<html>
<head>
<title> new document </title>
</head>
<body onLoad="aaa()">
</body>
</html>
<script language="javascript" type="text/javascript">
function aaa()
{
alert("aaa");
}
</script>

解决方案 »

  1.   

    楼主是不是少了个标签  <form>
      

  2.   

    <html>
    <head>
    <title> new document </title>
    </head>
    <body>
    <script language="javascript" type="text/javascript">
    function aaa()
    {
    alert("aaa");
    }
    aaa();
    </script>
    </body>
    </html>
    ie6测试通过
      

  3.   

    <html>
    <head>
    <title> new document </title>
    <script language="javascript" type="text/javascript">
    function aaa()
    {
        alert("aaa");
    }
    </script>
    </head>
    <body>
            <script language="javascript" type="text/javascript">
              aaa();
            </script>
        </form>
    </body>
    </html>
      

  4.   

    哪里出错:
    JavaScript 和 HTML 一样都是顺序执行的,
    如果你后面的部分没有加载到浏览器里头,
    那你在前面调用这个函数,浏览器就会提示出错!最好用document.all 判断下!