大网数据广告活动
Web 标准与前端开发

ScreenDetailed

· 52CE 我爱测

The **`ScreenDetailed`** interface of the Window Management API represents detailed information about one specific screen available to the user's device.

Window Management API

The ScreenDetailed interface of the Window Management API represents detailed information about one specific screen available to the user's device.

ScreenDetailed objects can be accessed via the ScreenDetails.screens and ScreenDetails.currentScreen properties.

Instance properties

Inherits properties from its parent, Screen.

  • ScreenDetailed.availLeft
    • : A number representing the x-coordinate (left-hand edge) of the available screen area.
  • ScreenDetailed.availTop
    • : A number representing the y-coordinate (top edge) of the available screen area.
  • ScreenDetailed.devicePixelRatio
    • : A number representing the screen's device pixel ratio.
  • ScreenDetailed.isInternal
    • : A boolean indicating whether the screen is internal to the device or external.
  • ScreenDetailed.isPrimary
    • : A boolean indicating whether the screen is set as the operating system (OS) primary screen or not.
  • ScreenDetailed.label
    • : A string providing a descriptive label for the screen, for example "Built-in Retina Display".
  • ScreenDetailed.left
    • : A number representing the x-coordinate (left-hand edge) of the total screen area.
  • ScreenDetailed.top
    • : A number representing the y-coordinate (top edge) of the total screen area.

Events

Inherits events from its parent, Screen.

  • change
    • : Fired on a specific screen when any property of the screen changes — width or height, available width or available height, color depth, or orientation, screen position and available screen position, device pixel ratio, label or screen's designation.

Examples

When Window.getScreenDetails() is invoked, the user will be asked for permission to manage windows on all their displays (the status of this permission can be checked using Permissions.query() to query window-management). Provided they grant permission, the resulting ScreenDetails object contains ScreenDetailed objects representing all the screens available to the user's system.

The following example opens a window in the top-left corner of the OS primary screen:

// Return ScreenDetails
const allScreens = await window.getScreenDetails();

// Return the primary screen ScreenDetailed object
const primaryScreenDetailed = allScreens.screens.find(
  (screenDetailed) => screenDetailed.isPrimary,
);

// Open a window in the top-left corner of the OS primary screen
window.open(
  "https://example.com",
  "_blank",
  `left=${primaryScreenDetailed.availLeft},
   top=${primaryScreenDetailed.availTop},
   width=200,
   height=200`,
);

[!NOTE] See Multi-window learning environment for a full example (see the source code also).

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。