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?

24 of 35 people (69%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How can I run a Java applet after I've used javascript to ensure java is enabled?

Mar 10th, 2000 09:19
Martin Honnen, Ian Meadows,


You don't use JavaScript to run an applet you include an
  <APPLET>
tag in your HTML page. And while you could use JavaScript to check 
whether java is enabled and only if it is write an applet tag
  <SCRIPT>
  if (navigator.javaEnabled())
    document.write(
      '<APPLET NAME="anApplet" CODE="whatever"><\/APPLET>'
    );
  else 
    document.write('your non java content here');
  </SCRIPT>
there is really no need to do so as a simple APPLET tag with 
alternative content inside will do:
  <APPLET NAME="anApplet" CODE="whatever">
  your non java content here
  </APPLET>
The browser will interpret the APPLET tag and load and start the applet 
if it supports Java and Java is enabled and otherwise it will display 
the alternative content of the APPLET tag.