AJAX3D - cross-browser html object how to

Posted on August 25th 2006 • Permalink

Wouldn't it be lovely if we didn't have to concern ourselves with the html? So far, it remains Not Possible to present a single html object tag that provides sufficient guidance for both Firefox and IE, for instance. The way to show active content using X3D hosted on a typical html/xhtml web browser is to use simple ecmascript to evaluate a basic browser capability check and generate a specific object element based on browser object implementation preferences and capabilities.

The AJAX tutorials on Ajax3d.com point the way to a great application area, but the 1990’s-browser-wars-style of html coding seriously impacts its use.

You gotta use the html/xhtml ‘object’ element if you want to be close to current html/xhtml standards. So far, it remains Not Possible to present a single object tag that provides sufficient guidance for both Firefox (Ff ) and IE. Along with related security issues, the author’s choice for showing active content using X3D hosted on a typical html/xhtml web browser is to use simple ecmascript to evaluate a basic browser capability check and generate a specific object element based on browser object implementation preferences and capabilities. We must demand w3c spec html/ecmascript from our html web browsers when we use them as a basis for our X3D aimed at the WWW.

Unfortunately, the html/xhtml object element is not yet fully standardized in the major html/xhtml web browsers. Ff cannot honor ‘classid’ and ‘codebase’, preferring to look at the ‘type’ (mime) attr and ‘pluginspage’ param. Those details along with differences in the way that a ‘data’ attribute, a ‘src’ parameter, and the actual file extension are applied produces slightly different functionality that may be one of the last artifacts of the early browser wars.

There are a couple of reasons for this, Probably one biggest one is security. At this time, IEs security for the object is fairly well developed. Security is required in the wild because the browser is loading and executing a control that may be designed to essentially replace the host browser and its host operating system. However, it is very simple to use the ‘classid’ and ‘codebase’ attrs to identify a specific control to be used along with a site for download if that control is not installed. The user is protected by layers of security ranging from not even showing the user any options for the control, to providing detailed interactions before allowing download and execution, to complete promptless freedom to download, install, and run the thing. Ff appears to be more limited by not allowing the author to identify a specific control (looks at ‘type’ instead of ‘classid’) and, as a result, there is no way to reliably recognize whether a specific control is installed and where to get it from a download site (except possibly under some specific circumstances where a control naming a specific mimetype has never been loaded).

More work needs to be done to move some existing AJAX3D examples into compliance with html standards and thus work in multiple html/xhtml web broswers, but here is a first step, being the first time i have been able to get X3D to run reliably OK in both Ff and IE. It is basically combos of a couple of Gecko tutorials. The idea is to produce a ‘custom’ object element that will load a specific X3D browser (Flux in this case) or if not installed, download it and run it.

html;

  

.js;

function LoadObjx3d() {
if (window.ActiveXObject)
{ // browser supports ActiveX/IE API and specifies FluxPlayer
document.write('

type="model/x3d+xml"');
document.write('
classid="clsid:918B202D-8E8F-4649-A70B-E9B178FEDC58"');
document.write('
codebase="http://mediamachines.com/download/SetupFluxPlayer.exe">

');
document.write('

'); document.write(''); document.write('
Got .X3D?/div>'); document.write('<

');
} else
{ // browser supports Firefox/Netscape Plugin API.
document.write('

class="x3dscene" type="model/x3d+xml"');
document.write(' data="myx3dapp.x3d" >

');
document.write('

'); document.write(''); document.write(''); document.write('
Got .X3D?
'); document.write('

');
document.write('

');
} }

For Ff, this works if Flux is installed last or if no other control has registered the mime type. The Ff object seems to go for the nested object with ‘pluginspace’ if it can’t find the mime ‘type’. If there is a handler for the mime-type, Ff may try it. In other words, the author cannot specify which control to use. The only way for the user to choose a specific control is to uninstall all others, or at least install the one you wish to use last. The best way I can predict this working for Flux in both IE and Ff when Flux is not installed, is to run IE first or directly install Flux, then run Ff.

This always works in IE (when allowed by security) whether or not Flux is installed and doing this by script also eliminates the control activation step. If this does not work in IE then security is interfering. visit www.hypermultimedia.com where I use this and try to explain how to set IE security to allow Flux.