1
Embedding and running Java Applets
Some useful tags for launching Java Applets
Peter Mozelius DSV/UCSC
2
5 ways of embedding an Applet1. <applet> </applet>2. <embed>
3. <object> static versioning 4. <object> dynamic versioning
5. HTMLConverter
3
The original applet tag<html> <head> <title> Hello Applet</title> </head> <body> <applet code="Hello" width="200" height="200"> Problems with launching the applet </applet> </body>
</html>
4
The embed tagFor older versions in the Mozilla famillyFirefox works with <applet> as well as with
<object>
<embed code="Applet1.class" width="200“ height="200" type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp"/>
5
<object> dynamic versioningFor IE only:<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93“
width="200" height="200"> <param name="code" value="Applet1.class"> </object>
6
<object> static versioning classid="clsid:CAFEEFAC-xxxx-yyyy-zzzz-ABCDEFFEDCBA"
In this form, "xxxx", "yyyy", and "zzzz" are four-digit numbers that identify the minimum version of Java Plug-in to be used
Java plugin 1.6: classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA"
7
<object> for other browsers For other browsers than Internet Explorer
<object classid="java:Applet1.class" type="application/x-java-applet" height="300" width="400" > <param name="codebase”value="files" />
8
Cross browser <object> <!-- MS IE (Microsoft Internet Explorer) -->
<object classid="clsid:8AD9C840-044E-11D1-B3E9-
00805F499D93" height="300" width="300" > <param name="code" value=“Applet1" /> <!--[if !IE]> Mozilla/Netscape family --> <object classid="java:Applet1.class" height="300" width="300" > </object>
<!-- <![endif]-->
</object>
9
HTMLConverter
10
HTMLConverter Multi-platform support Combines
<applet> <embed> <object>
PROMPT:> HTMLConverter NOT java HTMLConverter anymore
11
Workshop Pause
12
Deploying Applets with JavaScript Version 1 with <embed> and <object>
<html> <script language="Javascript"> var app = navigator.appName; if (app == 'Mozilla') { document.write('<embed code = "Applet1.class"', 'width="200"', 'height="200"','type= "application/x-java- applet;version=1.6">'); }
13
Deploying Applets with JavaScript else if(app == 'Microsoft Internet Explorer') { document.write('<object ',
'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"',
'width="200"', 'height="200">', '<param name="code"
value="Applet1.class">', '</object>');
}
14
Deploying Applets with JavaScript else { document.write('<p>Sorry, unsupported browser.</p>'); } </script> </html>
Thank you for listening!