简体   繁体   English

IE8 javascript被检测为IE7

[英]IE8 javascript detected as IE7

I trying to detect ie 7 or 6 and redirect users to the error page using the javascript bellow 我试图检测到7或6,然后使用javascript波纹管将用户重定向到错误页面

 var Browser = {
        Version: function () {
            var version = 999; // we assume a sane browser
            if (navigator.appVersion.indexOf("MSIE") != -1)
            // bah, IE again, lets downgrade version number
                version = parseFloat(navigator.appVersion.split("MSIE")[1]);
            return version;
        }
    }

    if (Browser.Version() == 7 || Browser.Version() == 6) {

        if (window.location.href != "/browser_problem") {
            window.location.href = "/browser_problem";
        }
    }

I got some Feedback, that ie version 8.0.7601.17514 is redirect users to the error page like they are on ie 7 or 6. 我得到了一些反馈,即版本8.0.7601.17514将用户重定向到错误页面,就像他们位于7或6上一样。

Any idea what can be the problem? 知道可能是什么问题吗?

I assume that you got this solution from here ? 我认为您从这里得到了这个解决方案?

If you read through the comments for the chunk of code you're using (on the link above) you'll see that someone else had the same issue you're having. 如果您仔细阅读了正在使用的代码块的注释(在上面的链接上),您会发现其他人也遇到了同样的问题。

The code itself is sound (although you'll find a few people who don't feel that browser-sniffing in this fashion is good practice). 代码本身是合理的(尽管您会发现有些人不觉得以这种方式进行浏览器嗅探是一种好习惯)。

The reason Internet Explorer 8 is getting caught and redirected is either: Internet Explorer 8被捕获和重定向的原因是:

  • The user has their browser in IE7 compatibility mode (which is possible from the Tools menu, or the little browser icon in the URL bar - IE8 was intended to be intelligent enough to detect and switched to IE7 mode automatically. This is usually caused by invalid markup); 用户将其浏览器设置为IE7兼容模式(可以通过“工具”菜单或网址栏中的浏览器小图标进行操作-IE8的智能程度足以自动检测并自动切换到IE7模式。这通常是由于无效标记);
  • The website itself is forcing their browser into IE7-mode using X-UA-Compatible or similar. 该网站本身正在使用X-UA-Compatible或类似工具强制其浏览器进入IE7模式。

To get to the bottom of your issues, get hold of a copy of IE8 and try it out for yourself (you can use BrowserStack - a really good in-browser resource for cross-browser testing), if you can replicate it using IE8, make sure you're not in IE7 mode in the Tools menu. 要深入研究问题,请掌握IE8的副本并自己尝试一下(您可以使用BrowserStack-一个非常好的浏览器内资源,用于跨浏览器测试),如果可以使用IE8复制它,确保您不在“工具”菜单中的IE7模式下。

Take a look at the HTML markup on your page and ensure that you don't have an X-UA-Compatible meta-tag that looks something like this in the head: 看一下页面上的HTML标记,并确保您的头部没有类似X-UA-Compatible元标记:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Which could be changed to: 可以更改为:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM