Search w3schools.com:

SHARE THIS PAGE

Location replace() Method

Location Object Reference Location Object

Definition and Usage

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

Syntax

location.replace(newURL)


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The replace() method is supported in all major browsers.


Example

Example

Replace the current document:

<html>
<head>
<script>
function replaceDoc()
  {
  window.location.replace("http://www.w3schools.com")
  }
</script>
</head>
<body>

<input type="button" value="Replace document" onclick="replaceDoc()">

</body>
</html>

Try it yourself »


Location Object Reference Location Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]