Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度:如果当前浏览器是Internet Explorer,如何重定向到静态的unsupported.html页面?_Javascript_Angular_Internet Explorer_Browser - Fatal编程技术网

Javascript 角度:如果当前浏览器是Internet Explorer,如何重定向到静态的unsupported.html页面?

Javascript 角度:如果当前浏览器是Internet Explorer,如何重定向到静态的unsupported.html页面?,javascript,angular,internet-explorer,browser,Javascript,Angular,Internet Explorer,Browser,我把这段代码放在index.html中的中。这似乎适用于IE版本10以上 const isIE = /msie\s|trident/i.test(window.navigator.userAgent); if (isIE) { window.location.href = "./unsupported.html"; } 但是对于版本8和版本9,我只得到一个空白页 有没有办法让它也适用于旧的IE版本?该代码在IE 8~9中不起作用,因为const仅受IE 11支持。你可以

我把这段代码放在
index.html
中的
中。这似乎适用于IE版本10以上

const isIE = /msie\s|trident/i.test(window.navigator.userAgent);
if (isIE) {
  window.location.href = "./unsupported.html";
}
但是对于版本8和版本9,我只得到一个空白页


有没有办法让它也适用于旧的IE版本?

该代码在IE 8~9中不起作用,因为
const
仅受IE 11支持。你可以查一下电话号码

我建议您使用
var
而不是与IE 8~11兼容的
const

var isIE = /msie\s|trident/i.test(window.navigator.userAgent);
if (isIE) {
  window.location.href = "./unsupported.html";
}
测试结果: