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.

EventTarget DevicePosture

Thuộc tính phiên bản

Kế thừa các thuộc tính từ lớp cha EventTarget.

type Read only Thử nghiệm

Trả về tư thế hiện tại của thiết bị.

Sự kiện

change Thử 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