views:

5484

answers:

3

Are there any ways providing an alternate GIF/PNG image, in case the user has no Adobe Flash installed and/or deactivated. I’ve found recommendations, like the following from W3C, which determine via JavaScript the existence of Adobe Flash on the client: W3C Providing alternative images

Honestly, I would prefer a non JS technique. I’m thinking of some XHTML tag, equivalent to <noscript>. (like <noobject> if the object (in our case Flash) can’t be displayed/loaded).

The reason for needing this separation is the following: The bank I’m working for will preferably display their banners in Flash format. In case it isn’t possible a simple image should be shown. In the past it was solved very likely in the way mentioned before. We’re currently working on a design refresh and that’s where I stumbled upon this piece of code which makes me wonder if it’s really the most elegant and compatible way of doing so.

Another idea that strikes me: Is it actually possible to load Flash-objects in a JavaScript disabled environment?

+5  A: 

I don't know why you want to avoid javascript, it is the best solution when dealing with Flash.

using the SWFObjects Library (the best known so far for the matter) you can do this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; 
<html xmlns="http://www.w3.org/1999/xhtml"&gt; 
<head> 
 <title> My Home Page </title> 
 <meta name="viewport" content="width=780"> 
 <script type="text/javascript" src="swfobject.js"></script> 
</head> 
<body> 
 <div id="splashintro"> 
   <a href="more.html"><img src="splash_noflash.png" /></a> 
 </div>
 <script type="text/javascript"> 
   var so = new SWFObject("csplash.swf", "my_intro", "300", "240", "8", "#338899"); 
   so.write("splashintro"); 
 </script> 
 </body> 
</html>

what the script does is replace the splashintro div with the flash file, if the browser does not support Flash, then does nothing and the splash_noflash.png will be shown.

P.S. With this technique you are ready for the iPhone, instead of showing the blue cube, it will show the image :)

balexandre
Some people allow Flash, but have Javascript turned off. Why depend on Javascript when you can have the best of both worlds?
Raithlin
And still others turn both off because they don't have enough bandwidth or don't like scripts running without their knowledge.
cdeszaq
thx for pointing me to the SWF Object Library. one up vote for this.though i didn't choose it as the perfect answer as the usage of the JS library isn't necessary in my particular case.
Gerhard Dinhof
no worries, always glad to help :)
balexandre
there is some changes with swfobject 2.0 : http://code.google.com/p/swfobject/wiki/documentation
Niklaos
+1  A: 

Actually having flash installed but javascript turned off is a valid scenario. This should work across most browsers:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="600" id="flashContent">
  <param name="movie" value="flash.swf" />
  <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="flash.swf" width="800" height="600">
  <!--<![endif]-->
      <img src="(...)" alt="Put your alternate content here" />
  <!--[if !IE]>-->
    </object>
  <!--<![endif]-->
</object>
Kristian J.
if in my example the javascript is turned off, then the script does not run, and for that does not replace the image, and ... you will see the image ! :) so: same thing at the end ;)
balexandre
that is way I do love SWFObjects library ;) runs everywhere perfectly
balexandre
Since when do other browsers do anything with conditional comments? That is not part of any w3c spec I've seen.
cdeszaq
well, in my opinion it doesn't matter if all non-IE browser will ignore the [if !IE] tag. they'll do exactly what the command tells us: interpret the second object tag. only IE will skip the tag.
Gerhard Dinhof
The conditional comments are only for IE. That's the whole point.
bzlm
+1  A: 

I use the following code for graceful degradation. It works well.

<!--[if !IE]> -->
<object type="application/x-shockwave-flash" data="flash.swf" width="500" height="100">
<!-- <![endif]-->

<!--[if IE]>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" 
    width="500" height="100">
  <param name="movie" value="flash.swf" />
<!--><!--dgx-->
  <param name="loop" value="false">
  <param name="menu" value="false">
  <param name="quality" value="high">
  <img src="flash_replacement.png" width="500" height="100" alt="No Flash">
</object>
<!-- <![endif]-->
Raithlin