Solved

Java Plugin Detection

Posted on 2002-04-05
8
907 Views
Last Modified: 2013-11-18
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
0
Comment
Question by:chandu33
8 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 6921963
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
 
LVL 1

Accepted Solution

by:
wolfpackinc earned 100 total points
ID: 6923074
//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
 
LVL 12

Expert Comment

by:ahosang
ID: 8123449
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
 
LVL 12

Expert Comment

by:ahosang
ID: 8239540
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 19

Expert Comment

by:cheekycj
ID: 8239914
IMHO, a split is in order.

Both participating experts gave valid responses of detecting Java Plugin.

CJ
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8239987
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
 

Expert Comment

by:SpideyMod
ID: 8303705
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
 
LVL 18

Expert Comment

by:bobbit31
ID: 8815089
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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now