Skip to main content

Posts

Showing posts with the label How to disable browser back button using JavaScript & MVC 5?

How To Detect Browser Back Button Event - Cross Browser?

Howto disable browser back button using JavaScript & MVC 5? How do I get a browser back button event using JavaScript? Warn and confirm to the User, if Back button is pressed is as below - window . onbeforeunload = function () { return "Your data will be lost!" ; }; You can also add hash when page is loading – location . hash = "noBack" ; Then just handle location hash change to add another hash – $( window ). on ( 'hashchange' , function () {     location . hash = "noBack" ; }); That makes hash always present and back button tries to remove hash at first. The Events – < script type= "text/javascript" >     function handleBackFunctionality () {         if ( window . event ) {             if ( window . event . clientX < 40 && window . event . clientY < 0 ) {     ...