I need to show text on IE only and not show it for the rest of the browsers. Any pointers to that? I looked around couldn't find it.
6 Answers
e.g.
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
(There are operators in the condition for less than, less than or equal, ... and you can chain branches to provider different behaviours for different versions see here for full details.)
Please note that since IE 10 conditional commenting are no longer supported and are treated as regular comments:
http://msdn.microsoft.com/en-us/library/ie/hh801214(v=vs.85).aspx
In order for it function as before you need to add the meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
There for, for me, if I need to detect IE (although I try to avoid browser detection and use feature detection) I use some code of JS as of here:
Detect IE version (prior to v9) in JavaScript
Best.
You have IE conditional comments or you can do it via javascript detect browser agents or with javascript frameworks such as jQuery
if (jQuery.browser.msie) {
// do something IE specific
}

- 22,634
- 36
- 132
- 182
Maybe in JS:
<script type="text/javascript">
function detectBrowser(){
var browser=navigator.appName;
if (browser=="Microsoft Internet Explorer"){
document.write("IE sux");
}
}
</script>

- 613
- 1
- 6
- 11
-
since I'm using Facebook which is pretty much a bitch so I'd have to go with the style sheet. Though this is more cooler ofcourse with the "IE sux" :D – Fahim Akhter Feb 16 '10 at 11:48
-
3Please, NO. Let's stop sniffing the User Agent already, especially since IE supports conditional comments. UA is not a reliable way to find out which browser the user is running. – Piskvor left the building Feb 16 '10 at 11:50
The examples here presume you know javascript. It would be nice to see everything you need if you only know HTML.
e.g.
gobbledegook

- 100
- 1
- 1
You need to detect if current browser is IE and show content only in this case.
The smallest script for IE detecting:
if(-[1,]) {
alert("Not IE!");
}

- 9,387
- 10
- 48
- 61
-
-
I also hope :) But I think it is an interesting script as it's being the smallest one on this moment for IE detecting. – sashaeve Feb 16 '10 at 11:50
THIS IS IE
in the conditional comments? – Fahim Akhter Feb 16 '10 at 11:49