【发布时间】:2014-03-24 08:58:44
【问题描述】:
我正在尝试为需要全屏分辨率的 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 html css windows-phone-8 internet-explorer-10