iframe导航打破Firefox后退按钮 - 解决方法?
There is an annoying bug in Firefox where navigation in a dynamically created iframe, which is then removed via Javascript, results in the inability to go back using the Firefox back button (you have to use the drop down and navigate back a further couple of pages).
I am using a form in an iframe which validates and submits data. On form submit/data validation the page in the iframe gets refreshed. This breaks the Firefox back button as above.
I need a solution to try and solve this issue and I've currently tried a few different things without much success:
- Storing each iframe page refresh in a session variable (PHP) and then using
history.go(-{session var})
in my jQuery code to navigate back. However this only seems to work when navigating back to the page BEFORE the iframe loaded, not the page where the iframe is loaded (in the later, it still breaks the back button) - Hiding the iframe rather than removing it - semi-works but requires multiple back button clicks and brings up the 'do you want to resubmit this data?' message
- Reloading the iframe when the user has closed it. No advantage doing this as if you go back you have to still go through all the previous iframe gubbins.
Any suggestions appreciated - but please note: I want to use an iframe, do not really want to use ajax and would love a solution that is cross-browser compatible (ha!).
If you're interested, steps to reproduce this problem:
- In Firefox try the iframe example which loads Google on the fancybox homepage: http://fancybox.net/home
- Search for something, i.e. load a new page in the iframe
- Close fancybox frame
- Try and go back without resorting to the back dropdown list
Incidentally, IE handles this scenario more gracefully than either Chrome or Firefox!
有一个恼人的错误,在动态创建的iframe中导航,然后通过Javascript删除,导致无法使用Firefox后退按钮返回(您必须使用 下拉并导航回另外几页)。 p>
我在iframe中使用表单来验证和提交数据。 在表单提交/数据验证中,iframe中的页面会刷新。 这打破了Firefox返回按钮,如上所述。 p>
我需要一个解决方案来尝试解决这个问题,我现在尝试了一些不同的事情但没有取得多大成功: p>
- 将每个iframe页面刷新存储在会话变量(PHP)中,然后在我的jQuery代码中使用
history.go( - {session var}) code>进行导航。 然而,这似乎只有在加载iframe之前导航回页面时才有效,而不是加载iframe的页面(在后面,它仍会打破后退按钮) li>
- 隐藏iframe而不是 删除它 - 半工作但需要多次后退按钮点击并显示'你想重新提交这些数据吗?' 消息 li>
- 当用户关闭iframe时重新加载iframe。 没有优势,如果你回去你必须仍然通过所有以前的iframe gubbins。 li> ul>
任何建议赞赏 - 但请注意:我想使用 一个iframe,真的不想使用ajax,并且喜欢跨浏览器兼容的解决方案(哈!)。 p>
如果您有兴趣,可以采取措施重现此问题: p>
- 在Firefox中尝试使用iframe加载Google的示例 fancybox homepage: http://fancybox.net/home li>
- 搜索 某事,即在iframe中加载新页面 li>
- 关闭fancybox框架 li>
- 尝试并返回而不使用后退下拉列表 li>
ul>
顺便说一下,IE比Chrome或Firefox更优雅地处理这种情况! p> div>
I've given up on this as have tried everything under the sun. Resorting to posting data via jQuery's AJAX methods which won't add a history item.