我有这个代码,让我们说吧 a.html
<form name="frmSubmit" id="frmSubmit" method="post">
<input type="hidden" name="hdnName" value="user name" />
</form>
<script>
// 1 : start
document.frmSubmit.action = 'b.html';
document.frmSubmit.submit();
// 1 : end
// 2 : start
document.getElementById("frmSubmit").action = 'b.html';
document.getElementById("frmSubmit").submit();
// 2 : end
</script>
Run Code Online (Sandbox Code Playgroud)
既1和2在IE(IE 8)工作,而不是在FF(3.6.10).Firebug给我以下错误:
document.frmSubmit未定义
我该如何解决?
<html>
<head>
<script>
function setup(){
// 1 : start
document.frmSubmit.action = 'b.html';
document.frmSubmit.submit();
// 1 : end
// 2 : start
document.getElementById("frmSubmit").action = 'b.html';
document.getElementById("frmSubmit").submit();
// 2 : end
}
</script>
</head>
<body onload="setup()">
<form name="frmSubmit" id="frmSubmit" method="post">
<input type="hidden" name="hdnName" value="user name" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8558 次 |
最近记录: |