因为在执行alert之前,aaa还未load入页面.
<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>

解决方案 »

  1.   

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

  2.   

    <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>
      

  3.   

    1.很明显,是先后次序问题么
    函数的定义可以放在后面
    但对象的定义就一定要放在前面了2.aaa前面要那个document干吗?去掉吧改成像下面这样就可以了:<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(aaa.value);
    -->
    </script>
    </body>
    </html>
      

  4.   

    也可以通过defer关键字来解决:<script language="JavaScript" defer>