Conditional Parameters based on the Plug In
I have an applet which has a parameter which is dependent on the presence of the Java Plug In.
Is there an easy way to put:
if (PlugInExists) { <PARAM NAME="Movie" VALUE = "PluginMovie"> }
else { <PARAM NAME="Movie" VALUE = "NonPluginMovie"> }
in HTML?
Yes!!. You should enable the javascrip in the browser. We have done it in our module based on the plugin exisit like
if (navigator.plugins["Java Plug-in 1.3 for Netscape Navigator"]) { document.writeln('<PARAM name= ');
.
.
}
It works fine. Good luck!!
-Msvp'>
I found that I had to be a little more precise in checking the Netscape browser for the Java Plug-in. First, I learned that on other operating systems (like HP-UX and AIX), the Java Plug-in description is worded differently. So if you look for a plug-in named "Java Plug-in 1.3 for Netscape Navigator" or even just "Java Plug-in" it could fail to find it.
My check is two-fold: first I check the Plug-in description for the words "Java" and "Plug-in", and then I check to see that it supports the correct mime type. That will also ensure that the Java Plug-in is up to the version that you want.
Here is the Javascript function I used. I only call this function if the web browser is Netscape.
function validatePlugin() {
navigator.plugins.refresh(false);
var numPlugins = navigator.plugins.length;
var javaPluginInstalled = false;
var correctVersion = false;
for (i = 0; i < numPlugins; i++)
{
var plugin = navigator.plugins;
if (plugin != null) {
var pluginName = plugin.name.toLowerCase();
if ( (pluginName.indexOf("java") != -1) && (pluginName.indexOf("plug-in") != -1) ) {
javaPluginInstalled = true;
var numTypes = plugin.length;
for (j = 0; j < numTypes; j++) {
var mimetype = plugin[j];
if (mimetype) {
var type = mimetype.type;
if (type.indexOf("application/x-java-applet;version=1.3") != -1) {
correctVersion = true;
}
}
}
}
}
}
if (javaPluginInstalled && correctVersion) {
return true;
} else {
return false;
}
}
dmw73 at 2007-6-29 2:21:58 >
