!--[if IE] question

liunx

Guest
I know that I can use the code <!--[if IE]> to make something load only if the user is using IE. Can I do the same for other browsers similar to the if...else statements with Javascript???<br />
<br />
Basically, if it is IE show this code, if it is anything else, whow another code??<br />
<br />
Thanks!<!--content-->There's either an "else" form or a "if not IE" form of that thing.<!--content-->could you provide the syntax? I am having trouble getting it to work. Basically I have an <iframe> and an <object>. I want the iframe to load for IE and the object for everything else.<!--content-->I don't use it but someone else here will chime in.<!--content-->There's either an "else" form or a "if not IE" form of that thing.<br />
Umm... technically there is, but it's not valid X/HTML. Those are IE5+/Win's (proprietary) Conditional Comments. No other browser supports them.<br />
<br />
About Conditional Comments (<!-- m --><a class="postlink" href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">http://msdn.microsoft.com/workshop/auth ... nt_ovw.asp</a><!-- m -->)<br />
Some more information on conditional comments can be found on this page. (<!-- m --><a class="postlink" href="http://www.positioniseverything.net/articles/multiIE.html">http://www.positioniseverything.net/art ... ltiIE.html</a><!-- m -->)<br />
QuirksMode.org : Conditional comments (<!-- m --><a class="postlink" href="http://www.quirksmode.org/css/condcom.html">http://www.quirksmode.org/css/condcom.html</a><!-- m -->)<br />
<!-- m --><a class="postlink" href="http://www.google.com/search?q=IE+conditional+comment">http://www.google.com/search?q=IE+conditional+comment</a><!-- m --><br />
<br />
Basically I have an <iframe> and an <object>. I want the iframe to load for IE and the object for everything else.<br />
Why?<!--content-->Yes you can do it - it is just a matter of having the comments start and end in the right places.<br />
<br />
<!--[if IE]><br />
Browser is Internet Explorer<br />
<![endif]><![if !IE]--><br />
Browser is NOT internet Explorer<br />
<!--[endif]--><!--content-->The following is what IE5+/Win shows when I try that. Apparently it keeps track of which tag its expecting.<br />
Browser is Internet Explorer <![if !IE]--> Browser is NOT internet Explorer <!--[endif]--> <br />
The following seems to work though, so thank you very much Felgall. :) I expect this will come in handy at some point.<br />
<!--[if IE]><br />
<p>Browser is IE5+/Win.</p><br />
<![endif]><![if !IE]>--><br />
<p>Browser is <strong>not</strong> IE5+/Win.</p><br />
<!--[endif]--><!--content-->
 
Top