针对 iframe 的 Firefox 表单正在打开新标签页 [英] Firefox form targeting an iframe is opening new tab

查看:28
本文介绍了针对 iframe 的 Firefox 表单正在打开新标签页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<form method="post" target="take_the_reload">

    ...

</form>


<iframe class="hide_me" name="take_the_reload"></iframe>

我的问题如下:

我有一个表单,在提交时需要阻止它刷新它所在的页面.为了解决这个问题,我一直使用一个空的 iframe 作为表单的 target.这在 Chrome (v12.0.742) 中完全按预期工作,但在 Firefox (v6.0) 中失败.

I have a form that needs to be prevented from refreshing the page it is located on when it is submitted. To combat this issue, I have been using an empty iframe as the target for the form. This works exactly as expected in Chrome (v12.0.742) but fails in Firefox (v6.0).

在 Firefox 中发生的情况是,提交表单时 iframe 在新选项卡中打开,这显然不是我想要的.

What happens in Firefox, is that the iframe is opened in a new tab upon form submission, which is obviously not what I want.

我发现了一些 相关 帖子,但没有解决我的特殊情况,他们的解决方案不起作用.

I have found some related posts, but none address my particular situation and their solutions do not work.

不幸的是,这项工作是在专用网络中的专有系统上进行的,所以我不能简单地提供链接.

Unfortunately, the work is on a proprietary system in a private network so I can not just simply provide a link.

我还尝试使用 frame 而不是 iframe 作为相关主题的答案是在这样的情况下使用 iframe一种方式已被弃用.但结果是一样的.

I have also tried using a frame as opposed to an iframe as an answer to a related topic was that using iframes in such a manner is deprecated. But the results are identical.

此外,iframe 是硬编码到页面中的,因为它不是用 JavaScript 动态添加的.最后,就像我之前说的,这在 Chrome 中可以完美运行,但在 Firefox 中根本无法运行.IE 不是问题,因此欢迎任何非 IE 友好的解决方案!

Also the iframe is hard-coded into the page in the sense that it is not dynamically added with JavaScript. Finally, like I said earlier, this works flawlessly in Chrome, but fails to work at all in Firefox. IE is not a concern and so any non-IE-friendly solutions are welcome!

推荐答案

这听起来可能很愚蠢,但您是否尝试为 iframe 提供与 name 属性相同的 ID?这似乎解决了一些与表单相关的问题.

This might sound stupid but did you try giving the iframe an id the same as the name attribute? This seems to solve some problems relating to forms.

<form method="post" action="link/to/post/to" target="take_the_reload">

    ...

</form>

<iframe id="take_the_reload" name="take_the_reload"></iframe>

这篇关于针对 iframe 的 Firefox 表单正在打开新标签页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆