5
Answers

how to disable a back button in a browser

Photo of sangeetha k

sangeetha k

7y
247
1
I am working on a project and where it that i have an option to navigate to a page which is endsession page on reaching that page i should not be able to go back in the browser any further. already i have killed the session and cleared the cache but yet its in vain. Can anyone suggest me something other than window.history.forward(); ?

Answers (5)

0
Photo of Mangesh Gaherwar
NA 4.1k 70.9k 7y
Sangeetha
 
there is nothing 100% which we can do with the Browsers back button we have to go with this solution only and there is no standard which will work across browser from the safari to chrome to IE so stick to this option and move ahead 
 
thanks 
 
mark approved if it helps 
0
Photo of sangeetha k
NA 98 2.9k 7y
i tried it its working bt is there anything which will disable the backbutton it should not be clickable
0
Photo of Mangesh Gaherwar
NA 4.1k 70.9k 7y
Hey sangeetha
 
dont know if this is the full proof and how many browser supports u can try this
  1. <html>  
  2. <head>  
  3. <title>Disable Back Button in Browser - Online Demo</title>  
  4. <style type="text/css">  
  5. body, input {  
  6. font-family: Calibri, Arial;  
  7. }  
  8. </style>  
  9. <script type="text/javascript">  
  10. window.history.forward();  
  11. function noBack() {  
  12. window.history.forward();  
  13. }  
  14. </script>  
  15. </head>  
  16. <body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">  
  17. <H2>Demo</H2>  
  18. <p></p>  
  19. <p>Click here to Goto <a href="noback.html">NoBack Page</a></p>  
  20. </body>  
  21. </html>  
try running this in ur browser and lemme know if it helps
0
Photo of sangeetha k
NA 98 2.9k 7y
have tried using this i am asking for a solution which will disable the entire back option it self this goeas back and again comes and gets retained 
0
Photo of Mangesh Gaherwar
NA 4.1k 70.9k 7y
  1. <script type = "text/javascript" >  
  2. function preventBack(){window.history.forward();}  
  3. setTimeout("preventBack()", 0);  
  4. window.onunload=function(){null};  
  5. </script>  
https://stackoverflow.com/questions/12381563/how-to-stop-browser-back-button-using-javascript
Did u try this Go through this once