Accessibility
 
Home > Products > Flash > Support > Flash Player detection
Flash Icon Macromedia Flash Support Center - Flash Player detection
Substituting an image for a Flash Player movie on the fly

The following code will work on all browsers that understand either JavaScript or ActiveX. If the browser supports the MIME Type application/futuresplash, the script writes out an EMBED tag; otherwise, it writes an IMG tag. The OBJECT tag is invoked on any browser that supports ActiveX, regardless of which tag the JavaScript writes. The lines starting with "//" are comments, as are the lines enclosed in " <!-- --> " The browser ignores the former as "not part of the JavaScript to be executed," and the latter as "not part of the HTML to be displayed."

<!-- begin the OBJECT tag, which will be understood by ActiveX-capable browsers -->
<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
CODEBASE="http://active.macromedia.com/flash/cabs/swflash.cab#version=3,0,0,11"

WIDTH="220" HEIGHT="110" NAME="sw" ID="sw">
<PARAM NAME="Movie" VALUE="flash_movie.spl">
<PARAM NAME="quality" VALUE="high">
<PARAM NAME="Loop" VALUE="true">
<PARAM NAME="play" VALUE="true">

<!-- begin the JavaScript -->
<SCRIPT LANGUAGE="JavaScript">
<!-hiding contents from old browsers

//If this browser understands the mimeTypes property and recognizes the MIME Type //"application/x-shockwave-flash"...
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){

   //...write out the following <EMBED> tag into the document.
   document.write('<EMBED SRC="flash_movie.spl" WIDTH="220" HEIGHT="110" LOOP="true" QUALITY="high">');
}

//Otherwise,...
else {

   //...write out the following <IMG> tag into the document. The image need
   //not be the same size as the Flash Player movie, but it may help you lay out the
   //page if you can predict the size of the object reliably.
   document.write('<IMG SRC="welcome.gif" WIDTH="220" HEIGHT="110" ALT="Non-Shockwave Welcome">');
}

//Done hiding from old browsers. --> 
</SCRIPT>

<!-- Close the OBJECT tag. --> 
</OBJECT>
Make sure there are no line breaks in your EMBED or IMG tags, or the script will fail. If you'd like to use line breaks, put each line in a separate document.write() . Notice that the entire EMBED and IMG strings are enclosed in single quotes; this allows for double quotes to be inside the strings without breaking them. If you want to put an apostrophe in your string (as in ALT="Your browser doesn't support Flash Player" ), you'll need to escape it with a backslash so that it doesn't close the string prematurely ( ALT="Your browser doesn\'t support Flash Player" ).

To Table of Contents    Back to Previous document    Forward to next document