检测 IE 的 Metro UI 版本

2023-09-29前端开发问题
4

本文介绍了检测 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 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Fatal error: Call to a member function fetch_assoc() on a no
业务场景:使用update语句去更新数据库字段。 原因:update接收值不正确。原来代码: $query = "UPDATE student SET date = now() WHERE id = $id";$result = $mysqli-query($query2) or die($mysqli-error); // 问题出现了在这句 $data = $result-fetch_ass...
2024-12-13 前端开发问题
136

js删除数组中指定元素的5种方法
在JavaScript中,我们有多种方法可以删除数组中的指定元素。以下给出了5种常见的方法并提供了相应的代码示例: 1.使用splice()方法: let array = [0, 1, 2, 3, 4, 5];let index = array.indexOf(2);if (index -1) { array.splice(index, 1);}// array = [0,...
2024-11-22 前端开发问题
182

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156

layui树状组件tree怎么默认勾选?
在layui树状组件tree中,勾选问题可以通过以下方法解决: 通过tree的oncheck事件来监听勾选操作,然后根据勾选状态进行相应的处理。例如: tree.on('check', function(obj) { // 获取勾选状态 var isChecked = obj.checked; // 获取当前节点数据 var data =...
2024-11-09 前端开发问题
372

layui中表单会自动刷新的问题
layui中表单会自动刷新的问题,因为用到layui的表单,遇到了刷新的问题所以记录一下: script layui.use(['jquery','form','layer'], function(){ var $ = layui.jquery, layer=layui.layer, form = layui.form; form.on('submit(tijiao)', function(data){ a...
2024-10-23 前端开发问题
262

JavaScript小数运算出现多位的解决办法
在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会...
2024-10-18 前端开发问题
301