|
|
Q370 How can I display a confirm box when a user unloads the page?
irt.org | Knowledge Base | JavaScript | Document | Q370 [ previous next ] Q370 How can I display a confirm box when a user unloads the page?Once a user has chosen to unload a document apart from telling him/her that he/she is leaving there's not much that can be done. If however you are only interested in whether the user clicks a link on the page then you can confirm that they want to leave:
However, the user can: close the window, close the browser, press back, type in a url, select a url from the history, select a url from the bookmarks - none of which can be prevented. The following was submitted by wEEdpEckEr Its actually pretty simple, instead of the onLoad, just use the onUnload attribute for the body-tag. When the users closes the page, goes to another one or anything else that leads away from that page, the function will be executed.
|
-- div -->
|