blob: 22fb0e4db4a95e5b417ce605705678c890f18663 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
---
title: Document.onvisibilitychange
slug: Web/API/Document/onvisibilitychange
translation_of: Web/API/Document/onvisibilitychange
---
<div>{{ApiRef('DOM')}}</div>
<p><code><strong>Document.onvisibilitychange</strong></code> 是一个事件处理方法,它将在该对象的 <code><strong>visibilitychange</strong></code>事件被触发时调用。</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox"><em>obj</em>.onvisibilitychange = <em>function</em>;
</pre>
<ul>
<li><code>function</code> 是一个用户定义的方法的名字(而非带()和任何参数的函数调用),或者匿名函数的申明。</li>
</ul>
<h2 id="例子">例子</h2>
<pre class="brush: js">document.onvisibilitychange = function() {
console.log("Visibility of page has changed!");
};
</pre>
<h2 id="标准">标准</h2>
<table class="spectable standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('Page Visibility API','#onvisiblitychange-event-handler','onvisibilitychange')}}</td>
<td>{{Spec2('Page Visibility API')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.Document.onvisibilitychange")}}</p>
<h2 id="另见">另见</h2>
<ul>
<li><a href="/en-US/docs/Web/API/Page_Visibility_API">Page Visibility API</a></li>
</ul>
|