From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/document/referrer/index.html | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 files/zh-cn/web/api/document/referrer/index.html (limited to 'files/zh-cn/web/api/document/referrer') diff --git a/files/zh-cn/web/api/document/referrer/index.html b/files/zh-cn/web/api/document/referrer/index.html new file mode 100644 index 0000000000..281b9dabdf --- /dev/null +++ b/files/zh-cn/web/api/document/referrer/index.html @@ -0,0 +1,38 @@ +--- +title: document.referrer +slug: Web/API/Document/referrer +tags: + - API + - Document + - 参考 + - 属性 +translation_of: Web/API/Document/referrer +--- +
{{APIRef("DOM")}}
+ +

Document.referrer 返回的是一个 URI, 当前页面就是从这个 URI 所代表的页面 跳转或打开的.

+ + + +

语法

+ +
var referrer = document.referrer;
+
+ +

+ +

如果用户直接打开了这个页面(不是通过页面跳转,而是通过地址栏或者书签等打开的),则该属性为空字符串。由于该属性只是返回一个字符串,所以不能够通过该属性引用页面的 DOM。

+ +

在{{HTMLElement("iframe")}}中,Document.referrer 会初始化为父窗口{{domxref("Window/location", "Window.location")}}的{{domxref("HTMLHyperlinkElementUtils/href", "href")}}。

+ +

规范

+ + + +

浏览器兼容性

+ + + +
{{Compat("api.Document.referrer")}}
-- cgit v1.2.3-54-g00ecf