HTMLHyperlinkElementUtils.origin

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

io error: No such file or directory (os error 2) (/home/runner/work/yari/yari/mdn/translated-content/files/zh-cn/web/api/htmlanchorelement/index.md)

HTMLHyperlinkElementUtils.origin 只读属性是一个 USVString ,其中包含代表 URL 的原始码的 Unicode 序列化,即:

  • 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 file: 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 Worker 中可用。

Syntax

string = object.origin;

Examples

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

Specifications

Specification
HTML Standard
# dom-hyperlink-origin-dev

Browser compatibility

BCD tables only load in the browser

See also