diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/window/closed | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/window/closed')
-rw-r--r-- | files/zh-cn/web/api/window/closed/index.html | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/window/closed/index.html b/files/zh-cn/web/api/window/closed/index.html new file mode 100644 index 0000000000..084eeaa92e --- /dev/null +++ b/files/zh-cn/web/api/window/closed/index.html @@ -0,0 +1,59 @@ +--- +title: Window.closed +slug: Web/API/Window/closed +translation_of: Web/API/Window/closed +--- +<div>{{APIRef}}</div> + +<h2 id="概述">概述</h2> + +<p>此只读属性表示所引用的窗口是否关闭。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><var>isClosed</var> = <var>windowRef</var>.closed; +</pre> + +<dl> + <dt><code>isClosed</code></dt> + <dd>一个布尔值。 可能的值: + <ul> + <li><code>true</code>: 窗口已被关闭。</li> + <li><code>false</code>: 窗口是打开的。</li> + </ul> + </dd> +</dl> + +<h2 id="示例">示例</h2> + +<h3 id="更改一个弹出窗口的URL">更改一个弹出窗口的URL</h3> + +<p>下面的示例演示怎样更改一个已打开的弹出窗口的URL。尝试更改URL之前,它使用window.opener属性来检查有窗口被打开,并且该窗口没有关闭:</p> + +<pre class="brush:js">// Check that an opener exists and is not closed +if (window.opener && !window.opener.closed) { + window.opener.location.href = "http://www.mozilla.org"; +}</pre> + +<p>请注意,弹出窗口只能访问打开他们的窗口。</p> + +<h3 id="刷新先前打开的弹出窗口">刷新先前打开的弹出窗口</h3> + +<p>在这个例子中,函数refreshPopupWindow()调用重载方法的弹出的位置要刷新其数据的对象。如果弹出窗口尚未打开,或者用户已关闭它打开一个新窗口。</p> + +<pre class="brush:js">var popupWindow = null; + +function refreshPopupWindow() { + if (popupWindow && !popupWindow.closed) { + // popupWindow is open, refresh it + popupWindow.location.reload(true); + } else { + // Open a new popup window + popupWindow = window.open("popup.html","dataWindow"); + } +} +</pre> + +<h2 id="技术说明">技术说明</h2> + +<p>HTML5</p> |