onunload无法在Chrome和Safari中使用
I have parent page and child page. In child page body tag i have below code.
我有父页面和子页面。在子页面正文标记我有下面的代码。
<body onunload="window.g_autoclosed=true;if(window.opener&&window.opener.NavModelessClose){window.opener.NavModelessClose(window,false);}">
when i click on button in parent page, child page should close and call the onunload event.
当我点击父页面中的按钮时,子页面应该关闭并调用onunload事件。
The unload event is raising correctly in IE and FF. But it is not raising in chrome and safari.
unload事件在IE和FF中正确引发。但它并没有提高铬和野生动物园。
Please help me.
请帮帮我。
4 个解决方案
#1
12
Modern WebKit browsers don't necessarily fire the unload
event at the moment where the page is hidden. This is done in order to allow improved caching.
现代WebKit浏览器不一定在隐藏页面时触发卸载事件。这样做是为了允许改进的缓存。
You might consider replacing the use of unload
with the pagehide
event.
您可以考虑使用pagehide事件替换unload的使用。
See this blog post for an in-depth discussion.
有关深入讨论,请参阅此博客文章。
更多相关文章
- JSON/Jave不更新innerHTML onClick事件。
- JavaScript中的事件详解
- 鼠标按下时是否可以防止鼠标光标离开页面
- 【JavaScript】案例一:使用JS完成注册页面表单校验
- OnClick事件只获取第一个动态创建的行/ id
- electron 将pc端(vue)页面打包为桌面端应用
- 从打印页面中删除网址并打印文本
- 如何在我的页面上以漂亮的格式显示JSON对象?(复制)
- 在contenteditable中的占位符—焦点事件问题