No flash then display jpeg

Posted on 2004-04-21
Last Modified: 2013-11-18
I have a flash logo on my website.  If a visitor does not have the flash 6 plugin it asks them to download it.  Is there a way for me to detect if the user has the plugin and if not then just display a JPEG logo instead?  


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=",0,29,0" width="600" height="400" align="middle">
<param name="movie" value="logo2.swf">
<param name="quality" value="high">

 <embed src="logo2.swf" width="600" height="400" align="middle" quality="high" loop=false pluginspage="" type="application/x-shockwave-flash"></embed>
Question by:almorris
LVL 10

Expert Comment

ID: 10883190
There's a way to test whether the user has Flash Player 6 or higher, because apparently ( ) Flash Player 6+ configures the browser to add the Flash MIME-type (application/x-shockwave-flash) to the HTTP Accept header.

See the article for more, but it basically means you can perform an

if(strpos($_SERVER['HTTP_ACCEPT'], "application/x-shockwave-flash"))        - (PHP)

to find out. This still leaves you with the fact that you won't find out if people have an older version of Flash, but thats dealt with more on the link above.
LVL 36

Expert Comment

ID: 10884808
This is possible with JavaScript:


function hasflash(){
for (i=0;i<navigator.plugins.length;i++){
if (navigator.plugins[i].name.indexOf("Flash")>=0){
return true;
return false;

// -->

Then, inside your body, you only need a script that calls the hasflash() function like this:

if (hasflash()) {
document.write(CODE FOR FLASH);
document.write(CODE FOR JPEG);
// -->

It may be better if you even used this with PHP to have the document.write substituted by echo(), but both should work.


Expert Comment

ID: 10889194
Zyloch's comment will only work in Netscape / Mozilla and Opera because Internet Explorer does not give you the navigator.plugins list.

I suggest that you use no scripting but let browsers without the plugin fall back on using the HTML code "inside" the OBECT tag.

First, remove the codebase reference to prevent the browser from asking the user if it should download it. I have also added a TYPE parameter to your OBJECT tag for browsers that do not understand a classid (this is used only by IE AFAIK).

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400" align="middle" type="application/x-shockwave-flash">

<param name="movie" value="logo2.swf">
<param name="quality" value="high">

 <embed src="logo2.swf" width="600" height="400" align="middle" quality="high" loop=false type="application/x-shockwave-flash">

<img src="mylogo.jpg" width="600" height="400" alt="My company logo" />


For old Netscapes you may have to add <noembed> tags around the image.

The above code should be handled by the browser as follows:

1) Voila, here is an OBJECT. If I understand this tag and can handle this file type with one of my plugins, I'll invoke the plugin and display it. if not...
2) Well, here is an EMBED tag. If I understand this tag and can handle this file type with one of my plugins, I'll invoke the plugin and display it. if not...
3) A good old IMG tag - since I for one reason or another couldn't make sense of the two other tags I'll just retrieve and display this image.

Gotcha: This is correct behaviour according to the HTML specification. Actual implementation in browsers may vary, as always...

Author Comment

ID: 10891898
hallvord  your comment looks the way to go as I do want this action in IE.   One thing I found is that when I tested it on win98 that had IE5 it thought my plugin was flash 3 (I guess this is what shipped with 98) and would not run the animation.  Is there away for me to see if it's version 6 like I have.  I guess the application/x-shockwave-flash id's all versions of flash.


Accepted Solution

hallvord earned 65 total points
ID: 10893011
Version numbers are a serious mess for many applications and plugins :-)

As far as I know you can not include a version number in the OBJECT tag (it would be great to be able to do something like type="application/x-shockwave-flash; version=6") without including a download location - in your original tag this was the "codebase" attribute. However, we would rather not include "codebase" here because it will make some browsers without Flash ask the user about downloading it..

The HTML tag solution is by far the "cleanest" way in my opinion although I have not tested it extensively - if you do try this solution in various browsers it would be really useful with a little list of how they cope.

If version numbers are essential, perhaps you want to use a script anyway. Plugin detection is complicated because it is not standardised and the methods used in IE and Netscape are wildly different. Also, if your visitor happens to use a version that is neither IE nor Netscape and it is mis-detected the plugin detection will probably break and perhaps give a false "plugin not installed" message (a common problem for Opera because it identifies as IE by default).

Here are a couple of pointers - you may find these interesting:
Using Flash for Flash detection:

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn how to count occurrences of each item in an array.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now