您可以使用 JavaScript 检测 -moz-device-pixel-ratio 和 -o-device-pixel-ratio 的当前值吗?
WebKit 引入了 -webkit-device-pixel-ratio
媒体功能和 window.devicePixelRatio
JavaScript 属性,以允许 Web 作者检测其页面是否在 iPhone 上呈现视网膜显示屏:
- https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariCSSRef/Articles/OtherStandardCSS3Features.html#//apple_ref/doc/uid/TP40007601-SW3
- http://www.robertprice.co.uk/robblog/archive/ 2011/5/Detecting_Retina_Displays_From_JavaScript_And_CSS.shtml
Mozilla 和 Opera 引入了等效媒体功能,-moz-device-pixel-ratio
和 -o-device-pixel-ratio
。然而,他们似乎没有引入 JavaScript 属性来配合它们。
有没有办法通过 Firefox 和 Opera 中的 JavaScript 检测设备像素比?
WebKit introduced the -webkit-device-pixel-ratio
media feature and window.devicePixelRatio
JavaScript property, to allow web authors to detect whether their page was being rendered on an iPhone with a retina display:
- https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariCSSRef/Articles/OtherStandardCSS3Features.html#//apple_ref/doc/uid/TP40007601-SW3
- http://www.robertprice.co.uk/robblog/archive/2011/5/Detecting_Retina_Displays_From_JavaScript_And_CSS.shtml
Mozilla and Opera have introduced equivalent media features, -moz-device-pixel-ratio
and -o-device-pixel-ratio
. However, they don’t seem to have introduced the JavaScript property to go along with them.
Is there any way to detect the device pixel ratio via JavaScript in Firefox and Opera?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 https://developer.mozilla.org/en/DOM 从 JS 测试媒体功能/window.matchMedia
You can test media features from JS using https://developer.mozilla.org/en/DOM/window.matchMedia