Detection Scripts
         written by kirupa chinnathambi

A common usability mistake people make is that they assume that everyone has the latest version of the Macromedia Flash Player installed. While 90% of people do use have the Flash plug-in installed, not everyone has the Flash 6 Player or even the Flash 5 Player installed on their computers. Should a user visit your site using an older, incompatible version of the Flash player, you could end up inconveniencing the viewer to the point that he/she never returns to your site again! Not all users use Internet Explorer with the cool Install On Demand feature that automatically downloads the plug-in if the user does not have the plug in installed.

To solve all your woes mysterious, holy people have created something called a detection script. A detection script basically checks your computer for the Flash plug-in. Should a plug-in be found, it performs an action such as transporting you to a page containing Flash content. If a plug-in cannot be found, the script might take you to another non-Flash page requesting you to download the Flash plug-in from another Web site.

I have provided several variations of the Flash Detection script for you to use on your own site. To use these scripts, simply copy and paste the code into an HTML document. Usually the HTML document will be the first page that leads up to some Flash content such as an index.htm or flashdetect.htm page.

Flash Detect: Flash Page or No-Flash Page
The most common type of Flash detection script is the script that checks to see if you have the Flash plug-in installed. Depending on what the script finds you will either see a Flash page or a non-Flash page. The non-Flash page will be displayed if you do not have the Flash plug-in installed. The Flash page, of course, will display if you have the Flash plug-in installed.

Here's the code:

[ script for detecting the flash plug-in and taking you to a flash/noflash page ]

To make the code work on your site, look in the code you pasted and replace http://www.kirupa.com with the page containing the Flash content. Replace http://www.kirupa.com/noflash.htm with the page that does not contain Flash content.

For the above code, you must ensure that the URL you enter is the full path instead of a relative URL. Instead of simply entering indexflash.htm, enter http://www.kirupa.com/indexflash.htm. Entering a relative URL without the http header will cause your script to fail.

Flash Detect: Image or Animation
In this script, the HTML page will check to see if the user has Flash. If the user has Flash, the animation contained on THE SAME page will be displayed. If the user does not have Flash, a graphical representation of the animation you provide will be displayed.

Here's the code:

[ script for detecting the flash plug-in and displaying swf or image ]

You will need to make some minor modifications to the above script for it to work properly for your site. Replace all instances of script.swf with the path to your Flash movie. Likewise, replace all instances of script.gif with the page to the image that will be displayed if the user does not have Flash installed.

The above pieces of code should help you in creating your own Flash Detection script. There is no way for you to cover 100% of all users. There will always be some user on a new, arcane browser that does not work with the re-direction. With these scripts, I am confident that you will target a majority of users on various platform/browser configurations!

For more control over how your Flash movies are detected, I recommend you try the Macromedia Flash Deployment Kit from the following URL: http://www.macromedia.com/software/flash/download/deployment_kit/

If you have a question about this or any other topic, the easiest thing is to drop by our forums where a bunch of the friendliest people you'll ever run into will be happy to help you out!


Get cool tips, tricks, selfies, and more...personally hand-delivered to your inbox!

( View past issues for an idea of what you've been missing out on all this time! )


blog comments powered by Disqus



kirupa.com's fast and reliable hosting provided by Media Temple.