tags:

views:

59

answers:

5

hello all,

I have a flash banner that I want to replace with a static image if the clients browser doesn't have flash enabled.

I was wondering if I can do this with php - or if anyone knows of a good method

Thanks

+3  A: 

http://code.google.com/p/swfobject/

This is what I use when i need to embed flash and it checks for relavent support and what elements are needed.

ozatomic
+1  A: 

I don't think you can check with PHP, you can do it with javascript or Actionscript from SWF file. Here is the official detection kit:

http://www.adobe.com/products/flashplayer/download/detection_kit/

Sarfraz
+1  A: 

You can only do this with javascript, using the navigator.plugins interface. Something like:

if(typeof navigator.plugins['Shockwave Flash']!=='undefined'){ }

However, a far more reliable solution that doesn't require any javascript would be simply to position your fallback image "behind" the flash object so that if the flash doesn't turn up, the image will show through. You can either put an <img/> tag inside the flash <object/> or you can put a CSS background-image on the object.

lucideer
thank but it work with FireFox , but not with Chrome ?U can help me?
Chameron
The javascript doesn't work or the <img/> in the <object/> doesn't work - I'd highly recommend doing the second one if possible - it's FAR FAR better than using javascript.
lucideer
P.S. I just tested the above javascript in my version of Chrome - it seems to works. What version do you have?
lucideer
i enable shockware flash .And test with code to show all plugins of browser.with Chorme i can't see shockware flash.with Firefox i can see shockware flash.-->if(typeof navigator.plugins['Shockwave Flash']!=='undefined'){ }.Work with FF but not Chrome
Chameron
+4  A: 

Allow the <object> (your Flash movie) to degrade:

<object width="640" height="480">
<param name="movie" value="yourflash.swf">
    <img src="yourimage.png">
</object>

This will show the image if the Flash video can't load, too.

strager
i can show a content html instead image ?
Chameron
+1 I believe this IS the right way. Simple and straightforward, both caracteristics of great code. Just a question for you, @strager. Can you write JavaScript in the degradation code for being executed instead?
Erik Escobedo
@user304828, Yes; `<object>` renders the children elements iff the object could not be rendered. @Erik Escobedo, No; you cannot degrade to a script directly. Example: http://jsbin.com/isige [The standard specifies](http://www.w3.org/TR/html4/interact/scripts.html#h-18.1): "Scripts that appear within a SCRIPT element are executed when the document is loaded."
strager
A: 

You could use SWFobject

With SWFobject you display alternative code by default, e.g.

<div id="myContent">
   <p>Alternative content</p>
</div>

This is then replaced where possible with flash content like this:

<script type="text/javascript">
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
</script>

It does have a dependency on JavaScript though which is its only major drawback

seengee