X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Location replace() Method

Location Object Reference Location Object

Example

Replace the current document:

location.replace("http://www.w3schools.com");

Try it yourself »


Definition and Usage

The replace() method replaces the current document with a new one.

The difference between this method and assign(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the "back" button to navigate back to the original document.

Tip: Use the assign() method if you want to load a new document, and the option to navigate back to the original document.


Browser Support

Method
replace() Yes Yes Yes Yes Yes


Syntax

location.replace(newURL)

Parameter Values

Parameter Type Description
newURL String Required. Specifies the URL of the page to navigate to

Return Value

No return value


Location Object Reference Location Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook