Nested <object> elements

We already know that an <object> element can contain fallback code in case the element cannot be displayed. The XHTML standard specifies that <object> elements may be nested. The required behaviour is that the browser should try to render the outermost <object> first, and failing that move in one level at a time until it finds one that it can display. Failing that it renders the innermost code.

Using this principle we would expect that the following code should work on both Internet Explorer and Firefox. Internet Explorer should use the ActiveX version and Firefox should use the inner <object>.

<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
        codebase="http://activ ... 1,52,701"
        standby="Loading Media Player components..." 
        type="application/x-oleobject" width="320" height="240">
  <param name="ShowDisplay" value="0" />
  <param name="ShowControls" value="1" />
  <param name="AutoStart" value="0" />
  <param name="AutoSize" value="0" />
  <param name="FileName" value="resources/IceScraping.wmv" />
  <object type="video/x-ms-wmv" data="resources/IceScraping.WMV"
          width="320" height="260">
    <param name="src" value="resources/IceScraping.WMV" />
    <param name="autoplay" value="0" />
    <param name="showcontrols" value="1" />
    <p>Cannot play WMV files!</p>
  </object>
</object>

The effect of this code is:

Cannot play WMV files!

You may think this is the final piece of the jigsaw for solving browser independent display of embedded content using standard XHTML. However, there is a problem with the above solution. Unfortunately, Internet Explorer 6 and earlier do not respect the specification for nesting <object> elements. IE6 will attempt to display both <object>s. The next session looks at strategies for solving this problem.

For now we should take the approach that if we can find a single method that works on all browsers, we should use it. We should only look for composite solutions where browser support is variable.

Valid XHTML 1.0! | Valid CSS! | WCAG Approved AA
Page design by: John P Scott - Hosting with: Netcetera