Window location.assign()

Example

Load a new document:

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

Description

The assign() method loads a new document.

See Also:

The replace() Method

Note

The difference between assign() and replace():

replace() removes the current URL from the document history.

With replace() it is not possible to use "back" to navigate back to the original document.


Syntax

location.assign(URL)

Parameters

Parameter Description
URL Required.
The URL of a page to navigate to.

Return Value

NONE

Browser Support

location.assign() is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.