这篇翻译不完整。请帮忙从英语翻译这篇文章。
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
错误会被抛出。
Syntax
object.assign(url);
Parameters 参数
Examples
// Navigate to the Location.reload article 例子,载入Location.reload 这篇文章 document.location.assign('https://developer.mozilla.org/en-US/docs/Web/API/Location.reload');
Specifications 说明
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard Location.assign() |
Living Standard | No change from HTML5. |
HTML5 Location.assign() |
Recommendation | Initial definition. |
Browser compatibility 浏览器的兼容性
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 更多
- The
Location
interface it belongs to. - Similar methods:
Location.replace()
andLocation.reload()
. - 属于
Location
接口 - 相似方法:
Location.replace()
andLocation.reload()
.