We help IT Professionals succeed at work.

Conditional comments

jeremyBass26
jeremyBass26 asked
on
963 Views
Last Modified: 2012-08-13
Hello, I'm looking for a complete list of these... but more to the point i need to know what this conditional comment would be:

if IE 7 and !IE

I think I'd be made up of:
<!--[if IE]><![if !IE]><![endif]-->
For FF and all non-MSIE
<!--[if IE]><![endif]><![endif]-->

<!--[if  IE 7]>
IE 7 only
<![endif]-->

how would you combine them?






the list as of yet:
<p><!--[if IE]>
According to the conditional comment this is Internet Explorer<br />
<![endif]-->
<!--[if IE 5]>
According to the conditional comment this is Internet Explorer 5<br />
<![endif]-->
<!--[if IE 5.0]>
According to the conditional comment this is Internet Explorer 5.0<br />
<![endif]-->
<!--[if IE 5.5]>
According to the conditional comment this is Internet Explorer 5.5<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is Internet Explorer 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is Internet Explorer 7<br />
<![endif]-->
<!--[if gte IE 5]>
According to the conditional comment this is Internet Explorer 5 and up<br />
<![endif]-->
<!--[if lt IE 6]>
According to the conditional comment this is Internet Explorer lower than 6<br />
<![endif]-->
<!--[if lte IE 5.5]>
According to the conditional comment this is Internet Explorer lower or equal to 5.5<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is Internet Explorer greater than 6<br />
<![endif]-->
</p>
Comment
Watch Question

Jagadeesh MBig Data and Splunk Architect

Commented:
You can also use AND ( & ) , OR ( | ), sub-expression and NOT ( ! ) operators as shown below -


[if (IE 6)|(IE 7)] - The OR operator. Returns true if any of the subexpressions evaluates to true.

[if !(IE 7)] - Subexpression operators. Used in conjunction with boolean operators to create more complex expressions.

[if (gt IE 5)&(lt IE 7)] - The AND operator. Returns true if all subexpressions evaluate to true

![if !IE] - The NOT operator. This is placed immediately in front of the feature, operator, or subexpression to reverse the Boolean meaning of the expression.



You can also use boolean true or false as shown below -

[if true] - Always evaluates to true.

[if false] - Always evaluates to false.


In general this all what is possible -

downlevel-revealed   ->  <![if expression]>
                           html
                         <![endif]>
downlevel-hidden     ->  <!--[if expression ]>
                           html
                         <![endif]-->
expression           ->  term
expression           ->  expression | term
term                 ->  value
term                 ->  term & value
value                ->  true
value                ->  false
value                ->  !value
value                ->  (expression)
value                ->  comparison
comparison           ->  feature
comparison           ->  feature version
comparison           ->  lt feature version
comparison           ->  lte feature version
comparison           ->  gt feature version
comparison           ->  lte feature version
feature              ->  [A-Za-z][A-Za-z0-9]*
version              ->  [0-9][A-Za-z0-9.]*


SOURCE:

http://msdn.microsoft.com/en-us/library/ms537512.aspx
http://msdn.microsoft.com/en-us/library/bb263988(VS.85).aspx

Author

Commented:
hello, and thanks for the hehlp... but how would you form

if IE 7 and !IE
Jagadeesh MBig Data and Splunk Architect

Commented:
sorry...can you make your question more clear? What are you trying to say in the conditional statement?


Author

Commented:
if it is IE 7 and  not IE show HTML

these do it each by them self

For FF and all non-MSIE
<!--[if IE]><![if !IE]><![endif]-->
HTML
<!--[if IE]><![endif]><![endif]-->

IE 7 only
<!--[if IE 7]>
HTML
<![endif]-->

but I want them combined...  It'd be really handy cause most of the time if it is good for IE7 it's good for FF but not good for IE6


side not: could you explane
downlevel-hidden
downlevel-revealed

I don't remeber it being inthe MSDN but it's been a while since i read it too lol...

Thanks for the help
Jagadeesh MBig Data and Splunk Architect

Commented:
do you realize ...when you say IE it includes IE7 also?

Author

Commented:
well yes...
but it'd be like


<!--[if IE]><![if !IE]><![endif]--> | <!--[if IE 7]>
HTML
<![endif]--><!--[if IE]><![endif]><![endif]-->

I guess I should have wrote
if it is IE 7 "or"  not IE show HTML
Consultant & Challenge Subduer
CERTIFIED EXPERT
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
well no but is what i wrote ok?... i was not able to test it... but i didn't think it would lol... good point on IE8..

Author

Commented:
nevermind... i got you now... I'll be back ...Thanks
jeremyBass

Author

Commented:
I had to test first but great... Thanks for the help on this...
Jagadeesh MBig Data and Splunk Architect

Commented:
hmm.....i thought the question was to just find out all possible combinations....and then peeked in to your problem !!!

Author

Commented:
No It is, that why the I'll be back... sorry... I guess I should have said I'd be back with the list i have so far... :) I have a project to finish tonight but I will be back with alist... please feel free to add anything you can think of... I think it'd be good for everyone it concerns to have a better list then what is out there... Talk with you later :)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.