Detect Metro UI Version of IE(检测 IE 的 Metro UI 版本)
问题描述
什么是最快的方法,将 User-Agent 检测为 metro internet-explorer >=10
?
What's the fastest method, to detect User-Agent as metro UI version of internet-explorer >=10
?
推荐答案
所以,似乎没有明确的测试来识别 Metro IE 与 Desktop IE,但您似乎确实有一些不同的数据可以尝试使用来假设它是 Metro.不幸的是,我发现的所有项目都无法通过其他设置来解释.换句话说,对于我发现的所有功能"测试,Desktop IE 可以配置为诱使测试认为它是在 Metro 上运行的.
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(Metro 不允许任何 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;
}
用户代理字符串检查(Metro 将始终在 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";
}
全屏检查(Metro 将始终处于全屏模式,但桌面 IE 也可以以全屏模式运行,但这可以作为 Metro 模式的支持证据)
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 以引用包含浏览器 UI(例如指示如何固定网页)的用户,请记住其他 Metro 应用程序可以将 IE10 Metro 浏览器嵌入为控件,因此即使您可以将浏览器识别为 Metro 与桌面,UI 也可能不是您试图引用它的地方,因此这最终可能是一个非常棘手的情况,要在 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 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检测 IE 的 Metro UI 版本
基础教程推荐
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01