Well technically you could just use:
window.navigator.javaEnabled();
but it has some issues with older Netscape browsers (
http://segal.org/macjavabugs/enabled/ )
In terms of your question: the new ActiveXObject is an IE specific
Object that allows you to access ActiveX. I donno how reliable this is
since it is ActiveX. It seems to me with more and more browser security
issues that ActiveX could be disabled or unaccessible to your scripts.
The other concern I have with your example is the fact that eval is
used. In this case it does not seem neccessary to have that statement
wrapped in eval. It seems like a slowdown. You function code be
simplified:
function javaInstalled(){
// if we can quickly determine java is enable return quickly
if( window.navigator.javaEnabled() ) return true;
// if netscape style plugins check to see if java is enabled
if (navigator.mimeTypes &&
navigator.mimeTypes["application/x-java-vm"]) return true;
// if IE and not the Mac version need to check ActiveXObject
else if (document.all && (navigator.appVersion.indexOf("Mac")==-1)){
try {
// create a Java ActiveX Object
var xObj = new ActiveXObject("Javaplugin");
if (xObj) return true;
} catch (e) {}
}
// if we get here we haven't detected java
return false;
}
I added comments and added a condition on the top of the function. I
did this because the script overhead will be greatly reduced if you
don't have to create an ActiveX object at least logic suggest so ;-)
Received on Tue Feb 7 21:29:04 2006