How to detect if device has Flash

I’m using Flash on a webpage. But iPad and iPhone devices can not display Flash and shows blank area. How can I detect if a device visiting my page has Flash or not? If it supports Flash, I want to display Flash. If not, I want to display a static image.

Wrap the flash object tag around the img tag. That way if the object cannot be processed the image it wraps will display instead.

In addition to what Felgall said, you can also use a JavaScript library like SWFObject to embed the flash.

It will detect whether you have Flash available or not and inject the correct <object> tag for you.

Of course, then you’re creating a reliance on JavaScript :stuck_out_tongue:

The SWObject Documentation page has examples for both techniques.

I would recommend using the SWObject JavaScript just to detect the Flash version so as to strip out the object tag if the version of Flash available is too old. That way you still have a good chance of having the Flash work even where JavaScript is disabled.

SWFObject also comes with an “ExpressInstall” SWF, if you for example specify that your flash requires version 9 and the user has version 8, the ExpressInstall will kick in and ask them to upgrade.

(Though this path obviously will not work if the user chooses not to upgrade, in which case felgall’s solution would be the way to go)