XML.com: XML From the Inside Out

XML.comWebServices.XML.comO'Reilly Networkoreilly.com
  Articles | Weblogs | Newsletter | Safari Bookshelf
advertisement

Article:
 The Vanishing Image: XHTML 2 Migration Issues
Subject: Use of Conditional Comments
Date: 2003-07-04 07:46:18
From: MikeyC Cacciottolo
Response to: Use of Conditional Comments

"You can embed the conditional comments like this:
<!-- [if !IE] -->
<object></object>
<!-- <![endif] -->"


Your example doesn't work. You can't use conditional comments in that manner.


No Previous Message Previous Message Move up to Parent Message Up Next Message No Next Message


Titles Only Titles Only Newest First
  • Use of Conditional Comments
    2003-07-04 14:37:27 Florian Bauer [Reply]

    I double-checked my example. It does indeed work, at least with the german version of IE 6. I have no idea whether this hack will work with any other version of IE. What version of IE did you use for testing?

    • Use of Conditional Comments
      2003-07-04 20:50:34 MikeyC Cacciottolo [Reply]

      IE6 sp1 - english running on Windows NT &
      IE6 sp1 - english running on Windows XP


      Here is the exact example I used (and I just double-checked it):


      <!-- [if !IE] -->
      i can see this in Internet Explorer
      <!-- <![endif] -->


      • Use of Conditional Comments
        2003-07-05 04:38:08 Florian Bauer [Reply]

        That is strange:
        Here is my example:


        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
        </head>
        <body>


        <!--[if !IE]> -->
        IE doesn't see this.
        <!-- <![endif] -->


        </body>
        </html>


        I checked this with ie6 on winxp, and ie5.5 on win98, both in the german version.
        I also tried your example and the conditional comments do also work there.
        strange...
        cheers
        Florian

        • Use of Conditional Comments
          2003-07-06 16:17:35 MikeyC Cacciottolo [Reply]

          I just realized something else. The example we've been playing with thus far uses a transitional doctype as it doesn't validate using a strict doctype. Something about character data not being allowed there according to the validator.


          XHTML 2 won't have a transitional mode (as far as I'm aware), so it seems that you can't use conditional comments anyways to deal with IE's broken Object support.


          Please correct me if I'm wrong.

          • Re: Use of Conditional Comments
            2003-10-16 18:09:25 Lenny D [Reply]

            "I just realized something else. The example we've been playing with thus far uses a transitional doctype as it doesn't validate using a strict doctype. Something about character data not being allowed there according to the validator."


            XHTML does not allow character data at the <body> level. It must be within a block level element such as

            .



        • Use of Conditional Comments
          2003-07-05 11:25:34 MikeyC Cacciottolo [Reply]

          I've isolated the problem. Your original example was:
          <!-- [if !IE] -->
          <object></object>
          <!-- <![endif] -->


          Your follow-up example was (notice there is no space before the opening bracket of the if statement):


          <!--[if !IE] -->
          <object></object>
          <!-- <![endif] -->


          Your second example is indeed correct. Why do trhings have to be so confusing ;)

Sponsored By:


Contact Us | Our Mission | Privacy Policy | Advertise With Us | | Submissions Guidelines
Copyright © 2008 O'Reilly Media, Inc. | (707) 827-7000 / (800) 998-9938