DOM

Window:deviceorientation イベント

 編集:2022.10.18 by T.A.

[Edge]。→

mdn: 端末の現在の向きを地球座標フレームと比較した場合に、方角センサーから最新のデータが得られた場合に発生します。このデータは端末内部の磁力計から収集されます。詳細については、向きと動きのデータの説明を参照してください。

バブリング なし
キャンセル可能 いいえ
インターフェイス DeviceOrientationEvent
イベント ハンドラー プロパティ ondeviceorientation
deviceorientation イベント

HTML:

<SPAN id=IdLog></SPAN><BR>
<SPAN id=IdInd></SPAN>

JavaScript:

function Job(eve){  //deviceorientation イベントの処理:
  D=eve;  //=[object]:[object DeviceOrientationEvent]。最初に得られたデータ。
詳細 //isTrusted=[boolean]:true //alpha=[object]:null //beta=[object]:null //gamma=[object]:null //absolute=[boolean]:false //type=[string]:deviceorientation //target=[object]:[object Window] //currentTarget=[object]:[object Window] //eventPhase=[number]:0 //bubbles=[boolean]:false //cancelable=[boolean]:false //defaultPrevented=[boolean]:false //composed=[boolean]:false //…
IdLog.innerHTML="alpha:"+eve.alpha+"<BR>" +"gamma:"+eve.gamma+"<BR>" +"beta:"+eve.beta; IdInd.innerHTML=IdInd.innerHTML+"●"; } window.ondeviceorientation=Job; //イベント割り当て。


テスト