Disabling the Back Button
Disable Browser Back Button Script. Disable Browser Back Button Implementation. For illustration purposes, two Pages are used Login and Home. Login Page. Home Page. Note : HTML Anchor link is added to illustrate that the Login page will be prevented only using Browser Back button and not when accessed using other means.
Browser Compatibility. Related Articles. Add Comments. Thank you for the feedback. The comment is now awaiting moderation. You will be notified via email when the author replies to your comment. You can add your comment about this article using the form below. Make sure you provide a valid email address else you won't be notified when the author replies to your comment Please note that all comments are moderated and will be deleted if they are Not relavant to the article Spam Advertising campaigns or links to other sites Abusive content.
Hlw Comment. Disclaimer : The code samples and API available at disab,e. You are free to use it for commercial as well as non-commercial use at your own risk, but you cannot use it for posting on blogs or other tutorial websites similar to www. All the code samples and API provided by the authors are solely their creation and neither the author nor the site are responsible if it does not work as intended. I agree to the ti terms.
How to disable back and forward button of browser in php
We can use 4mobile. Excellent article. But my problem is how to avoid the back button from the current page. For e. If user is trying to click on back button it should not go back, it should stay in the same page and user will forcefully close the browser. Appreciate if you can provide the code to handle this. Anyone who disables the back button of a browser is scum. Why would you want to intentionally make the internet harder for people to use?
Are you trying to ensure that repeat traffic on your website is zero? A properly designed website will never, for any reason, need this feature. What if you have a web-based application internal to your company running on JVMs? This action leads to null pointer exceptions in the application log, and rapid generation of many spurious objects within JVM memory, which Garbage Collection then struggles to delete.
Not everything is about traffic :. I remember I needed this for a Drupal website I was building a few years ago. Fortunately, we found a Drupal Module to do the trick. This is working like a charm. Thanks a lot. Now do you know how to disable the forward as well. Thanks a billion. Thanks Viral for sharing this. The fact that I have landed here, means I was looking for help. Those of you demeaning these solutions will one day come back to this site.
There are so many practical reasons for these requirements. I m using the code given below n this is not working so can anybody tell me what is the problem in this code. Thank you so much..
Hi prapoorna Is your functionality working when you pressed back button twice or more than once? If yes can you please provide the solution for this? Thanks Viral Your solution is working fine for me.
But its working only when i click Back Button first time. Any Solution to this Problem?? SetCacheability HttpCacheability. NoCache Response. SetExpires DateTime. AddHours -1 Response. Hi i have a question, I am performing a research were i am required to disable back button. I tried your code and its working fine. Do my question is how do i save my current state. Please guide. Appreciate your help. Its works nicely but if you disable the back button then its look more good.
Plz help. Pls provide me example code for warning message when user clicks back button in jsp. Your email address will not be published. Save my name, email, and website in this browser for the next time I comment.
This is common in Online Banking Websites and other sites where security is of principal concern. User may hit back and navigate from the page and forget to logout. Hence sometime it is required that we disable the functionality of Back button. But unfortunately this is not an easy task. There is no direct way of dealing with this problem. We can do few hacks to ensure that user does not get back in the browser. Following are few tricks that can be used to disable the back button in browser.
But in some case it works like charm. All you have to do is to open the webpage in a new window. This technique does work in some case but user has still a workaround to navigate to previous page. Most of the browser have options of Back in context menu.
Manoj says:. Michael Freidgeim says:. Mayur says:. Sedat Kumcu says:. Shobhraj says:. Amit Herlekar says:. Pavan says:. Rubesh says:. Azhar says:. Dumindu says:. Shishir says:. Sachin Kalane says:. DineshKumar says:. Nandha says:.