Catch window close and confirm
Posted on 2004-11-04
I have a webpage to be used for delivering a test to users. The grade a user gets counts towards their overall grade. If they close or navigate away from the test page, the test will time out on the server and will be forfeited, resulting in a poor overall grade.
What i need to do is detect when the page is unloaded and offer the option of staying on the page. I can do it fine in IE, but I cant get it to go in Firefox. (I dont have Netscape so cant test it in there.)
Heres what I have:
window.event.returnValue = "This will cancel the test. Are you sure you want to do this?";