Valid Flash in Firefox
Saturday, January 13th, 2007In working on getting Ryboe.com to correctly validate tonight, I ran across an interesting tidbit about Flash movies and the W3C. The <embed> tag was created by Netscape as a way to get Flash objects to play in their browser. The problem with this Netscape-invented <embed> tag is that the W3C does not recognize it as a valid XHTML tag. If you are like me and would like for your site to validate, you have to remove it. So how do you get your Flash files to play in Firefox, Netscape, etc. and still have your site validate? Well, after doing some digging, I found that the solution is actually quite simple.
In this case, I have an image slideshow Flash movie that I want to display. Here is what the HTML embed code used to look like to show the Flash:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="580" height="225" id="slideshow" align="left">
<param name="movie" value="slideshow.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent" />
<embed src="slideshow.swf" quality="high" bgcolor="#ffffff" wmode="transparent" width="580px" height="225px" name="slideshow_as2" align="left" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
In this article, entitled Embedding Macromedia Flash While Supporting Standards, Drew McLellan talks about his experience in dealing with this exact issue.
Just strip the <embed> tag altogether and place an extra definition of the Flash file path within the opening <object> tag. A "type" attribute is used to define that you want the Flash movie to play with the Macromedia Shockwave-Flash player. Here is my final code:
<object type="application/x-shockwave-flash" data="slideshow.swf" width="560" height="225" id="slideshow" align="left">
<param name="movie" value="slideshow.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent" />
</object>
By defining the path to the Flash file again with the "data" attribute, my movie plays fine!
Download the Ryboe Tag Cloud Plugin


