Disabling Back Button of Browser using Javascript

Generally once user Logout, it redirects to login page. But user can go back(by clicking on browsers back button) due to caching concept. But user should not be able to go back.

Here is a simple solutions using javascript.Write this code in logout page.

<script type="text/javascript">
function noBack()
{ window.history.forward(); } //The forward method loads the next URL in the History list.
<body onload="noBack();" onpageshow="if (event.persisted) noBack();">
<h1>Back button disabled.</h1>


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: