(FB Instant游戏)如何获取/设置屏幕分辨率? [英] (FB Instant games) How I can get/set screen resolution?
本文介绍了(FB Instant游戏)如何获取/设置屏幕分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取/设置移动Facebook应用程序或Messenger中的即时游戏的屏幕分辨率?我尝试通过"window.screen.width"和"window.innerWidth"得到它,它返回了360个像素(但我在Chrome浏览器中有980个像素).我没有使用任何会限制分辨率的元标记.
How can I get/set screen resolution for instant games in mobile facebook app or mesenger? I tried getting that by "window.screen.width" and "window.innerWidth", it returned me 360 pixels (but i have 980 in Chrome browser). I haven’t used any meta tags which can limit the resolution.
推荐答案
您需要使用window.innerWidth
和window.innerHeight
.
您需要将它们乘以window.devicePixelRatio
.
所以:
PixelW = window.innerWidth * window.devicePixelRatio;
PixelH = window.innerHeight * window.devicePixelRatio;
这篇关于(FB Instant游戏)如何获取/设置屏幕分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文