window.screenX 和 window.screenY 不应该在移动设备的浏览器上工作吗?

Shouldn't window.screenX and window.screenY work on browsers on mobile devices?

当我在桌面 Chrome 上登录 window.screenX 时,我看到值 1920

当我在 Safari 和 Mobile 上对 phone 和 iPad 执行相同操作时,我看到 0 或一些非常奇怪的值。

来自 MDN Link:

问题

这不是应该适用于桌面和移动设备、设备和浏览器吗?

您实际上想要获取哪些信息return?来自您的 MDN link:

Returns:

A number equal to the number of CSS pixels from the left edge of the browser viewport to the left edge of the screen.

您的移动设备上的浏览器是否处于 windowed 模式?因为在全屏模式下,像大多数移动设备浏览器一样,它应该始终 return 0 因为设备屏幕左侧和浏览器开始之间没有像素 window.

您实际上是想测量屏幕左侧和浏览器视口开始之间的 space,还是您真的想获得整个屏幕的水平分辨率?如果是后者,你要找的可能就是window.screen.width属性。 属性 的文档可以在 MDN here 上找到。