Possible Duplicate:
Disabling Back button on the browser
How do I disable the back button of a browser using JavaScript?
You can't, and you shouldn't try to. The users browser is expected to behave a certain way, you should not break that expectation. Your site should behave like the other 99.999999% of the internet, it shouldn't suddenly change the meaning of the users toolbar buttons, their very fundamental browser operation.
What are you trying to prevent? There's probably a much better solution to the problem, e.g. page cache timeout, etc. I would say form posting and not wanting to re-post is the most common problem you're trying to avoid, if that's the case, give another model a look.
You shouldn't. But what's about opening a new browser window?
You cannot manipulate browser's GUI from a web page on such detailed level. Consider the consequences - what a mess and abuse.
You cannot and you never should attempt to do so.
Users are free to re-open a page they have visited before, the back button helps them go back easily to the last page visited.
If this is for some "defensive" requirement, it is better to have it on the application level and not the browser.
精彩评论