IE浏览器11本身的识别类似于Mozilla [英] IE 11 browser recognizes itself as Mozilla

查看:223
本文介绍了IE浏览器11本身的识别类似于Mozilla的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的MVC应用程序,.NET 4.5框架,VS 2010。
我有一段JavaScript代码code标识应用程序正在运行的浏览器。如果浏览器是火狐然后code的特定块将如果没有另一个块code将被执行处决。
  随着IE 11我有一个奇怪的问题。
  浏览器(如11)承认自己为Mozilla的。

I am working on MVC application, .net 4.5 framework, VS 2010. I have a piece of Javascript code that identifies which browser the application is running. If the browser is Firefox then a particular block of code will be executed if not another block code will get executed. With IE 11 I am having a weird problem. The browser (ie 11) recognizes itself as Mozilla.

的javascrip code:

javascrip code :

 if ($.browser.mozilla) {
      if (location.pathname == "/Stats/Reports") {            // This is for local env.
      $("#prntCss").attr("href", "../../../Content/SitePrint_FF.css");
            }
            else {                                                 
      $("#prntCss").attr("href", "../../Content/SitePrint_FF.css");
      $("#rptPrntCss").attr("href", "../../Content/reportPrintStyles_FF.css");
            }

推荐答案

是的。 IE 11犯规说,这是IE浏览器了,它说,这是Mozilla浏览器。

Yes. IE 11 doesnt say it is IE anymore, it says it is Mozilla.

Althoug,所有IE版本中的所有版本的响应字三叉戟(它的布局引擎)。

Althoug, all IE versions respond the word Trident (its layout engine) in all of its versions.

所以,这样的事情可能会在你的JavaScript工作

So something like this could work in your javascript

<script type="text/javascript">
    CheckIE();
    function CheckIE()
    {
    var Browser;
    Browser = navigator.userAgent;
    if (Browser.indexOf("Trident") == -1)
    {
        //WHATHEVER YOU WANT IF IT IS NOT INTERNET EXPLORER
    }
    }
</script>

这篇关于IE浏览器11本身的识别类似于Mozilla的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆