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.
The unload event is raising correctly in IE and FF. But it is not raising in chrome and safari.
Please help me.
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.
You might consider replacing the use of unload
with the pagehide
event.
Unload works in modern browsers, but for example you cant launch an alert. See: http://bugs.jquery.com/ticket/10509
Also if you want to use $.get or $.post in unload, is better that you use $.ajax with async=false.
Ex:
$(window).unload(function() {
$.ajax({
url: '/some_url.htm',
async: false
});
});
也许尝试onbeforeunload
事件?
是的,附加到窗口(或子页面的内部窗口)的onbeforeunload应该这样做
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.