Detect click browser refresh button for all modern browsers

I really can’t find the answer to my question, if it is possible to define jquery, if the user clicks the Refresh / Reboot button in a modern browser?

I found...

window.onbeforeunload = function(e) { // Action }; 

... but the problem along the way is that it always fires when the page loads. But if I use the forward button and then the back button, it should not do this, only when the update button is clicked. Is it possible? And is there a solution for all modern browsers?

Edit: thanks for the link, I will try the cookie example.

+6
source share
1 answer
 window.onunload = function(){ alert("unload event detected!"); } 

Start a fire before the window really refreshes.

or for key detection

 $("body").keydown(function (e) { if (e.which == 116 || e.which == 17) { inFormOrLink = true; } }); 
-1
source

All Articles