gpt4 book ai didi

javascript - screen.width 在 Firefox 和 Chrome 上产生不同的结果

转载 作者:行者123 更新时间:2023-12-03 05:19:22 25 4
gpt4 key购买 nike

我正在与一个网站合作,我知道屏幕的宽度,这就是为什么我尝试使用 screen.width 但我不知道为什么我在 Firefox 和 Firefox 上得到不同的结果 Chrome 。 Firefox 似乎向我显示了正确的值,但 Chrome 却没有。

有谁可以帮我看看是什么原因吗?

谢谢

最佳答案

原因是当前没有标准来定义该值应该是什么。最接近的是CSSOM View Module ,其中指出:

The width attribute must return the width of the output device, in CSS pixels.

但是,该规范是一个工作草案,这意味着它是一项正在进行的工作,并且所规定的定义可能并非已实现的定义。事实上,Editor's Draft给出了两个不同的定义:

The Web-exposed screen area is one of the following:

  • The area of the output device, in CSS pixels.
  • The area of the viewport, in CSS pixels.

很明显,浏览器 vendor 正在采用他们想要的任何定义。

有关该属性的更多讨论,请参阅 PPK's rant "screen.width is useless" on Quirks Mode

关于javascript - screen.width 在 Firefox 和 Chrome 上产生不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41461788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com