屏幕详细信息:currentScreen 属性
currentScreen
是ScreenDetails
接口的只读属性,它包含一个ScreenDetailed
对象,该对象代表当前浏览器窗口显示在其上的屏幕的详细信息。
价值
一个ScreenDetailed
对象。
示例
js
// Utility function for opening new windows
function openWindow(left, top, width, height, url) {
const windowFeatures = `left=${left},top=${top},width=${width},height=${height}`;
return window.open(url, "_blank", windowFeatures);
}
// Open a new window that fills the available area of the current screen.
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,
);
规范
规范 |
---|
窗口管理 # ref-for-dom-screendetails-currentscreen |
浏览器兼容性
BCD 表格仅在浏览器中加载