例項屬性
繼承其父級 EventTarget 的屬性。
type只讀 實驗性-
返回裝置的當前狀態。
事件
change實驗性-
當裝置狀態發生變化時觸發。
示例
js
const postureOutput = document.getElementById("currentPosture");
function reportPostureOutput() {
// type property returns "continuous" or "folded"
postureOutput.textContent = `Device posture: ${navigator.devicePosture.type}`;
}
navigator.devicePosture.addEventListener("change", reportPostureOutput);
規範
| 規範 |
|---|
| 裝置姿態 API # dom-deviceposture |
瀏覽器相容性
載入中…
另見
- CSS
device-posture@media特性 - 裝置姿態 API
- developer.chrome.com 上的摺疊 API 來源試用 (2024)