admin管理员组文章数量:1420650
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!!
本文标签: detect java not installed and provide a link from JavascriptStack Overflow
版权声明:本文标题:detect java not installed and provide a link from Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745327091a2653642.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论