Location assign() Method
THE WORLD'S LARGEST WEB DEVELOPER SITE

Location assign() Method

❮ Location Object

Example

Load a new document:

location.assign("https://www.w3schools.com");
Try it Yourself »

Definition and Usage

The assign() method loads a new document.

The difference between this method and replace(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the "back" button to navigate back to the original document.


Browser Support

Method
assign() Yes Yes Yes Yes Yes

Syntax

location.assign(URL)

Parameter Values

Parameter Type Description
URL String Required. Specifies the URL of the page to navigate to

Return Value

No return value

❮ Location Object