javascript给iframe中的表单实现自动提交

有一个服务器端的表单页test.html,内容是:
<form action="http://127.0.0.1" method="post" id="go">
<input type="text" value="test" >
<input type="submit" value="提交" />
</form>

然后现在还有一个本地页面go.html,go.html用iframe加载了test.html,现在需要的是,打开go.html则自动提交test.html的表单,用js如何实现呢?我在go.html中写的代码是:
<html>
<iframe src="test.html" width="500" height="500">
</iframe>

<script language="javascript">
function submitForm()
{
var form=document.getElementsById("go").contentWindow.document;
form.submit();
}
</script>
</html>

但是这个代码根本提交不了,无法实现,求高手帮写一个正确的代码,万分感谢

第1个回答  2013-12-29
<body >
<iframe src="test.html" width="500" height="500" name="win" id="win" onLoad="window.frames['win'].document.aform.submit();" ></iframe>
</body>

//你试试 有问题再追问就行

第2个回答  2013-12-29
window.onload=function(){
test.go1.submit();
}

有这么难吗?

第3个回答  2013-12-29
你把自动提交放到test.html中啊。
<script language="javascript">
document.getElementsById("表单ID").submit();
</script>追问

有这么 容易我还用得着问????

相似回答