错误行:document.write(d.elements[i].name);
只输出了textfield,然后就提示说没有权限 纳闷
- HTML code
<html> <head> <script type="text/javascript"> function op() { var d = document.getElementById("form1"); var l = d.length; for(var i = 0; i < l-1; i++) { document.write(d.elements[i].name); } //document.write(d.elements[2].name); } </script> </head> <body> <form name="form1" action="3.html" method="post"> <input type="text" name="textfield" id="textfield"> <input type="text" name="textfield2" id="textfield2"> <input type="text" name="textfield3" id="textfield3"> <input type="text" name="textfield4" id="textfield4"> <input type="submit" name="button" id="button" value="提交" onclick="op()"> </form> </body> </html>
------解决方案--------------------
document.write 是从新建一个新文档了
后面的都不执行了