This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The assign() method of the Location interface causes the window to load and display the document at the URL specified. After the navigation occurs, the user can navigate back to the page that called Location.assign() by pressing the "back" button.
assign(url)
urlA string or any other object with a stringifier, such as a URL object, containing the URL of the page to navigate to; for example, an absolute URL such as https://developer.mozilla.org/en-US/docs/Web/API/Location/reload, or a relative URL — such as /Web (just a path, for navigating to another document at the same origin) or #specifications (just a fragment string, for navigating to some part of the same page), and so on.
SecurityError DOMException
Thrown if the origin of the script calling the method is not the same origin of the page originally described by the Location object, mostly when the script is hosted on a different domain. Browsers also throttle navigations and may throw this error, generate a warning, or ignore the call if it's called too frequently.
SyntaxError DOMException
Thrown if the provided url parameter is not a valid URL.
None (undefined).
// Navigate to the Location.reload article
window.location.assign(
"https://developer.mozilla.org/en-US/docs/Web/API/Location/reload",
);
// Then navigate to its Specifications section
window.location.assign("#specifications");
// Eventually navigate to https://developer.mozilla.org/en-US/docs/Web
window.location.assign("/Web");
| Specification |
|---|
| HTML> # dom-location-assign-dev> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
assign |
1 | 12 | 1 | 3 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
Location interface it belongs to.Location.replace() and Location.reload().
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Location/assign