How to identify browser tab closing using JavaScript or jQuery? I have to give a confirmation message when user click on the browser close button. If user press yes button I have to load another page on the same tab. if press cancel. then close the tab. any body knows the scripts for this functionality. Please help me :(
4 Answers
That's annoying as hell from a user experience perspective IMO, but you can try using the onunload event:
$(window).unload(function() { if(confirm("Load something else here?")) { // blah blah blah } });