0

I need to display a text e.g. "You are using Internet Explorer browser" within the div for all users using IE browsers (6-11). MS has dropped conditional comments as of IE10 so I'm unable to do so via css. Any advice?

Dairo
  • 822
  • 1
  • 9
  • 22

2 Answers2

1

Use navigator.userAgent:

function isIE () {
  var myNav = navigator.userAgent.toLowerCase();
  if( myNav.indexOf('msie') > -1 || myNav.indexOf('.net') > -1) {
    // do stuff;
  }
}

myNav.indexOf('.net') is needed to detect IE 11, all other versions have msie in the UA string.

(modified from code here)

Community
  • 1
  • 1
SomeKittens
  • 38,868
  • 19
  • 114
  • 143
1

use ie conditional compilation to target 10/11, which is essentially conditional comments in javascript. you can see a demo here: http://dev.bowdenweb.com/ua/browsers/ie/ie10-detection-via-cc.html

albert
  • 8,112
  • 3
  • 47
  • 63