Skip to main content

Posts

Showing posts with the label disable browser back button javascript

How to disable browser back button AngularJs?

How to disable browser back button using JavaScript? AngularJs provides a useful event called location Change Start. The examples for $rootScope and $scope level looks like, Example1 for $scope level as below, //How to disable browser back button angularjs? //Added event listner for disabled back button. $ scope. $ on( '$locationChangeStart' , function (evnt, next, current){ alert ( "Your, browsers back button is disabled!" ); //Prevent browser's back button default action. evnt.preventDefault(); }); Example2 for $rootScope level as below, //Using $rootScope for event $locationChangeStart. app.run([ '$rootScope' , function ($rootScope) { $ rootScope. $ on( '$locationChangeStart' , function (event) { event .preventDefault(); }); }]); I hope, It might help you! Thank you!

How to disable browser back button using JavaScript & MVC 5?

How to disable browser back button using JavaScript & MVC 5? How do I get a browser back button event using JavaScript? Hello everyone, Today's I have a requirement to disable browsers back button in MVC 5 projects , I have fixed the the above problem using the below  example code. Table of Contents : JavaScript code C# code for MVC ActionResult Step 1. The JavaScript Code sample The  javascript code put master page of the application for disable the browser back button.   ? 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 //This is JavaScript code for "disable browsers back button.   <script type="text/javascript">            function disableBackButtonAllBrowsers() {              window.history.forward()       ...