Detect if an Applet is readyTag(s): Javascript interaction
<SCRIPT>
function isAppletReady(a) {
return a.isActive();
}
</SCRIPT>
<FORM>
<INPUT TYPE=button
VALUE="Check applet"
onClick="if (!isAppletReady(document.applets[0])) alert("not ready");">
</FORM>To execute a Javascript only when an Applet is ready :
<SCRIPT>
function waituntilok() {
if (document.myApplet.isActive()) {
doit();
}
else {
settimeout(waituntilok(),5000)
}
}
function doit() {
....
}
</SCRIPT>
...
<BODY onLoad="waituntilok();">
....
</BODY>Here a "browser friendly" solution from N. Witteman to check if an Applet can be loaded (or found).
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
onError = errHandler;
// Without he parentheses, because we don't want IE
// to do this. Like this, only NS does.
function appLoaded() {
if (!document.applets[0].isActive)
// in IE: isActive returns an error if the applet IS loaded,
// false if not loaded
// in NS: isActive returns true if loaded, an error if not loaded,
// so never reaches the next statement
alert("IE: Applet could not be loaded");
}
function errHandler() {
alert("NS: Applet could not be loaded");
consume();
// stops further processing of the error
}
</SCRIPT>
</HEAD>
<BODY onLoad = appLoaded();>
<APPLET code=someClass.class
codeBase=someURL height=50 width=300><PARAM NAME="bgcolor" VALUE="FFFFFF">
</APPLET>
</BODY>
</HTML>