ScreenDetailed: top 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

实验性: 这是一项实验性技术
在生产中使用此技术之前,请仔细检查浏览器兼容性表格

安全上下文: 此功能仅在安全上下文(HTTPS)中可用,且支持此功能的浏览器数量有限。

ScreenDetailed 接口中只读的 top 属性是一个数字,表示相对于 多屏幕起点,在操作系统虚拟屏幕布局中的整个屏幕区域的 y 坐标(顶部边缘)。

这等于屏幕的真实顶部边缘,忽略了绘制在屏幕顶部的任何操作系统 UI 元素。窗口无法放置在这些区域;要获取窗口可以放置的屏幕区域的顶部坐标,请使用 ScreenDetailed.availTop

注意: 在 Firefox 中,`Screen` 接口上提供了 `top` 属性的一个非标准实现。有关用法详情,请参见下面的 非标准示例,有关与非标准实现相关的浏览器支持信息,请参见 Screen 参考页面。

一个数字。

示例

窗口管理 API 示例

js
// Available in browsers that support the Window Management API
const screenDetails = await window.getScreenDetails();

// Return the absolute top value of the first screen
const screen1Top = screenDetails.screens[0].top;

非标准示例

js
// Available in Firefox
// Return the absolute top value of the current screen
const screenTop = window.screen.top;

规范

规范
窗口管理
# ref-for-dom-screendetailed-top

浏览器兼容性

另见