We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE


The Location.assign() method causes the window to load and display the document at the URL specified.

The Location.assign() 方法发起 window 读取并显示特定URL指向的document 。

If the assignment can't happen because of a security violation, a DOMException of the SECURITY_ERROR type is thrown. This happens if the origin of the script calling the method is different from the origin of the page originally described by the Location object, mostly when the script is hosted on a different domain.

假如因为安全违规导致操作失败, 将会抛出一个SECURITY_ERROR type类型的DOMException错误。假如发起请求的脚本源与Location object 对象所描述的原始页面来源不一致时或者大多是情况由于不同的主机分布,会导致发生这类错误。

If the provided URL is not valid, a DOMException of the SYNTAX_ERROR type is thrown.

假如请求的URL是无效的,SYNTAX_ERROR type中的DOMException错误会被抛出。



Parameters 参数

Is a DOMString containing the URL of the page to navigate to.


// Navigate to the Location.reload article
例子,载入Location.reload 这篇文章

Specifications 说明

Specification Status Comment
HTML Living Standard
Living Standard No change from HTML5.
Recommendation Initial definition.

Browser compatibility 浏览器的兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

See also 更多



 此页面的贡献者: luyouxin84
 最后编辑者: luyouxin84,