blob: 5271657093b80e86f897a9071832f84d7c3092b6 (
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
|
---
title: 'Window: orientationchange event'
slug: Web/API/Window/orientationchange_event
tags:
- Sensors
translation_of: Web/API/Window/orientationchange_event
---
<div>{{APIRef}}</div>
<p><code>orientationchange</code> 事件在設備方向改變時被觸發。</p>
<table class="properties">
<tbody>
<tr>
<th scope="row">冒泡</th>
<td>No</td>
</tr>
<tr>
<th scope="row">可取消</th>
<td>No</td>
</tr>
<tr>
<th scope="row">介面</th>
<td>{{domxref("Event")}}</td>
</tr>
<tr>
<th scope="row">事件處理器</th>
<td><code><a href="/zh-TW/docs/Web/API/Window/onorientationchange">onorientationchange</a></code></td>
</tr>
</tbody>
</table>
<h2 id="範例">範例</h2>
<p>可於 <code><a href="/zh-TW/docs/Web/API/EventTarget/addEventListener">addEventListener</a></code> 方法中使用 <code>abort</code> 事件:</p>
<pre class="brush:js;">window.addEventListener("orientationchange", function() {
console.log("the orientation of the device is now " + screen.orientation.angle);
});
</pre>
<p>或使用 <code><a href="/zh-TW/docs/Web/API/Window/onorientationchange">onorientationchange</a></code> 事件處理器屬性:</p>
<pre class="brush: js">window.onorientationchange = function() {
console.log("the orientation of the device is now " + screen.orientation.angle);
};</pre>
<h2 id="規範">規範</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
</tr>
<tr>
<td>{{SpecName('Compat', '#event-orientationchange', 'orientationchange')}}</td>
<td>{{Spec2('Compat')}}</td>
</tr>
</tbody>
</table>
<h2 id="瀏覽器相容性">瀏覽器相容性</h2>
<p>{{Compat("api.Window.orientationchange_event")}}</p>
|