Java Plugin Detection

Hi All Experts,

I have problem, I need to detect if java plugin is installed or not and if not i need to redirect the user to a diff page.

I know the Navigator object gives me a list of plugins installed for the browser, but this works for Netscape only,

How do i do it for IE.

Please Help !!!

Thanks in Advance !!!
- C
chandu33Asked:
Who is Participating?
 
wolfpackincConnect With a Mentor Commented:
//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer


Header:
<SCRIPT SRC="plugins.js"></SCRIPT>
<SCRIPT LANGUAGE="Javascript">
<!--

function wopen() {
if (document.all){

if(pluginlist.indexOf("Java")!=-1){
window.open("java.htm","Name Page Here","fullscreen scrollbars");
}
}
}
//-->
</SCRIPT>

plugins.js at: http://wolfpackinc.hypermart.net/plugins.js
0
 
cheekycjCommented:
see if these help:
http://www.oreillynet.com/pub/a/javascript/2001/07/20/plugin_detection.html?x-order=date

from faqts:
Try following java script, it works on new browsers (NS 4+, IE5+). For
IE you have to enable 'ActiveX objects creation' in security options.


var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);


var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-
1)
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav4up = (is_nav && (is_major >= 4));

var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -
1));
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-
1) );
var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-
1));
var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.0") !=-
1));
var is_ie5up = (is_ie && (is_major == 4)
&& ( (agt.indexOf("msie 5.0")!=-1)
|| (agt.indexOf("msie 5.5")!=-1)
|| (agt.indexOf("msie 6.0")!=-1) ) );

var pluginDetected = false;
var activeXDisabled = false;

// we can check for plugin existence only when browser is 'is_ie5up'
or 'is_nav4up'
if(is_nav4up) {
// Refresh 'navigator.plugins' to get newly installed plugins.
// Use 'navigator.plugins.refresh(false)' to refresh plugins
// without refreshing open documents (browser windows)
if(navigator.plugins) {
navigator.plugins.refresh(false);
}

// check for Java plugin in installed plugins
if(navigator.mimeTypes) {
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.3") != -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) {
// Creating ActiveX controls thru script is disabled
// in InternetExplorer security options

// To enable it:
// a. Go to the 'Tools --> Internet Options' menu
// b. Select the 'Security' tab
// c. Select zone (Internet/Intranet)
// d. Click the 'Custom Level..' button which will display the
// 'Security Settings' window.
// e. Enable the option 'Initialize and script ActiveX controls
// not marked as safe'

activeXDisabled = true;
}

// Check whether we got required (1.3+) Java Plugin
if ( (javaVersion != null) && (javaVersion.indexOf("1.3") != -1) ) {
pluginDetected = true;
}
}


if (pluginDetected) {
// show applet page
} else if (confirm("Java Plugin 1.3+ not found, Do you want to download
it?")) {
// show install page
} else {
// show error page
}
0
 
ahosangCommented:
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or so. I appreciate any comments that would help me to make a recommendation.
 
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
 
ahosang
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ahosangCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ - NO REFUND
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 
cheekycjCommented:
IMHO, a split is in order.

Both participating experts gave valid responses of detecting Java Plugin.

CJ
0
 
ahosangCommented:
fine with me. I can't test this question - that's why i said PAQ. That's why feedback is often required to help cleanup volunteers.
Thanks CJ
0
 
SpideyModCommented:
split

SpideyMod
Community Support Moderator @Experts Exchange

cheekycj, points for you at:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20580423.html
0
 
bobbit31Commented:
wolfpackinc... do you still have the plugins.js file?

if so, could i use it please? i'd rather not have to re-invent the wheel.

thanks

ps. if you don't mind, please post the file here if possible (so others can make use of it in the future)
0
All Courses

From novice to tech pro — start learning today.