ScreenDetails: currentScreen property
Limited availability
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.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Thuộc tính chỉ đọc currentScreen của giao diện ScreenDetails chứa một đối tượng ScreenDetailed đơn đại diện cho thông tin chi tiết về màn hình mà cửa sổ trình duyệt hiện tại đang hiển thị.
Giá trị
Một đối tượng ScreenDetailed.
Ví dụ
js
// Hàm tiện ích để mở cửa sổ mới
function openWindow(left, top, width, height, url) {
const windowFeatures = `left=${left},top=${top},width=${width},height=${height}`;
return window.open(url, "_blank", windowFeatures);
}
// Mở một cửa sổ mới lấp đầy vùng có sẵn của màn hình hiện tại.
const currentScreen = (await window.getScreenDetails()).currentScreen;
console.log(`Opening a window to fill screen ${currentScreen.label}`);
const windowRef = openWindow(
currentScreen.availLeft,
currentScreen.availTop,
currentScreen.availWidth,
currentScreen.availHeight,
url,
);
Thông số kỹ thuật
| Specification |
|---|
| Window Management> # ref-for-dom-screendetails-currentscreen> |