I am creating an HTML printable quiz and test maker and I would like to confirm "Are you sure you want to close this window?" when the user attempts to close the window. If they click ok it closes, but if they click cancel it does not.
I need this to work in IE and Chrome.
I am creating an HTML printable quiz and test maker and I would like to confirm "Are you sure you want to close this window?" when the user attempts to close the window. If they click ok it closes, but if they click cancel it does not.
I need this to work in IE and Chrome.
Share Improve this question edited Dec 11, 2013 at 6:54 Jonathan Leffler 756k145 gold badges951 silver badges1.3k bronze badges asked Mar 22, 2013 at 20:37 Dustin HDustin H 852 silver badges8 bronze badges 1- 4 You're probably looking for developer.mozilla/en-US/docs/DOM/window.onbeforeunload – j08691 Commented Mar 22, 2013 at 20:39
1 Answer
Reset to default 5window.onbeforeunload = function(e) {
return 'some prompt text';
};
Working Example