My hobbyist coding updates and releases as the mysterious "Mr. Tines"

Friday, 5 November 2004

Strict XHTML Applets

Noting that this page was reached by the search query "Strict XHTML Applets", a brief guide to what I've done along these lines.

I started with Hixie's Embedding flash without <embed>, which nests <object /> tags, but suffers from parameter duplication, and, IIRC, unless I had things back-to-front, it also leaves empty place-holders for the "other platform" applet in some browsers. By using IE conditional comments in a sneaky fashion, one only need duplicate the opening <object> as follows (code based upon that in my N-body applet page):-

<!--[if IE]>

<object archive="nbodyzip.zip" type="application/x-java-object"
code="Nbody.class" width="250" height="150" title="&lambda; Serpentis
II system simulation" standby="standby" >
<![endif]-->

<!--[if !IE]> -->
<object archive="nbodyzip.zip" type="application/x-java-object"
classid="java:Nbody.class" title="&lambda; Serpentis II system
simulation" standby="standby" width="250" height="150" >
<!-- <![endif]-->

<!-- shared parameter tags go here if needed e.g. -->
    <param name="bgcolor" value="#000000" />

<!-- followed by fallback content such as:- -->

    <p>Alas! Either your browser is not one for which I've been able to get
    XHTML object tags to work, or perhaps it's not Java enabled!</p>

<!-- finally close the one object tag -->

</object>

Here IE wants the main-class via the code attribute code="Nbody.class"; whereas Gecko browsers (Netscape, Mozilla, Firefox) want it via the classid attribute, classid="java:Nbody.class". Both use the archive attribute to show where the bytecode is to be found.

This works for Netscape 4 and up. I believe it also works in Konqueror (KHTML), and thus also Safari - but if you know different, please say.

It would be nicer if I could find one tag that would feed Java to all these browsers…

No comments: