I am developing an .aspx page which will ultimately launch an applet after the user clicks on a button (I am using the <applet>
tag). So, I would like to detect if java is enabled/installed on the user's browser.
I am using navigator.javaEnabled() method. However, even though this is working fine on IE7, it is returning inconsistent results on Firefox 3.0.12 (don't know about different browsers), sometimes saying that java is enabled (which it is), and then after launching the applet and coming back out of the applet to this page again, it will report false. If I close firefox and return to the applet launching page, navigator.javaEnabled() will report true again (correctly).
Is there anything that is determining this inconsistent behaviour or is navigator.javaEnabled() not the best way to do the java applet check?
Thanks in advance.
Make in your applet a method
public boolean isRunning() { return true; }
Now create an applet:
<applet src=".../yourapplet.jar" id="someId">
And now wrap this code in some helper function
try {
var x = document.getElementById('someId').isRunning()
return x;
} catch(e) {
return false;
}
Why this works? If applet runs it will return true. If applet doesn't run or Java is not supported you'll get an exception, so you'll get false.