I am trying to come up with a function that will confirm the user actually wants to close the browser window.
It is easy to do if I create the close button but I am trying to have it work if someone closes the window another in other ways. For example the X button. Here is were I am with it. The confirm works but if they click Cancel the window closes anyway. Can anyone steer me in the right direction?
Code:function init() { if (confirm("You have not submitted your registration yet. Are you sure you want to quit?")) { parent.close(); } else { alert("Close cancelled."); } } window.onunload = init;


Reply With Quote
Bookmarks