【问题标题】:Finding screen resolution in IE10 on Windows Phone 8在 Windows Phone 8 上的 IE10 中查找屏幕分辨率
【发布时间】: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


    【解决方案1】:

    使用 javascript,此代码适用于任何设备:

    var width = window.innerWidth;
    var height = window.innerHeight;
    

    【讨论】:

    • 感谢您的回复,不幸的是,这不是答案 在 HTC 8X (720x1280) 上:如果我将它与视口一起使用,则会得到 320x521 如果我在没有视口的情况下使用它,则会得到 1024x1667
    • 哦,好的。谢谢你告诉我。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-31
    • 2011-02-02
    相关资源
    最近更新 更多