Javascript examples for Browser Object Model:Location
The replace() method replaces the current document with a new one by passing URL.
replace() removes the URL of the current document from the document history, and it is not possible to use the "back" button to navigate back to the original document.
Parameter | Type | Description |
---|---|---|
newURL | String | Required. URL of the page to navigate to |
No return value
The following code shows how to Replace the current document:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Replace document</button> <script> function myFunction() {//from w w w . j a v a2 s . com location.replace("http://www.java2s.com") } </script> </body> </html>