How to know in Firefox whether refresh button is clicked or browser back button is clicked... for both events onbeforeunload()
method is a callback. For IE I am handling like this:
function CallbackFunction(event) { if (window.event) { if (window.event.clientX < 40 && window.event.clientY < 0) { alert("back button is clicked"); }else{ alert("refresh button is clicked"); } }else{ // want some condition here so that I can differentiate between // whether refresh button is clicked or back button is clicked. } } <body onbeforeunload="CallbackFunction();">
But in Firefox event.clientX and event.clientY are always 0. Is there any other way to find it?
If you press the Firefox menu button and select Customize, you can drag the reload button back to the toolbar. See Customize Firefox controls, buttons and toolbars for more information. Hope this helps. If you press the Firefox menu button and select '''Customize''', you can drag the reload button back to the toolbar.
You can do it like this: window. onbeforeunload = function() { return "Data will be lost if you leave the page, are you sure?"; };
Use for on refresh event
window.onbeforeunload = function(e) { return 'Dialog text here.'; };
https://developer.mozilla.org/en-US/docs/Web/API/window.onbeforeunload?redirectlocale=en-US&redirectslug=DOM%2Fwindow.onbeforeunload
And
$(window).unload(function() { alert('Handler for .unload() called.'); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With