Latest web development tutorials

Location replace () method

Location Object Reference Location Object

Definition and Usage

replace () method can be used with a new document to replace the current document.

grammar

location.replace(newURL)


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support replace () method


Examples

Examples

Use replace () method to replace the current document:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function replaceDoc () {
window.location.replace ( "http://www.w3big.com")
}
</ Script>
</ Head>
<Body>

<Input type = "button" value = "Loading a new document to replace the current page" onclick = "replaceDoc ()">

</ Body>
</ Html>

try it"


Location Object Reference Location Object