2014. július 16., szerda

JIRA - Internet Explorer 11 feels itself Mozilla :-)

In IE11

jQuery.browser.mozilla returns true
jQuery.browser.msie returns undefined
jQuery.browser.safari returns undefined

You can read more about it here.



Solution instead of using the above:

Query the user agent string by using window.navigator.userAgent which is
  • in Mozilla: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0,
  • in Chrome: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36,
  • in IE11: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko,
and find for the following strings:
  • in Mozilla - "Firefox",
  • in Chrome - "Chrome",
  • in IE11 - "Trident".
Note: you can search for "Trident" to identify Internet Explorer since IE9.

For example:
var ua = window.navigator.userAgent;
console.log(ua);
var msie = ua.indexOf("Trident"); // -1 if not found
console.log(msie);

Hurrah for IE11 again! ;-)

Nincsenek megjegyzések:

Megjegyzés küldése