如何使用javascript检查java插件是否启用?

时间:2013-02-14 09:13:31

标签: javascript asp.net

我有一个由applet代码组成的.aspx页面。为了运行它,浏览器必须具有活动的Java插件。

有没有办法检查是否使用Javascript安装并启用了Java插件?

2 个答案:

答案 0 :(得分:4)

window.navigator.javaEnabled()//true if java enabled 

window.navigator.plugins // will give u all the plugins installed in the browser

答案 1 :(得分:3)

我建议你选择Oracle推荐的方法

<script src="http://www.java.com/js/deployJava.js"></script>
<script>
    if (deployJava.versionCheck('1.6+')) {            
        var url = "http://docs.oracle.com/javase/tutorialJWS/deployment/webstart/examples/Notepad.jnlp";

        <!-- you can also invoke deployJava.runApplet here -->
        deployJava.createWebStartLaunchButton(url, '1.6.0'); 
    } else {
        document.location.href="http://oracle.com";
    }
</script> 

这取自http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/jreVersionCheck.html

您还应该查看Java Deployment Toolkit http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit