2009-03-20 35 views

Trả lời

7

java deployment toolkit

 

script src="http://java.com/js/deployJava.js" 

if (deployJava.versionCheck('1.6')) 
{ 
alert("1.6 installed") 
} 

+0

tính năng này không hoạt động luôn. (1) Nếu nó bị vô hiệu hóa trong firefox nó nói không được cài đặt. (2) trên sư tử os x, ngay cả khi nó bị vô hiệu hóa trong tất cả các trình duyệt, nó nói với cài đặt – Nakul

0

Đây không phải là một câu trả lời cho câu hỏi chính xác của bạn nhưng được cung cấp như một giải pháp cho việc xác định trình duyệt riêng của mình. Đừng quá khắc nghiệt, đây thực sự là mã cũ mà tôi đã viết một thời gian trước đây.

import java.applet.*; 

public class BrowserDetector extends Applet { 

    public void init() { 
     if (isNetscape()) { 
      System.out.println("This browser is a Netscape Browser."); 
     } 
     if (isMicrosoft()) { 
      System.out.println("This browser is a Microsoft Browser."); 
     } 
     System.out.println("VM Type: " + getVMType()); 
    } 

    public static boolean isNetscape() { 
     try { 
      Class.forName("netscape.applet.MozillaAppletContext"); 
     } catch (ClassNotFoundException e) { 
      System.out.println("This browser is not a Netscape Browser."); 
      return false; 
     } 
     return true; 
    } 

    public static boolean isMicrosoft() { 
     try { 
      Class.forName("com.ms.applet.GenericAppletContext"); 
     } catch (ClassNotFoundException e) { 
      System.out.println("This browser is not a Microsoft Browser."); 
      return false; 
     } 
     return true; 
    } 

    public String getVMType() { 
     String theBrowser = "No VM"; 
     String appletContext = getAppletContext().toString(); 
     if (appletContext.startsWith("sun.applet.AppletViewer")) 
      theBrowser = "APPLETVIEWER"; 
     else if (appletContext.startsWith("netscape.applet.")) 
      theBrowser = "NETSCAPE"; 
     else if (appletContext.startsWith("com.ms.applet.")) 
      theBrowser = "MICROSOFT"; 
     else if (appletContext.startsWith("sunw.hotjava.tags.TagAppletPanel")) 
      theBrowser = "HOTJAVA"; 
     else if (appletContext.startsWith("sun.plugin.navig.win32.AppletPlugin")) 
      theBrowser = "NETSCAPEPLUGIN"; 
     else if (appletContext.startsWith("sun.plugin.ocx.ActiveXApplet")) 
      theBrowser = "MICROSOFTPLUGIN"; 
     else if (appletContext.startsWith("sun.plugin.viewer.context.IExplorerAppletContext")) 
      theBrowser = "MICROSOFTPLUGINJRE1.4"; 

     return theBrowser; 
    } 

} 
Các vấn đề liên quan