谷歌浏览器onbeforeunload错误的行为与iframe [英] Google chrome onbeforeunload wrong behavior with iframe

查看:446
本文介绍了谷歌浏览器onbeforeunload错误的行为与iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两页。其中一个包含iframe中的另一个。如果您在父页面上订阅了onbeforeunload事件,则当iframe处于焦点时关闭标签页时,此事件不会触发。我想这是一个错误,写在这里:
Google Chrome问题



但我提到过,例如,Google文档处理这种情况。谁能给我一个解决方案?
重要提示:我没有实际的iframe内容,因为它是第三方的html编辑器(WYSIWYG)。

解决方案

我知道这是一个古老的问题,但只是帮助那些通过搜索来到这里的人: 现在在这里修复

由于chrome 10的问题应该得到解决。



有一个相关错误虽然在这里



所以,总之如果您仍然无法在框架上触发 onbeforeunload ,可能是因为通过JavaScript更改了内容,如 document.open document.write document.close 等。


Let say I have two pages. One of them contains another one inside as iframe. If you subscribe to onbeforeunload event on the parent page, then this event doesn't triggers if you close tab when iframe is in focus. I suppose it is a bug as written here: Google Chrome issues

But I mentioned that, for example, google docs handle this situation. Can anyone give me a solution? Important note that I have no actual access to the iframe content as it is a third party html editor (WYSIWYG).

解决方案

I know it is an old question but just to help people who are coming here through Search :

The bug is fixed by now here.

Since chrome 10, the issue should be fixed.

There is a related bug though here.

So, in short if you still not able to fire "onbeforeunload" on frames, it could be due to change in the content through JavaScript like document.open document.write document.close etc.

这篇关于谷歌浏览器onbeforeunload错误的行为与iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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