Wednesday, January 4, 2012

Adding an applet to an XHTML page

The traditional way to add a java applet to a web page used to be the <applet> tag but this method has been deprecated.Instead the <object> is now used.

The xhtml code to add an applet is quite tricky now. Here is an example of it:

<!--[if !IE]>-->
<object classid="java:vr.class"  
   type="application/x-java-applet" 
   archive="YOUR_JAR.jar" height="HEIGHT" width="WIDTH" > 
<!--[endif]-->
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"  
   height="HEIGHT" width="WIDTH">  
   <param name="code" value="YOUR_CLASS" />
   <param name="archive" value="YOUR_JAR.jar" />
</object>

More examples and a full explanation of what clsid is can be found here