检测IE的Metro UI的版本 [英] Detect Metro UI Version of IE

查看:145
本文介绍了检测IE的Metro UI的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最快的方法,来检测用户代理作为地铁的问题 UI版本title=\"show问题标记'internet-explorer'\" rel=\"tag\">互联网探险家 > = 10

What's the fastest method, to detect User-Agent as metro UI version of internet-explorer >=10 ?

推荐答案

所以,似乎没有成为一个明确的测试,以确定地铁IE VS桌面IE浏览器,但似乎是几个不同的数据块你可以尝试使用假定它是地铁。不幸的是,没有我发现的物品不能被其他设置解释程。换句话说,因为我发现所有的功能的测试中,IE浏览器的桌面可以在某种程度上欺骗测试,以为它是在地铁运行的配置。

So, there doesn't appear to be a definitive test to identify Metro IE vs Desktop IE, but there does seem to be a few different pieces of data you can attempt to use to assume that it is Metro. Unfortunately, none of the items I have found can't be explained away by other settings. In other words, for all the "feature" tests I have found, Desktop IE could be configured in a way to trick the tests into thinking it was running on Metro.

时的ActiveX禁用(地铁不允许任何ActiveX内容,但桌面IE可以把它设置为禁用以及):

Is ActiveX disabled (Metro doesn't allow any activex content, but desktop IE can have it set to disabled as well):

function isActivexEnabled() {
    var supported = null;        
    try {
        supported = !!new ActiveXObject("htmlfile");
    } catch (e) {
        supported = false;
    }

    return supported;
}

用户代理字符串检查(新城将始终处于64位模式下运行,但不会在32位机器上,和桌面IE浏览器可配置为64位中的模式下运行,以及不知道如何受欢迎要么这些选项会)

User Agent string check (Metro will always run in 64bit mode, but won't on a 32bit machine, and Desktop IE can be configured to run in 64bit mode as well not sure how popular either of those options will be)

function isWin64() {
    return navigator.platform == "Win64";
}

全屏检查(新城将始终处于全屏模式,但是桌面IE也可以在全屏模式下运行,但是这可能被用来作为地铁模式支持证据)

Full screen check (Metro will always be in full screen mode, however Desktop IE can also run in full screen mode, but this could be used as supporting evidence of Metro mode)

function isFullScreen() {
   return (window.innerWidth == screen.width && 
           window.innerHeight == screen.height);
}

总之,我认为你必须尝试检查了一堆功能,然后猜测,目前还没有确切的方法。或者你可以只接受MS不希望你这样做,并使用功能检测要使用的功能。

In short, I think you have to try to check a bunch of features, and then guess, there is no definitive way. Or you could just accept that MS doesn't want you to do this, and use feature detection for the features you want to use.

对于那些想尝试提供的UI来指包含浏览器的用户界面(指示如何针脚例如网页),请记住,其他的地铁应用程序可以嵌入IE10新城浏览器作为控制,使即使你可以找出浏览器作为新城VS桌面,用户界面​​可能不会在那里你会尝试引用它,所以这可能最终会被pretty棘手的局面得到的时间正确的100%。因此,要么,不要尝试,或者你可以尝试其他的检测技术和接受,有一些你可能会显示错误的UI的用例。

For those that want to try to provide UI to refer to the containing browser UI (to indicate how to Pin the web page for example), keep in mind that other Metro apps can embed the IE10 Metro browser as a control, so even if you could identify the browser as Metro vs desktop, the UI might not be where you'd attempt to refer to it, so this can end up being a pretty tricky situation to get right 100% of the time. So either, don't try, or you could attempt the other detection techniques and accept that there are use cases that you could be displaying the wrong UI.

这篇关于检测IE的Metro UI的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆