Checking for Java Applets with the length Property of the Applet Array : applets « Document « JavaScript Tutorial






<HTML>
    <HEAD>
    <TITLE>Checking for Java Applets</TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function checkApplets(){
      var numApplets = document.applets.length;
      if(numApplets == 0){
        alert(0);
      } else if (numApplets == 1){
        alert(1);
      } else if (numApplets > 2){
        alert(2);
      }
    }
    -->
    </SCRIPT>
    </HEAD>
    <BODY onLoad='checkApplets()'>
    <CENTER>
    <TABLE BORDER=1>
      <TR>
        <TD>
          <APPLET CODE="TestApplet" CODEBASE="." WIDTH=200 HEIGHT=35 NAME="AppletOne" MAYSCRIPT>
            This browser is not able to run Java applets
          <PARAM NAME="clickurl" VALUE="http://www.java2s.com">
          </APPLET>
        </TD>
      </TR>
        <TR>
          <TD>
            <APPLET CODE="TestApplet" CODEBASE="." WIDTH=200 HEIGHT=35 NAME="AppletTwo">
              This browser is not able to run Java applets
              <PARAM NAME="clickurl" VALUE="http://www.java2s.com">
            </APPLET>
          </TD>
      </TR>
    </TABLE>
    </CENTER>
    </BODY>
    </HTML>








14.5.applets
14.5.1.document.applets
14.5.2.document.applets.length
14.5.3.Checking for Java Applets with the length Property of the Applet Array