sse*_*ell 42 html forms firefox
<form method="post" target="take_the_reload">
...
</form>
<iframe class="hide_me" name="take_the_reload"></iframe>
Run Code Online (Sandbox Code Playgroud)
我的问题如下:
我有一个表单需要防止刷新它提交时所在的页面.为了解决这个问题,我一直在使用空格iframe作为target表格.这与Chrome(v12.0.742)中的预期完全一致,但在Firefox(v6.0)中失败.
在Firefox中发生的是,在表单提交时在新选项卡中打开iframe,这显然不是我想要的.
我找到了一些 相关的 帖子,但没有一个解决我的特殊情况,他们的解决方案不起作用.
不幸的是,这项工作是在专用网络中的专有系统上进行的,所以我不能简单地提供一个链接.
我也试过使用a frame而不是iframe作为对相关主题的回答是,iframe以这种方式使用s已被弃用.但结果是一样的.
此外,它iframe是硬编码到页面中的,因为它不是动态添加JavaScript.最后,正如我之前所说的,这在Chrome中完美无缺,但在Firefox中根本无法工作.IE不是一个问题,因此欢迎任何非IE友好的解决方案!
sg3*_*g3s 80
这可能听起来很愚蠢,但你尝试给iframe一个id与name属性相同吗?这似乎解决了与形式有关的一些问题.
<form method="post" action="link/to/post/to" target="take_the_reload">
...
</form>
<iframe id="take_the_reload" name="take_the_reload"></iframe>
Run Code Online (Sandbox Code Playgroud)
Cha*_*les 10
对于将来对此进行调查的任何人,请注意,如果您有两个或更多针对相同iframe ID的表单,Firefox将打开一个新选项卡,除非这两个表单具有不同的名称.奇怪的是,这不是Chrome中的问题.因此,例如,这在Firefox中不起作用
<form method="post" action="link/to/post/to" target="theiframe">
<!---input stuff here---->
</form>
<form method="post" action="link/to/post/to" target="theiframe">
<!---input stuff here---->
</form>
<iframe id="theiframe" name="theiframe"></iframe>
Run Code Online (Sandbox Code Playgroud)
但它可以在Chrome中使用.如果您希望代码在Chrome和Firefox中都有效,则必须执行以下操作:
<form name="form1" method="post" action="link/to/post/to" target="theiframe">
<!---input stuff here---->
</form>
<form name="form2" method="post" action="link/to/post/to" target="theiframe">
<!---input stuff here---->
</form>
<iframe id="theiframe" name="theiframe"></iframe>
Run Code Online (Sandbox Code Playgroud)
不知道这是一个错误还是Firefox就是这样设计的.我正在使用Firefox 18(截至本文撰写时的最新版本),它仍然是一个问题.
希望这有助于其他人; 在我最终弄清楚问题是什么之前,我咬牙切齿大约2个小时.
干杯!
小智 8
提示:不要在id和name中使用大写字母
不行
<iframe id="formSubmit" name="formSubmit">
Run Code Online (Sandbox Code Playgroud)
作品
<iframe id="form_submit" name="form_submit">
Run Code Online (Sandbox Code Playgroud)
这对我来说真是太神奇了!
| 归档时间: |
|
| 查看次数: |
22798 次 |
| 最近记录: |