IE 11 browser recognizes itself as Mozilla

BumbleBee picture BumbleBee · Jan 3, 2014 · Viewed 14.2k times · Source

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 :

 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");
            }

enter image description here

Answer

Ricardo Polo Jaramillo picture Ricardo Polo Jaramillo · Jan 3, 2014

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

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

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>