--- title: 'Window: orientationchange イベント' slug: Web/API/Window/orientationchange_event tags: - API - Event - Reference - Sensors - Window - onorientationchange - イベント translation_of: Web/API/Window/orientationchange_event ---
orientationchange イベントは、端末の向きが変化した時に発生します。
| バブリング | なし |
|---|---|
| キャンセル | 不可 |
| インターフェイス | {{domxref("Event")}} |
| イベントハンドラー | {{domxref("Window/onorientationchange", "onorientationchange")}} |
orientationchange イベントは {{domxref("EventTarget/addEventListener", "addEventListener")}} メソッドで使用することができます。
window.addEventListener("orientationchange", function() {
console.log("端末の向きが " + screen.orientation.angle + "になりました。");
});
または、 {{domxref("Window/onorientationchange", "onorientationchange")}} イベントハンドラープロパティを使用します。
window.onorientationchange = function() {
console.log("端末の向きが " + screen.orientation.angle + "になりました。");
};
| Specification | Status |
|---|---|
| {{SpecName('Compat', '#event-orientationchange', 'orientationchange')}} | {{Spec2('Compat')}} |
{{Compat("api.Window.orientationchange_event")}}