origin 只读特性在 定位 接口是 USVString containing the Unicode serialization of the origin of the represented URL ; that is:

  • for URL using the http or https , the scheme followed by '://' , followed by the domain, followed by ':' , followed by the port (the default port, 80 and 443 respectively, if explicitely specified);
  • for URL using 文件: scheme, the value is browser dependant;
  • for URL using the blob: scheme, the origin of the URL following blob: . E.g "blob:https://mozilla.org" will have "https://mozilla.org".
注意: 此特征可用于 Web 工作者 .

句法

string = object.origin;
						

范例

// On this page, returns the origin
var result = window.location.origin; // Returns:'https://developer.mozilla.org'
						

规范

规范 状态 注释
HTML 实时标准
The definition of 'origin' in that specification.
实时标准 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
origin Chrome Yes Edge 12 Firefox 26
26
Before Firefox 49, results for URL using the blob scheme incorrectly returned null.
IE 11
11
Intranet sites are set to Compatibility View, which will emulate IE7 and omit window.location.origin .
Opera 10 Safari Yes
Yes
According to Apple's documentation , window.location.origin is supported since Safari 10 (both desktop and mobile), but the feature seems to be present in some older versions as well. Because of this, the exact versions supporting this feature cannot be determined reliably.
WebView Android Yes Chrome Android Yes Firefox Android 26
26
Before Firefox 49, results for URL using the blob scheme incorrectly returned null.
Opera Android ? Safari iOS 5 Samsung Internet Android Yes

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

见实现注意事项。

元数据

  • 最后修改:
  1. 定位
  2. 特性
    1. Location: ancestorOrigins
    2. Location: hash
    3. Location: host
    4. Location: hostname
    5. Location: href
    6. Location: origin
    7. Location: password
    8. Location: pathname
    9. Location: port
    10. Location: protocol
    11. Location: search
    12. Location: username
  3. 方法
    1. Location: assign()
    2. Location: reload()
    3. Location: replace()
    4. Location: toString()

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1