JavaScript无法在Firefox中使用iframe

时间:2013-03-30 11:46:03

标签: javascript firefox iframe

我正在使用iframe加载带有表单的页面。使用javascript覆盖表单操作。 JavaScript表单操作正在IE和Chrome中运行。但是在Firefox中,javascript无效,表单已提交给http://example.com/index.php

代码如下:

<script language='Javascript' type='text/JavaScript'>
function submitFunction() {
document.Insert.action = 'http://example.com/page2.php';
return true;
}
</script>

<FORM ACTION='http://example.com/index.php' METHOD='POST' ENCTYPE='x-www-form-urlencoded' name='Insert' id='Insert' autocomplete='off' onsubmit='return(submitFunction())'>

<input name='num' SIZE='45' MAXLENGTH='45'>

<input name='Submit' type='submit'/>
</FORM>

提前致谢。

1 个答案:

答案 0 :(得分:1)

更改

document.Insert.action = 'http://example.com/page2.php';

document.getElementById('Insert').action = 'http://example.com/page2.php';

但是在onsubmit中更改表单的操作URL似乎有点奇怪。你也可以从一开始就定义它。

相关问题