If you saw my previous post on valid Flash embed while maintaining preload functionality and used it, be warned: when the user does not have Flash, a lovely <![endif]-->
will appear in IE where the Flash movie would normally be. The only way around it I’ve found is to actually duplicate everything from the opening object
tag to the closing one so there is one each for IE and Firefox. For example:
<!--[if !IE]>--> <object data="movie.swf" type="application/x-shockwave-flash" width="725" height="235"> <param name="movie" value="movie.swf" /> </object> <!--<![endif]--> <!--[if IE]> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="725" height="235"> <param name="movie" value="movie.swf" /> </object> <![endif]-->
Definitely a pain, but I’ve found no other way around it.
Also in my search for a solution, I discovered that our old pal Internet Explorer does not let you append anything but param
elements to object
elements in Javascript. That was pretty frustrating. Don’t try that. It doesn’t work.
The Pesky iframe and XHTML Strict
Update: Example code updated. It used the shortened form of
iframe
before, as in<iframe />
. That doesn’t sit well with IE. It now uses<iframe></iframe>
which works. The same goes forobject
. It similarly does not play well with Firefox 4 (perhaps even lower versions) in shortened form.If you’ve done much web work before, you’ve probably, at some time or another, had to use an
iframe
. It’s not pretty, but sometimes it’s the only choice, such as embedding a widget from another site or displaying things such as real estate listings. One of my biggest problems with it is that it doesn’t exist in the spec for XHTML Strict! It exists in Transitional, but I don’t like to use it. That may be good enough for some developers, but certainly not for me. How about you?In Internet Explorer 8 (and possibly IE7, but I have not tested it) and Firefox, you can use the
object
element to embed a web page just like aniframe
; however, IE gives it a thick, lovely border that seems impossible to remove. Here’s the trick: employing IE’s conditional comments, use aniframe
for IE and anobject
for everything else. Here’s an example:Valid XHTML Strict! Make sure to keep your settings the same across both elements to keep it consistent.
Happy coding!
Tags: Conditional Comments, Firefox, Iframe, Internet Explorer, Object, Web Development, XHTML
Posted in Web Standards | Comments Off on The Pesky iframe and XHTML Strict