Sometimes when you create web-applications (eg: ASP.Net, etc), you need to disable the use of the browser back button. Now there is no way you can actually disable the browser back button using JavaScript, so you could create a new window without toolbars, etc.
But another way you can do it is by inserting the following code into the page that you don’t wish to support the ability to go back to:
<head>
<script type="text/javascript">
window.history.go(1)
</script>
</head>
How does it work?
go(1), makes the browser go forward to the next page in the browser history. The first time you visit a page, your browser history does not have a page to go to, so go(1) does nothing. But if you try and go back to a page on which the above code exists, then because you have a page in history, go(1) works and takes you back to the page that you were on. Simple and effective.
Note: I came across this solution on the Internet and cant find the link anymore.
1 comment:
good script ....it works thanks buddy :)
Post a Comment