|
|
<applet
name="Dizzer" code="Dizzer.class"
alt="JAVA Applet"
width="400" height="50"
codebase="../common/class/" align="left">
<param name="FontFace" value="Arial">
<param name="Size" value="30">
<param name="Text" value="Applet Object">
</applet>
|
This is the Java applet Dizzer.class, or
document.applet[0].
JavaScript can access the property name.
The parameter / value pairs are not scriptable.
|
<form
name="AppForm">
<input type="button" name="AppBttn"
value=".stop() Applet" onClick="AppControl()">
</form>
<script language="JavaScript">
<!--
|
The form AppForm contains one button object, AppBttn, which
acts as a toggle on/off switch for the Applet. |
function
AppControl() {
App = document.applets[0]
bttn = document.AppForm.AppBttn
|
AppControl defines two variables, App (the
applet) & bttn(the
toggle). |
bttn.value = ( bttn.value == ".stop()" ) ?
".start()": ".stop()"
|
if ( bttn.value != ".stop()" ) { App.stop() }
else { App.start() }}
// -->
</script> |
The bttn.value is checked & reset using a the
conditional control structure. Then checked again to invoke the Applet methods start() & stop(). |