Latest web development tutorials
 

Location assign() Method

< Location Object

Example

Load a new document:

location.assign("http://www.w3ii.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