ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Plug-In Detection with JavaScript
Subject:   Detecting Acrobat Reader & others
Date:   2002-09-21 00:53:14
From:   anonymous2
Response to: Detecting Acrobat Reader

Try this
/This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer



var agt=navigator.userAgent.toLowerCase();
var ie = (agt.indexOf("msie") != -1);
var ns = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);


if (ie && win) { pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
if (ns || !win) {
nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes.type.toLowerCase();
pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
}


function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }


pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);


//SAMPLE USAGE- detect "Flash"
//if (pluginlist.indexOf("Flash")!=-1)
//document.write("You have flash installed")


1 to 2 of 2
  1. Detecting Acrobat Reader & others
    2003-11-19 02:33:19  anonymous2 [View]

    • Detecting Acrobat Reader & others
      2005-02-23 08:22:37  Hulkman [View]

      • Detecting Acrobat Reader & others
        2007-06-30 10:53:39  WebMaMa [View]

      • Detecting Acrobat Reader & others
        2005-04-15 15:01:58  jas1114 [View]

        • Detecting Acrobat Reader & others
          2005-04-18 06:21:43  ales78 [View]

          • Detecting Acrobat Reader & others
            2005-05-03 13:53:29  attheshow [View]

            • Detecting Acrobat Reader & others
              2006-11-24 05:58:39  ramprakash [View]

            • Detecting Acrobat Reader & others
              2006-11-24 05:58:09  ramprakash [View]

  2. what about other plug-ins ? msWord etc?
    2003-02-05 17:23:28  bnreyal [View]

    • what about other plug-ins ? msWord etc?
      2003-02-13 07:08:04  anonymous2 [View]

      • what about other plug-ins ? msWord etc?
        2003-05-29 21:46:33  anonymous2 [View]

1 to 2 of 2