[development] xhtml and embed tag: best way to compliance?

Karl Rudd karl.rudd at gmail.com
Thu Jun 8 00:23:33 UTC 2006


I ran up against this a while ago and through a tonne of research this
is what I have come up with. It's not exactly pretty but it works
everywhere, including in XHTML Strict.

Note the, of course, for Quicktime, Real, etc objects you'll have to
change the "type" and "classid" values.

<!--[if !IE]> <-->
<object type="application/x-shockwave-flash" width="100" height="100"
data="flash.swf">
<!--> <![endif]-->
<!--[if IE]>
<object type="application/x-shockwave-flash" width="100" height="100"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<![endif]-->
    <param name="movie" value="flash.swf" />
    <p>Alternative content.</p>
</object>

Basically you're providing IE with an alternative version of the
opening OBJECT tag.

Additionally to deal with the whole "Click to interact with ActiveX
control" thing I have, wrapped in conditional comments for "IE only",
an external Javascript.

<!--[if IE]><script defer="defer" src="iefixes.js"
type="text/javascript"></script><![endif]-->

Please note the "defer" attribute, it's very important. Basically it
makes the script run after the page body has completed parsing, but
while images, objects, etc are still loading.

In the "iefixes.js" file I have code like this:

var objects = document.getElementsByTagName( 'object' );
for ( var i = 0; i < objects.length; i++ )
    objects[ i ].outerHTML = objects[ i ].outerHTML;

And that's it.

As I said, it's not pretty but it's the "least ugly" and the "least
intrusive" way I could find to implement all of this.

Karl Rudd


Fabio Varesano <fabio.varesano at gmail.com> wrote:
> Hi everybody,
>
> I'm working on making my video module full XHTML compliant.
>
> At the moment the module uses a lot of embed tags for displaying video
> content (Quicktime, Flash, Wmv, Real, etc...).
>
> The problem is that embed tags are NOT part of any W3C standard and
> make a Drupal site which uses the Video module NOT W3 standard compliant.
>
> W3 compliant tag for embedding videos on xhtml pages is object but
> it's not well supported by Internet Explorer... so an object only
> implementation is not possible.
>
> So I investigate on some work around to create valid code but still IE
> compatible..
>
> And I finally get some types of solutions:
> 1 - Javascript hacks:
> basically leave only the object tag then onLoad add the embed tag to
> the document.
> 2 - CSS Tricks
> creating two nested objects then use some css hacks to hide one
> 3 - Extending XHTML
> extends default XHTML dtds to create a custom made embed tag
>
>
> While the first and second solutions are only hacks and are prone to
> errors and incompatibility between current and future versions of
> browsers, the third solution is much more elegant and should be
> supported by future versions of browsers without giving us headaches.
>
> So.. IMHO the best way in doing this is solution 3.
>
> Extending XHTML can be done in two ways:
> - creating a custom made DTD
> - extending an existing DTD by adding new rule as an internal subset
> directly in the document
>
> The problem is that using a customized DTD will produce a document not
> validable by W3C validator.. Other validators can be used.
>
> Instead extending DTD directly on document will create a W3 validable
> document but browsers (even firefox 1.5) will display a "]>" on the
> first line of the page...
>
> So... I'd like to hear your suggestion in facing this problem.
> For me the DTD extension on document is the best solution but I need
> to find some hacks to let browsers hide the "]>"...
>
> What do you think about this???
>
> Thank you.
>
> Fabio Varesano


More information about the development mailing list