How can I know in Firefox whether the refresh button is clicked or browser back button is clicked? For both events, the onbeforeunload()
method is a callback. For Internet Explorer, 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 {
// I 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 another way to find it?