このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

DevicePosture

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

DevicePosture端末形態 API のインターフェイスで、この端末の形態、すなわちビューポートが平らなのか、折り曲げられている状態なのかを表します。

EventTarget DevicePosture

インスタンスプロパティ

親である EventTarget から継承したプロパティがあります。

type 読取専用 Experimental

この端末の現在の形態を返します。

イベント

change Experimental

端末の形態が変化したときに発生します。

js
const postureOutput = document.getElementById("currentPosture");

function reportPostureOutput() {
  // type プロパティは "continuous" または "folded" を返す
  postureOutput.textContent = `端末の形態: ${navigator.devicePosture.type}`;
}

navigator.devicePosture.addEventListener("change", reportPostureOutput);

仕様書

Specification
Device Posture API
# dom-deviceposture

ブラウザーの互換性

関連情報