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/window/opener/index.html | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 files/zh-cn/web/api/window/opener/index.html (limited to 'files/zh-cn/web/api/window/opener') diff --git a/files/zh-cn/web/api/window/opener/index.html b/files/zh-cn/web/api/window/opener/index.html new file mode 100644 index 0000000000..52317273f7 --- /dev/null +++ b/files/zh-cn/web/api/window/opener/index.html @@ -0,0 +1,38 @@ +--- +title: window.opener +slug: Web/API/Window/opener +translation_of: Web/API/Window/opener +--- +

{{ ApiRef() }}

+ +

概述

+ +

返回打开当前窗口的那个窗口的引用,例如:在window A中打开了window B,B.opener 返回 A.

+ +

语法

+ +
var objRef = window.opener;
+
+ +

例子

+ +
 if (window.opener != indexWin) {
+     referToTop(window.opener);
+ }
+
+ +

备注

+ +

如果当前窗口是由另一个窗口打开的, window.opener保留了那个窗口的引用. 如果当前窗口不是由其他窗口打开的, 则该属性返回 null.

+ +

规范

+ +

{{ DOM0() }}

+ +

{{ languages( { "fr": "fr/DOM/window.opener", "ja": "ja/DOM/window.opener", "pl": "pl/DOM/window.opener", "en": "en/DOM/window.opener" } ) }}

+ +

浏览器兼容性

+ +

{{Compat("api.Window.opener")}}

+ +

注意:在Chrome78最近的几个版本,如果A、B页面跨域,A页面中打开B页面,在B页面使用console.log在控制台打印window.opener会报跨域的错误。

-- cgit v1.2.3-54-g00ecf