页面还未加载完毕<html>
<head>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<script language="JavaScript" type="text/JavaScript" event="onload" for="window">
<!--
alert(document.all.aaa.value);
-->
</script>
</head>
<body leftmargin="0" topmargin="0">
<input  type=button name=aaa value="fdsfds">
</body>
</html>

解决方案 »

  1.   

    script语句在前面,页面运行时document.aaa不存在建议写一个script函数或过程,把document.aaa.value作为参数,再用onchange或click事件运行函数
      

  2.   

    这样就行了.<html>
    <head>
    <META content="text/html; charset=gb2312" http-equiv=Content-Type>
    </head>
    <body leftmargin="0" topmargin="0">
    <input  type=button name=aaa value="fdsfds">
    <script language="JavaScript" type="text/JavaScript">
    alert(document.all.aaa.value);
    </script>
    </body>
    </html>
      

  3.   

    <html>
    <head>
    <META content="text/html; charset=gb2312" http-equiv=Content-Type>
    <script language="JavaScript" type="text/JavaScript">
    function window.onload()
      {alert(document.aaa.value);}
    </script>
    </head>
    <body leftmargin="0" topmargin="0">
    <input  type=button name=aaa value="fdsfds">
    </body>
    </html>