aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/globaleventhandlers/onresize/index.html
blob: 4afad82e58f379487a6f1190db225ddb8d4a9a18 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
title: window.onresize
slug: Web/API/GlobalEventHandlers/onresize
translation_of: Web/API/GlobalEventHandlers/onresize
---
<p>{{ ApiRef() }}</p>

<h3 id="Summary" name="Summary">概述</h3>

<p><code>onresize</code>属性可以用来获取或设置当前窗口的resize事件的事件处理函数</p>

<h3 id="Syntax" name="Syntax">语法</h3>

<pre class="eval">window.onresize = <em>funcRef</em>;
</pre>

<h3 id="Parameters" name="Parameters">参数</h3>

<ul>
 <li><code>funcRef</code> 是一个函数引用</li>
</ul>

<h3 id="Example" name="Example">例子</h3>

<pre>window.onresize = doFunc;
</pre>

<pre>&lt;html&gt;
&lt;head&gt;

&lt;title&gt;onresize测试&lt;/title&gt;

&lt;script type="text/javascript"&gt;

window.onresize = resize;

function resize()
{
 alert("检测到resize事件!");
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;p&gt;改变浏览器窗口的大小来触发resize事件.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>

<h3 id="Notes" name="Notes">备注</h3>

<p>在窗口大小改变之后,就会触发resize事件.</p>

<h3 id="Specification" name="Specification">规范</h3>

<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('HTML WHATWG','webappapis.html#handler-onresize','onresize')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<p>{{ languages( {"en": "en/DOM/window.onresize" } ) }}</p>