faqts : Computers : Programming : Languages : JavaScript : Applets/Java

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

123 of 136 people (90%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Can JavaScript check whether an applet is loaded?

Mar 31st, 2000 02:50
Martin Honnen,


When 
  <BODY ONLOAD
fires every component including applets is loaded. Otherwise you can 
check
  if (document // document available
      && document['appletName'] // applet available in js
      && document['appletName'].isActive  // applet active
      )
    // script applet
The following function recursively checks till an applet comes 
available and then calls a handler function
  function checkApplet (appletName, handler) {
    if (document && 
        document[appletName] && 
        document[appletName].isActive())
      handler(document[appletName]);
    else 
      setTimeout(checkApplet, 100, appletName, handler);
  }  
called for instance as
  checkApplet('anApplet', function (applet) { applet.methodName() });

IE4+ also has the readyState property for many elements probably 
including applets but I haven't checked that in detail to find out 
whether it works.