JavaScript不工作在Firefox中的iframe中
问题描述:
我正在使用一个用表单加载页面的iframe。表单操作使用javascript重写。 javascript表单操作在IE和Chrome中运行。提前JavaScript不工作在Firefox中的iframe中
<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>
感谢:但在Firefox的JavaScript不能正常使用的形式得到提交http://example.com/index.php
下面的代码中给出。
答
变化
document.Insert.action = 'http://example.com/page2.php';
到
document.getElementById('Insert').action = 'http://example.com/page2.php';
但似乎有点陌生,改变表单的动作URL中的onsubmit。你可以从一开始就定义它。
我想隐藏网址,因此我将它加载到iframe中。提交按钮将在鼠标悬停上显示表单动作url。问题是当它加载到iframe中时。 – user1690835
@ user1690835:允许用户看到将要发生的事情是** Good Thing **。强烈建议专注于有用的功能,而不是隐藏用户的东西。 –