Monday, August 28, 2006

My friend can up with a curious problem.

To run an applet a prerequiste is to actually check whether JRE(or JVM) is actually present on the machine. Although applet inherits the intelligence to actually point the browser to the web location.

However if the application has to be in total control then how??????

In short for Non-IE browsers then navigator.mimeTypes gets the registry values for the installed runtimes.
But alas IE does not implement mimetypes. So an activeX document to implement the same.


Here is a small snippet of the code written in javascript.


if(navigator.mimeTypes) {
//For non-IE browsers
for (i=0; i < navigator.mimeTypes.length; i++) {
if( (navigator.mimeTypes[ i].type != null)
&& (navigator.mimeTypes[ i].type.indexOf(
"application/x-java-applet;jpi-version=1.5") != -1) ) {
pluginDetected = true;
break;
}

}
}
} else if (is_ie5up) {
var javaVersion;
var shell;
try {
// Create WSH(WindowsScriptHost) shell, available on Windows only
shell = new ActiveXObject("WScript.Shell");

if (shell != null) {
// Read JRE version from Window Registry
try {
javaVersion = shell.regRead("HKEY_LOCAL_MACHINE\\Software\\JavaSoft\\Java Runtime Environment\\CurrentVersion");
} catch(e) {
// handle exceptions raised by 'shell.regRead(...)' here
// so that the outer try-catch block would receive only
// exceptions raised by 'shell = new ActiveXObject(...)'
}
}
} catch(e) {
}

No comments: