因为在执行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>
<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>
解决方案 »
- 一个奇怪的js错误,求正解!
- http://examples.ext.net/这网站上的教程文档,有没有离线教程文档可以下载呢?
- onmousedown和onclick的奇怪问题
- 小弟向各位前辈提问!
- 如何批量依次提交数据?悬赏100分啊
- 怎么样删除数组中的重复元素?大家来看看我的算法。欢迎斧正。
- 关于从数据库提取时间的问题,大侠们,帮帮忙!!!
- 问一个关于Table修改行的问题
- 能将javascript改写成其它语言吗?
- 請問可不可以只刷新jsp頁面的某一部分,例如頁面中的某一個表格,而不是整個頁面都刷新,可不可以實現的,如何做?因爲現在要做一個聊天
- 关于showModalDialog打开的窗口的里面连接问题
- 怎样用程序控制对IE中Internet选项中各种设置的修改?(谢谢,非常急用)
<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>
函数的定义可以放在后面
但对象的定义就一定要放在前面了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>