Search code examples
javascriptflashswfobject

Flash detection with SWFObject


I don't quite understand the SWFObject examples downloaded http://download.macromedia.com/pub/developer/alternative_content_examples.zip'>here.

Why the availability of the flash plugin is checked only by <|--[if !IE]> --> instructions. Does it mean that just IE can be without preintalled flash player? Of course no. Then why just IE is checked?


Solution

  • No! The code doesn't mean it only check IE.

    There are two example in the zip, first one is

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="728" height="90" id="myFlashContent">
        <param name="movie" value="banner.swf" />
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="banner.swf" width="728" height="90">
        <!--<![endif]-->
            <img src="banner.jpg" alt="Alternative content rules!" />
        <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
    </object>
    

    second one is:

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="480" height="270" id="myFlashContent">
        <param name="movie" value="movie.swf" />
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="movie.swf" width="480" height="270">
        <!--<![endif]-->
            <ol>
                <li><img src="frame1.jpg" alt="" />It's night-time, a UFO flies over the pasture, cows grazing</li>
                <li><img src="frame2.jpg" alt="" />The UFO tries to abduct two cows using a tractorbeam, however the cows appear to be too heavy to be lifted off the ground</li>
                <li><img src="frame3.jpg" alt="" />It's daytime again, cows are still grazing, one cow looks very relieved</li>
            </ol>
        <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
    </object>
    

    <!--[if !IE]>--> and <!--<![endif]--> works as a pair. They are just like if (!isIE){ //... }. And what it means is IE will ignore the code inside the pair (pay attention to the ! which means "not"). They are actually not related to Flash detection.

    Flash detection(in fact it's graceful degradation) is done by using the characteristic that when the plug-in is not present, its object/embed tag will be ignored and the HTML inside those tags will be displayed.

    If Flash is not present, for the first one, <img src="banner.jpg" alt="Alternative content rules!" /> will be displayed. For the second, it's

    <ol>
        <li><img src="frame1.jpg" alt="" />It's night-time, a UFO flies over the pasture, cows grazing</li>
        <li><img src="frame2.jpg" alt="" />The UFO tries to abduct two cows using a tractorbeam, however the cows appear to be too heavy to be lifted off the ground</li>
        <li><img src="frame3.jpg" alt="" />It's daytime again, cows are still grazing, one cow looks very relieved</li>
    </ol>