Add Flash To Your Webpage - The Right Way
Posted by Matthew Hancock
Tutorials April 6th, 2007 at 3:38 pmAlmost everyone knows how to add flash to a webpage these days. However, most of the code people use is not cross-browser compatible. It is bulky, slow, and many times just doesn’t work 100% of the time. The problem usually lies with the embed and object tags. Normally when a person adds flash to a webpage, there are two places in the code where the flash movie is referenced. One is in an Object Tag, the other is in an Embed Tag. Most browsers can only support one or the other. So what does the browser do when it runs into an unsupported tag? Well, fortunately most newer browser just ignore it. Some older browsers will spit out errors, but if you’re still using IE4 you should be slapped anyway. My point is a simple one. Why rely on bad code?
This code is different. It uses IE supported HTML Conditional Comments to display only the supported code snippet. It’s simple and concise, and most importantly, a much needed upgrade from the code floating around out there.
<!--[if !IE]> -->
<object type="application/x-shockwave-flash" data="flash.swf" width="640" height="480">
<!-- <![endif]-->
<!--[if IE]>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
width="640" height="480">
<param name="movie" value="flash.swf" />
<!--><!---->
<param name="loop" value="true" />
<param name="menu" value="false" />
</object>
<!-- <![endif]-->

Recent Comments