Skip to main content

Can we capture the same browser closing event without using “onunload”



Actually using the window.close , we can control whether browser is closed or not, but it works only for pop-ups created by the browser.





So, are there any ways to listen to the closing event of the browser without using onunload ? Because we don't want things to be executed when back , refresh or forward actions occur.





Please also reply if you know specifics regarding Firefox.





Thanks in advance!


Comments

  1. You are trying to manipulate the EXPECTED behaviour of the browser, essentially taking away people's ability to navigate. Fortunately browser developers were smart enough to disallow this - so the answer is NO.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...