Location replace() method
Location object
Definition and Usage
The replace() method can replace the current document with a new document.
Syntax
location.replace(
newURL
)
Browser support





All major browsers support the replace() method
Example
Example
Use the replace() method to replace the current document:
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Runoob Tutorial(runoob.com)
title
<
script
function replaceDoc(){ window.location.replace("https://www.runoob.com") }
script
head
<body>
<input type="button" value=">Load a new document to replace the current page
"
onclick
=
"
replaceDoc()
"
body
html
Try it »
Location object