DevicePosture: type プロパティ
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
type は DevicePosture インターフェイスの読み取り専用プロパティで、端末の現在の形態を返します。
値
この端末の現在の形態を表す文字列です。以下のどちらかの値です。
continuous-
平らな画面の形態を示します。これには、平らな状態で使用中の折り曲げ式端末、継ぎ目のない曲面ディスプレイ、または標準的なデスクトップ、ノートパソコン、タブレット、モバイル端末の画面を含みます。
folded-
折り曲げられた画面の形態を示します。これはブック型またはノートパソコンの形態折り曲げ可能な端末を含みます。
例
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-type> |
ブラウザーの互換性
関連情報
- CSS
device-posture@media特性 - 端末形態 API
- Origin trial for Foldable APIs - developer.chrome.com (2024)