Dojo 1.6.x unable to detect IE11 browser version details

For IE11, Microsoft changed their browser's version identification. Now the navigator.useragent inspects the value as:

"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"

This leads to an older version of Dojo (I've seen this issue with Dojo 1.6.x) to return dojo.isIE as undefined. Dojo 1.9.3 does have support for IE 11, but we can still tweak for older Dojo versions of dojo to atleast detect the browser version for IE 11. Below is the javascript trick:

if( !dojo.isIE )
      var userAgent = navigator.userAgent.toLowerCase();
      var IEReg = /(msie\s|trident.*rv:)([\w.]+)/;
      var match = IEReg.exec(userAgent);
      if( match )
          dojo.isIE = match[2] - 0;
          dojo.isIE = undefined;

The above dojo code will now detect browser version as 11 for IE 11.


Post a Comment