Window:origin 属性
Window
接口的 origin
只读属性返回全局作用域的来源(序列化为字符串)。
值
一个字符串。
示例
在 window 作用域中执行以下代码片段,则会将全局作用域的来源记录到控制台。
js
console.log(window.origin);
如果来源不是方案/主机/端口元组(例如试图在本地,即通过 file://
URL 运行脚本),origin
将返回字符串 "null"
。
规范
Specification |
---|
HTML # dom-origin-dev |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
origin |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.