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.
One significant difference (other than cancelability) between the onbeforeunload and onunload is that the former is triggered for download links and the latter is not. Example: <a href="https://somewhere.com/thething.zip">download</a> will trigger the onbeforeunload handler, but not the onunload .
The beforeunload event is fired when the window, the document and its resources are about to be unloaded. The document is still visible and the event is still cancelable at this point. This event enables a web page to trigger a confirmation dialog asking the user if they really want to leave the page.
This feature is deprecated/obsolete and should not be used.
onunload occurs when the user navigates away from the page (by clicking on a link, submitting a form, closing the browser window, etc.). Note: The onunload event is also triggered when a user reloads the page (and the onload event).
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.
See this blog post for an in-depth discussion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With