screen.width 和 screen.height 的可靠性如何?

发布于 2024-12-26 05:16:07 字数 146 浏览 2 评论 0原文

我想制作一个具有“响应式设计”的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小伙你站住 2025-01-02 05:16:07

是的,screen.widthscreen.height 是可靠的,但是您可能对用于布局页面的窗口的大小更感兴趣。例如,CSS3 中的 @media 查询使用窗口大小,而不是屏幕大小。

Yes, screen.width and screen.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文