javascript - 如何将 Internet Explorer 用户重定向到新页面?

标签 javascript html css internet-explorer redirect

我试过使用下面的脚本

[if IE]
<script type="text/javascript">
window.location = "error.html";
</script>
[endif]

除了 Chrome 等其他浏览器也重定向到 error.html 页面这一事实之外,它的工作原理就像一种享受。它有什么问题?谢谢

最佳答案

试试这个:

<script type="text/javascript">
if(navigator.appName.indexOf("Internet Explorer")!=-1 || navigator.userAgent.match(/Trident.*rv[ :]*11\./))
{
   //This user uses Internet Explorer
   window.location = "error.html";
}
</script>

来自维也纳的问候

关于javascript - 如何将 Internet Explorer 用户重定向到新页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26238086/

相关文章:

html - 在 HTML 标签样式中“{...}{ :active . .. } 不起作用?

html - 水平列表显示在行中

html - 如何使用 CSS3 自动在屏幕上显示一个巨大的图像?

c# - 将 json 字符串作为参数传递给 webmethod

javascript - 如何使用适用于 Android 的 Phonegap SoftKeyboard 插件?

javascript - 倒计时到多个时刻,如何?

html - 如何在达到页面边框时水平对齐 div 而不让它们倒下?

javascript - ajax POST 不发送对象的一部分

html - 在没有 HTML 表格的情况下,如何在同一行上放置两个 DIV,一个左对齐,一个右对齐?

css - Angular 、背景图像和背景位置