Location replace() Method - Javascript Browser Object Model

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 Values

Parameter Type Description
newURLString Required. URL of the page to navigate to

Return Value

No return value

The following code shows how to Replace the current document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Replace document</button>

function myFunction() {//from w  w w . j a  v  a2 s  . com


Related Tutorials