DevicePosture
Khả dụng hạn chế
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Giao diện DevicePosture của Device Posture API đại diện cho tư thế của thiết bị, tức là liệu khung nhìn có ở trạng thái phẳng hay gập hay không.
Thuộc tính phiên bản
Kế thừa các thuộc tính từ lớp cha EventTarget.
typeRead only Thử nghiệm-
Trả về tư thế hiện tại của thiết bị.
Sự kiện
changeThử nghiệm-
Kích hoạt khi tư thế của thiết bị thay đổi.
Ví dụ
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);
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Device Posture API> # dom-deviceposture> |
Tương thích trình duyệt
Xem thêm
- CSS
device-posture@mediafeature - Device Posture API
- Origin trial for Foldable APIs on developer.chrome.com (2024)