I\'m using window.onbeforeunload to display a message to the user on windows close, the function works well with Chrome and IE but it doesn\'t work with Firefox
I looked for a Firefox onbeforeunload solution over 2 days and with no luck, so I worked hard on this, and did it with a little trick.
In my trick, the user needs to click on the browser window at least once.
If the user clicks on the window and then clicks on the back button, refreshes the page, or tries to exit the page, onbeforeunload events will fire,
$(window).on('beforeunload', function () {
return "Are you sure you want to exit this page?";
});
$(window).one('click',function(){
alert('hi');
$('.javavoid').trigger('click');
});
.hide{display:none;}
asdf
Welcome, click anywhere then click on back button or refresh page