我正在尝试为需要全屏分辨率的 Windows Phone 8 制作网络应用
好像没办法发现这个
使用:<meta name="viewport" content="width=device-width, user-scalable=no" />
这将永远是 320
使用 javascript screen.width
返回 320
使用 javascript screen.availWidth
返回 320
我整理了一些目前看来可以使用的代码:
JavaScript:
window.devicePixelRatio = window.devicePixelRatio || screen.deviceXDPI / screen.logicalXDPI;
var actualWidth = screen.width * window.devicePixelRatio;
actualWidth = actualWidth - (actualWidth % 2);
var actualHeight = screen.height * window.devicePixelRatio;
actualHeight = actualHeight - (actualHeight % 2);
// TEMP FIX!
if(actualHeight == 1282){
actualHeight = 1280;
}
$(window).bind('resize', function() {
if(window.innerHeight > window.innerWidth){
// portrait
width = actualWidth;
height = window.innerHeight;
}else{
// landscape
width = actualHeight;
height = window.innerHeight;
}
$('html').css('width', width);
$('body').css('width', width);
}).trigger('resize');
CSS:
@media screen and (orientation:portrait) {
@-ms-viewport { width: 720px; }
}
@media screen and (orientation:landscape) {
@-ms-viewport { width: 1280px; }
}
有没有更好的方法来找到 Windows Phone 8 上的真实屏幕分辨率?
任何关于此问题的帮助/建议将不胜感激,谢谢!
最佳答案
使用 javascript,这段代码可以在任何设备上运行:
var width = window.innerWidth;
var height = window.innerHeight;
关于javascript - 在 Windows Phone 8 上的 IE10 中查找屏幕分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21958258/