I want to detect the browser return button in java-script / jquery without using any external plugins.
I will support the following browsers
IE8, IE9, Firefox, Chrome
I googled so many links and found below a piece of code from a code project
<body onbeforeunload="HandleBackFunctionality()"> function HandleBackFunctionality() { if(window.event) { if(window.event.clientX < 40 && window.event.clientY < 0) { alert("Browser back button is clicked..."); } else { alert("Browser refresh button is clicked..."); } } else { if(event.currentTarget.performance.navigation.type == 1) { alert("Browser refresh button is clicked..."); } if(event.currentTarget.performance.navigation.type == 2) { alert("Browser back button is clicked..."); } } }
The above code works with IE browser. this means that I can get the window.event.clientX and customerY values ββin IE browser. but in chrome / firefox does not work.
When I click the "Back back" button, I need to refresh the page.
how can I detect a mouse click event in a browser in all browsers (IE, firefox, chrome)
Any help would be appreciated.
source share