
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to disable browser's back button with JavaScript?
To disable web browsers’ back button, try to run the following code. This is the code for current HTML page,
Example
<html> <head> <title>Disable Browser Back Button</title> <script src = "http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> </head> <body> <a href = "newpage.html">Next Page</a> </body> <script> $(document).ready(function() { function disablePrev() { window.history.forward() } window.onload = disablePrev(); window.onpageshow = function(evt) { if (evt.persisted) disableBack() } }); </script> </html>
The following is the code for newpage.html,
<html> <body> Go to back page using web browser back button. </body> </html>a
- Related Questions & Answers
- How to disable back button in android while logging out the application?
- How to clean one's belly button?
- Disable a button with Bootstrap
- How to disable the back button in android while logging out the application using Kotlin?
- What's the best way to open new browser window using JavaScript?
- How to enable back button in action bar?
- How to enable back button in android webview?
- Disable a Bootstrap Button
- How to perform back and refresh in a browser in Selenium with python?
- How to set an element's display type with JavaScript?
- How to detect the browser's format for HTML input type date
- How to Disable / Enable a Button in TKinter?
- How can I pass arguments to Tkinter button's callback command?
- How to create a "scroll back to top" button with CSS?
- Sending response back from Node.js server to browser
Advertisements