/    Sign up×
Community /Pin to ProfileBookmark

!–[if IE] question

I know that I can use the code

[code=html]<!–[if IE]>[/code]

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???

Basically, if it is IE show this code, if it is anything else, whow another code??

Thanks!

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@ray326Sep 13.2006 — There's either an "else" form or a "if not IE" form of that thing.
Copy linkTweet thisAlerts:
@yodasw16authorSep 13.2006 — 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.
Copy linkTweet thisAlerts:
@ray326Sep 13.2006 — I don't use it but someone else here will chime in.
Copy linkTweet thisAlerts:
@KravvitzSep 14.2006 — There's either an "else" form or a "if not IE" form of that thing.[/QUOTE]
Umm... technically there is, but it's not valid X/HTML. Those are IE5+/Win's (proprietary) Conditional Comments. No other browser supports them.

[url=http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp]About Conditional Comments[/url]

[url=http://www.positioniseverything.net/articles/multiIE.html]Some more information on conditional comments can be found on this page.[/url]

[url=http://www.quirksmode.org/css/condcom.html]QuirksMode.org : Conditional comments[/url]

http://www.google.com/search?q=IE+conditional+comment

Basically I have an <iframe> and an <object>. I want the iframe to load for IE and the object for everything else.[/QUOTE]
Why?
Copy linkTweet thisAlerts:
@felgallSep 14.2006 — Yes you can do it - it is just a matter of having the comments start and end in the right places.

&lt;!--[if IE]&gt;
Browser is Internet Explorer
&lt;![endif]&gt;&lt;![if !IE]--&gt;
Browser is NOT internet Explorer
&lt;!--[endif]--&gt;
Copy linkTweet thisAlerts:
@KravvitzSep 14.2006 — The following is what IE5+/Win shows when I try that. Apparently it keeps track of which tag its expecting.
Browser is Internet Explorer &lt;![if !IE]--&gt; Browser is NOT internet Explorer &lt;!--[endif]--&gt;
The following seems to work though, so thank you very much Felgall. ? I expect this will come in handy at some point.
&lt;!--[if IE]&gt;
&lt;p&gt;Browser is IE5+/Win.&lt;/p&gt;
&lt;![endif]&gt;&lt;![if !IE]&gt;--&gt;
&lt;p&gt;Browser is &lt;strong&gt;not&lt;/strong&gt; IE5+/Win.&lt;/p&gt;
&lt;!--[endif]--&gt;
×

Success!

Help @yodasw16 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...