Main Page |
10.2 Keeping a Page Out of the Browser HistoryNN 3, IE 4 10.2.1 ProblemYou want to remove the current page from the browser history so that the Back button does not take the user back to the current page after a script navigates to some other page. 10.2.2 SolutionNavigate to the next page via the location.replace( ) method: location.replace("http://www.megacorp.com/indexDHTML.html"); 10.2.3 DiscussionThe capability of keeping a page out of the browser's history can come in handy when your site contains a page that include automatic forwarding under script control. Recipe 5.10 is a typical situation that benefits from keeping a temporary page out of the history. If the user reaches the real home page, a press of the browser's Back button normally brings the user back to the temporary page, and the user is essentially trapped in an infinite loop from which escape can only occur by going forward. You can also use this technique if you do not want a user to come back to a form after submitting it. But in this case, you must assemble the form data yourself, appending it to the URL string passed with the replace( ) method. The page returned from your CGI program replaces the form page in the browser history. Be aware, however, that this works only for form submissions that can be accomplished with the GET method, rather than the POST method. Invoking the location.replace( ) method causes the browser to request a page through a GET method just like a regular web page. 10.2.4 See AlsoRecipe 5.10 for a likely scenario for using location.replace( ); Recipe 10.6 to see how to assemble form data as part of a URL. |
Main Page |