What's new? | Help | Directory | Sign in
Google
             
Search
for
Updated Sep 19, 2008 by pilgrim
Labels: about-dom, is-dom-method
LocationReplaceMethod  
The location.replace method

MSDN: "When a document is replaced, it is also removed from the history object. Moreover, the user interface navigation methods, such as the Back and Forward buttons, will no longer access the URL."

Mozilla Developer: "The difference from the assign() method is that after using replace() the current page will not be saved in session history, meaning the user won't be able to use the Back button to navigate to it."

Usage

location.replace(url)

Arguments

url = New location to load, replacing current page in history.

Browser compatibility

Compatibility table legend

Test IE8 IE7 IE6 FF3 FF2 Saf3 Op9 Chrome
typeOf(location.replace) != 'undefined' Y Y Y Y Y Y Y Y

Further reading


Comment by josh.avroch, Sep 03, 2008

The browser compatibility here is misleading. Certain browsers only half-support this method. As certain browsers don't replace the page in history. So, you can still hit back to get to the last page. For example, Safari, and the new Google Chrome, both don't replace the page in history.


Sign in to add a comment