I have this panorama viewer that makes use of java,
but when trying to acces from firefox and java not installed, it warns that some plugin is needed but it doesn't specify whitch one or where to download if from...
So, can i, from javascript, detect if user hasn't installed java and provide him with a download link?
I have this panorama viewer that makes use of java,
but when trying to acces from firefox and java not installed, it warns that some plugin is needed but it doesn't specify whitch one or where to download if from...
So, can i, from javascript, detect if user hasn't installed java and provide him with a download link?
Share Improve this question asked Feb 14, 2012 at 8:42 Toni Michel CaubetToni Michel Caubet 20.2k58 gold badges218 silver badges388 bronze badges 1- possible duplicate of Detecting if java is installed and enabled with javascript – Mat Commented Feb 18, 2012 at 18:24
3 Answers
Reset to default 4Use Deployjava.js to test whether java installed or not:
Sample Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Deploy Java Test </TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript" src="deployJava.js">
</SCRIPT>
<script type="text/javascript">
function call()
{
if (deployJava.versionCheck("1.6.0+") || deployJava.versionCheck("1.4") || deployJava.versionCheck("1.5.0*"))
{
alert("Java is Enabled");
} else
{
alert("Java is Not Enabled");
}
}
</script>
<BODY onload="call();">
</BODY>
</HTML>
Working Sample:
http://jsfiddle/ym78z/
Hope it helps you :-)
You should check out Java Deployment Toolkit.
* deployJava.js
*
* This file is part of the Deployment Toolkit. It provides functions for web
* pages to detect the presence of a JRE, install the latest JRE, and easily run
* applets or Web Start programs.
Detecting if applet is ready
<SCRIPT>
function isAppletReady(a) {
return a.isActive();
}
</SCRIPT>
<FORM>
<INPUT TYPE=button
VALUE="Check applet"
onClick="if (!isAppletReady(document.applets[0])) alert("not ready");">
</FORM>
To execute a Javascript only when an Applet is ready :
<SCRIPT>
function waituntilok() {
if (document.myApplet.isActive()) {
doit();
}
else {
settimeout(waituntilok(),5000)
}
}
function doit() {
....
}
</SCRIPT>
...
<BODY onLoad="waituntilok();">
Here's the solution:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
onError = errHandler;
// Without he parentheses, because we don't want IE
// to do this. Like this, only NS does.
function appLoaded() {
if (!document.applets[0].isActive)
// in IE: isActive returns an error if the applet IS loaded,
// false if not loaded
// in NS: isActive returns true if loaded, an error if not loaded,
// so never reaches the next statement
alert("IE: Applet could not be loaded");
}
function errHandler() {
alert("NS: Applet could not be loaded");
consume();
// stops further processing of the error
}
</SCRIPT>
</HEAD>
<BODY onLoad = appLoaded();>
<APPLET code=someClass.class
codeBase=someURL height=50 width=300><PARAM NAME="bgcolor" VALUE="FFFFFF">
</APPLET>
</BODY>
</HTML>
....
</BODY>
Hope this will work for you!!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745327092a4622708.html
评论列表(0条)