You are here: irt.org | FAQ | Java | Q4013 [ previous next ]
The applet tag doesn't have an onLoad event handler, Its possible in Netscape provided you are willing to tweak the Java applet's code to call JavaScript using the JSObject of Netscape. Doesn't sound very practical to be of any use though.
The JavaScript code can however look for the existence of the applets array. It gets populated when the applet is loaded. The JS code can poll for the loading status of the applet this way. But there's no event driven mechanism to achieve the same that I can think of.
The following was submitted by René Bauer
I could think of one solution, but this would mean taking away JavaScript code that would be called through the onload event but instead using the init() function of the applet.
In the init() function one could add code which calls the JavaScript function that would have been called at the onload event (like a js_onload()). Then your JavaScript would start running when the applet is loaded.
Code in the applet:
public void init() { try { win = JSObject.getWindow(this); win.eval("js_onload();"); } catch(Exception e) { if (e instanceof JSException) { // add JavaScript exception code here } else { // add other exception code here } e.printStackTrace(); }
Code on the HTML page:
function js_onload() { alert("Applet has been loaded!"); document.applets['AppletName'].anyfunction(); // add JavaScript code here }