WakeLockSentinel: type property
Baseline
2025
Newly available
Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Thuộc tính chỉ đọc type của giao diện WakeLockSentinel trả về biểu diễn chuỗi của loại WakeLockSentinel hiện đang được giữ.
Giá trị
Biểu diễn chuỗi của loại khóa thức hiện đang được giữ. Hiện tại, giá trị luôn là screen, biểu diễn khóa thức màn hình. Nó ngăn thiết bị làm mờ hoặc khóa màn hình.
Ví dụ
Ví dụ này cho thấy một hàm bất đồng bộ thu nhận WakeLockSentinel, sau đó ghi loại vào console.
js
const requestWakeLock = async () => {
wakeLock = await navigator.wakeLock.request("screen");
console.log(wakeLock.type); // logs 'screen'
};
requestWakeLock();
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Screen Wake Lock API> # the-type-attribute> |