Cross-Platform object Syntax Today and Tomorrow

 <  Day Day Up  >  


Cross-Platform <object> Syntax Today and Tomorrow

Although the whole point of Java applets is to deal with cross-platform compatibility issues, Microsoft ActiveX controls and Netscape plug-ins are extremely platform- and browser-dependent. While this might suggest that using Java applets would be the way to go, in many cases, it is more likely that ActiveX controls and Netscape plug-ins can be referenced side-by-side in a Web page before Java applets are even considered . For example, consider the <object> syntax, <embed> syntax, and <noembed> syntax combined in the following way:

  <object classid="XXX" id="object1" name="object1"   height="100" width="100">   <param name="sample param" value="sample" />   <!--   other param elements here -->   <embed src="XXX" id="plug1" name="plug1" height="100" width="100">   <noembed>  Sorry, your browser supports neither ActiveX nor plug-ins.  </noembed>   </embed>   </object>  

In this case, the ActiveX control is tried first, then the plug-in, and finally the content within the <noembed> would be used if none of the other worked. Other methods for addressing cross platform issues might include using JavaScript to detect what browser is being run and then outputting the appropriate markup to reference an ActiveX control, Java applet, or maybe even some other alternative form. The point is that it is possible with some careful thought to cover all the possible situations and until the syntax and technology for including objects is straightened out, this is the only reasonable approach to handling cross- browser issues, short of locking out users from a page or falling back to less interactive or less motivating technology.

Although the future of cross-browser object support sounds enticing, it has yet to materialize. For example, according to the strict versions of XHTML including the upcoming XHTML 2.0, <object> will be the main way to add any form of object to a Web page, whether it's an image, image map, sound, video, ActiveX control, Java applet, or anything else. This approach seems appropriate, but before rushing out to use <object> , understand the ramifications ”little backwards compatibility.

Even today, while standardized, the syntax is not consistently supported. For example, according to even the HTML 4 specification, the object element can be used to include markup from another file by using the data attribute. Imagine specifying a header file called header.html with the contents shown here:

  <h1 style="text-align: center; background-color: #FFA500;">  I am an included heading!  </h1>  

This file then could be included in a Web page by using an <object> tag, like so:

  <object data="header.html">  Header not included  </object>  

This example should pull in the contents of the file header.htm in browsers that support this feature, and display "Header not included" in all others. The example here demonstrates this in use:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   <html xmlns="http://www.w3.org/1999/xhtml" lang="en">   <head>   <title>  Object Inclusion Test  </title>   </head>   <body>   <div style="background-color: yellow; border-style: solid;   text-align: center; margin: 5px;">  Before Object  </div>   <object data="header.html" style="width: 100%;   border-style: dashed; border-width: 1px;">  Header not included  </object>   <div style="background-color: yellow; border-style: solid;   text-align: center; margin: 5px;">  After Object  </div>   </body>   </html>  

A rendering of Internet Explorer 6 and Mozilla shown in Figure 15-6 demonstrates the drastic difference in browsers that do and do not support the full <object> syntax.

click to expand   click to expand
Figure 15-6: <object> for file inclusion in Internet Explorer and Mozilla

Eventually, <object> will be used in a generalized sense and maybe object technologies will be supported through very simple markup. For now, you should carefully use the applet , embed, and object elements to include components and media objects other than images in pages along with any required scripting to avoid locking users out of viewing your Web page.



 <  Day Day Up  >  


HTML & XHTML
HTML & XHTML: The Complete Reference (Osborne Complete Reference Series)
ISBN: 007222942X
EAN: 2147483647
Year: 2003
Pages: 252
Authors: Thomas Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net