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?
Asked
Active
Viewed 131 times
0
-
1Why? IE 10 and 11 are pretty much comparable with other browsers, and versions 6 - 9 can be targeted with conditional comments. – David Thomas Mar 25 '14 at 00:31
-
You could do it the old-fashioned way...check `navigator.userAgent` – Matt Browne Mar 25 '14 at 00:32
-
@David Thomas For some unknown reasons IE11 is not uploading attachments via php upload. It's working fine with Chrome and Firefox, but not with IE so I thought it's gonna be quicker for me just to put a warning message for IE users :) – user3426374 Mar 25 '14 at 00:35
-
1Quicker for you, kind-of disappointing for your IE users. – Pointy Mar 25 '14 at 00:42
-
@Pointy Could be just a temporary fix while he digs out the cause of the problem. – SomeKittens Mar 25 '14 at 00:43
-
I think it'd be better, long-term, to find out why it's not working, rather than force your users to switch browsers. – David Thomas Mar 25 '14 at 00:45
-
@DavidThomas IE10 and 11 are NOT comparable to other browsers and are still the worst on the planet. – Rob Mar 25 '14 at 00:50
-
Feature testing for the particular capabilities you need is a much better alternative. – Jeremy J Starcher Mar 25 '14 at 02:03
2 Answers
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