Window: orientationchange イベント
orientationchange イベントは、端末の向きが変化した時に発生します。
| バブリング | なし |
|---|---|
| キャンセル | 不可 |
| インターフェイス | Event |
| イベントハンドラー | onorientationchange |
例
orientationchange イベントは addEventListener メソッドで使用することができます。
js
window.addEventListener("orientationchange", function() {
console.log("端末の向きが " + screen.orientation.angle + "になりました。");
});
または、 onorientationchange イベントハンドラープロパティを使用します。
js
window.onorientationchange = function() {
console.log("端末の向きが " + screen.orientation.angle + "になりました。");
};
仕様書
| Specification |
|---|
| Compatibility Standard # event-orientationchange |
ブラウザーの対応
BCD tables only load in the browser