强制Internet Explorer在Edge中打开网站

问题描述

我刚刚在Internet Explorer中访问了apple.com网站,并注意到Internet Explorer直接在Edge中打开该网站,并在IE窗口中直接打开shows this page

我也想在我的网站上实现此功能,因此我不必优化IE的所有功能。您有什么想法,这怎么可能?

我找到了此代码段,但它不起作用:<meta http-equiv="X-UA-Compatible" content="IE=edge">

解决方法

在您的网站开始时运行以下代码:

if (isIE()) {
  // We open the website in Chrome if it's IE,note that ActiveXObject only works on IE
  var shell = new ActiveXObject("WScript.Shell");
  shell.run("Chrome https://google.com");
}

function isIE() {
  ua = navigator.userAgent;
  // MSIE used to detect old browsers and Trident used to newer ones
  var is_ie = ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
  return is_ie;
}

这是一个hack,但是如果用户在浏览器中启用了活动的X,它应该可以工作。如果没有,他将提示您启用它。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...