0

我在网页中使用 javascript 来检查计算机上是否安装了 java 和 java web start。像这样

      var javawsInstalled = 0;
      var javaws150Installed = 0;
      isIE = "false";

      if (navigator.mimeTypes && navigator.mimeTypes.length) {
         x = navigator.mimeTypes['application/x-java-jnlp-file'];
         if (x){
            javawsInstalled = 1;
            javaws150Installed = 1;
         } 
      } else {
         isIE = "true";
      }
      console.log("javawsInstalled: " + javawsInstalled)
      console.log("javaws150Installed: "+ javaws150Installed)
      console.log("is IE" + isIE)

在此之前有代码

<SCRIPT language=VBScript>
          on error resume next
          If isIE = "true" Then
            If Not(IsObject(CreateObject("JavaWebStart.IsInstalled"))) Then
                  javawsInstalled = 0
            Else
                  javawsInstalled = 1
            End If

            If Not(IsObject(CreateObject("JavaWebStart.isInstalled.1.6.0.0"))) Then
                  javaws150Installed = 0
            Else
                  javaws150Installed = 1
            End If  
          End If
</SCRIPT> 

但是,它似乎不能在所有浏览器和所有 java 版本上完美运行,例如,当安装 Java 7 update 15 时,它会在控制台中显示以下内容。

javawsInstalled: 0 index_cn.jsp:27
javaws150Installed: 0 index_cn.jsp:28
is IEfalse 
4

0 回答 0