Navigator:devicePosture 屬性
Navigator.devicePosture 只讀屬性返回瀏覽器的 DevicePosture 物件,該物件允許開發者查詢裝置的當前姿態(即視口是否處於展開或摺疊狀態)並響應姿態變化來執行程式碼。
值
一個 DevicePosture 物件。
示例
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-navigator-deviceposture |
瀏覽器相容性
載入中…
另見
DevicePosturedevicePosture.type- 裝置姿態 API
- CSS
device-posture@media特性