No, you will need to use a child window for this. and disable toolbars,etc in it.
Main Topics
Browse All Topicshow can I disable the browser's "Back" button in a HTML page?
I do not want to create JavaScript window to avoid showing any toolbar,etc.
In regular HTML page, is there any way to disable the back button in the toolbar?
thanks.
-skundu
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You said ...
"Some commercial web pages does not let you go back to previous page (leaving their web site). How do they do that? By some way but not the javascript?"
A way to do that without javascript is to use a meta refresh tag in the entry page to your site. If you have a banner ad or a link to you from another site you can prevent the user from going back (leaving your site). Put the following meta tag in the <head></head> section of your page to redirect to page2.html after 0 seconds.
<meta http-equiv=refresh content="0, URL=page2.html">
You could put this in your home page and make page2.html your home page content.
This code is useful in following conditions.
1) When you dont want the round trip to server
2) When the page contents contains dynamically created objects. ( u will loose all the stuff u entered after refresh)
==========================
code follows
var gotBodyFocus=0; // used in gotBFocus() function.
function escBackSpace() // called on document.body keydown event
{
if(event.keyCode == 8)
{
if (gotBodyFocus == 1 | document.activeElement.get
{
//event.keyCode = 0;
event.returnValue=false
}
}
}
function gotBfocus() //called on document.body onfocus event
{
gotBodyFocus = 1;
}
function lostBfocus() // called on document.body onblur event
{
gotBodyFocus = 0;
}
<body MS_POSITIONING="GridLayout
<form id="Form1" method="post" runat="server" onkeydown="escBackSpace();
You may try the following options from JavaScript,
1. If you move from page1 -> page2, and want to disable the browser back in page 2,then add the following at the top of page1.
<script>
if(window.history.forward(
window.history.forward(1);
</script>
This works for both IE and NS
2.You may also replace the page in the history with the current page itself so that there is no page to go back.
location.replace(this) would do this.
3.If you are using JSP and not HTML, the best thing would be to prevent the JSP page from caching itself.
Theres another way you can do it.
Simply hide the back button and use a javascript to cancel out the Backspace button on the keyboard.
<script>
function KeyCache() {
if (window.event && window.event.keyCode == 8) {
window.event.keyCode = 123; //Replaces with F12 button. (Does nothing in IE)
}
}
document.onkeydown=KeyCach
</script>
We need a better solution. Here's a new scenario. I have a form that that I send to the user and I put different parts of the form in <Div></Div> pairs that I wrap around different parts of the form. I set the div attributes to hidden and only make visible the portion of the form that I want the user to fill in. Based on that input, I will hide the portion of the form they just completed and either show a new portion of the form or submit the form for processing. I need to keep the user from going back within that page so that I can properly manage the visiblity of the different parts of the form until the form is sent to the server for final process, after which I can return control of the browser back to them. Any creative solutions to this one?
well there seem to be a litle confusion about cache and history, i can disable cache and still be able to navigate back using several processes, even if cache of that page is disabled that means only that the page will be refreshed from the server, it solves most of the cases. But sometimes we dont want the history back thing.. well it seems wiser to me to prevent the url from entering the history list (this can be done sometimes using a location.replace) than catching all atempts to navigate back in history list. Of course this wont be good for everyone, in my case i dont mind user goes back to some other site but dont want to allow the resubmition/refresh of my page because it is not stateless the content displayed is always in conformity with the server stored state, meaning that going back and requesting some other thing from that page will bring confusion because the server responds only to the stored state (normal site and app's work on a stateless schema, all info needed to make an operation is submitted. not my case)
Add this to the bottom of your page:
<script>
window.onbeforeunload = function () {
// Disable back.
}
</script>
This works on IE, Firefox and Safari. Its used to give warnings when people leave your page, by any means, except for forms and links. Like closing the window or pressing then back button.
As a side effect the browser stops caching previous pages, if you press back you just return to the same page. We have been using this technique in a browser game, so that you dont get session and sql errors, cause people change pages and cookie and then return to a older view. ( see http://booty.game-host.org
For more info:
http://www.hunlock.com/blo
Business Accounts
Answer for Membership
by: apprentiPosted on 2003-12-17 at 11:49:04ID: 9959097
If you think this is a good functionality to implement, you've got some very strange ideas.