在javascript中可以在一个function定义之后 立即调用该function: <script type="text/javascript"> var showMsg = function(){alert("自动运行的function")}(); </script>