screen.width 和 screen.height 的可靠性如何?
我想制作一个具有“响应式设计”的 Web 应用程序,将 JavaScript 屏幕分辨率发回服务器并根据该信息做出决策,但问题是我是否可以依靠 window.screen 始终提供正确的笔记本电脑,平板电脑、智能手机信息?
当然,考虑到它仅支持现代浏览器和设备。
I would like to make a web application with a "responsive design" to post back to the server the JavaScript screen resolution and make decisions based on that information, but the question is can I rely on window.screen to always supply the correct laptop, tablet, smartphone information?
And of course taking into consideration that it support only modern browsers and devices.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,
screen.width
和screen.height
是可靠的,但是您可能对用于布局页面的窗口的大小更感兴趣。例如,CSS3 中的@media
查询使用窗口大小,而不是屏幕大小。Yes,
screen.width
andscreen.height
are reliable, however you probably would be more interested in the size of the window for laying out your pages. For instance,@media
queries in CSS3 use the window size, not the screen size.