1

Right now, I'm doing this:

if (Function('/*@cc_on return document.documentMode===10@*/ ')()) { 
  // do stuff
}

But this only targets IE10. How to do it so I target IE10 and below? (Using the same pure JavaScript method?)

alex
  • 7,111
  • 15
  • 50
  • 77
  • I think you can check with [`document.documentMode`](https://msdn.microsoft.com/en-us/library/cc196988(v=vs.85).aspx) down to IE 8. Although I'm not sure how to check for specific IE versions below that. – Spencer Wieczorek Jun 24 '16 at 03:36

1 Answers1

1

You can always parse UserAgent string like the old times. Here are many examples that show you how.

function isIE () {
  var myNav = navigator.userAgent.toLowerCase();
  return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}

if (isIE () && isIE () < 9) {
 // is IE version less than 9
} else {
 // is IE 9 and later or not IE
}
Community
  • 1
  • 1
Uzbekjon
  • 11,655
  • 3
  • 37
  • 54