Navigator: devicePosture プロパティ
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
Navigator.devicePosture は読み取り専用のプロパティで、ブラウザーの DevicePosture オブジェクトを返します。これにより、開発者は端末の現在の形態(つまり、ビューポートの状態が平らか折り曲げられているか)を問い合わせ、形態の変化に応じてコードを実行することができるようになります。
値
DevicePosture オブジェクトです。
例
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-navigator-deviceposture> |
ブラウザーの互換性
関連情報
DevicePosturedevicePosture.type- 端末形態 API
- CSS
device-posture@media特性