Detect IE 11 in XPages

function isIE11() {
  var isBrowserIE11 = false;
     
  if (context.getUserAgent().getBrowser() == 'Unknown') {
    var userAgent = context.getUserAgent().getUserAgent();
    if (userAgent.indexOf('Trident/7') > -1 && userAgent.indexOf('rv:11') > -1) {
      isBrowserIE11 = true;
    }
  } 
  
  return isBrowserIE11;
}





Built-in methods of the XSPUserAgent class in XPages do not recognize IE 11 (in 8.5.x or 9 so far). The isIE() method will return false. The getBrowser() method will return 'Unknown'. And so on. This snippet detects IE 11 based on the user agent string.

For the time being, this function can be used to conditionally include IE resources (via a theme or via the resource's rendered property) like this:

return context.getUserAgent().isIE() || isIE11();

More information (including Paul Hannan's feedback on the origin of the issue) can be found here: http://xcellerant.net/detecting-ie11-in-xpages/

JavaScript (Server)
Brad Balassaitis
January 9, 2014 11:21 AM
Rating
167

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



2 comment(s)Login first to comment...
jeniffer homes
(at 07:50 on 19.12.2015)
Built-in methods of the XSPUserAgent class in XPages do not recognize IE 11
Anonymous
(at 07:48 on 19.12.2015)
The isIE() method will return false. The getBrowser() method will return 'Unknown'.