View Full Version : Detecting Adobe Acrobat viewer

Dec 4th, 2002, 09:14 PM
I have been searching high and low looking for a cross browser, cross platform Adobe Acrobat detect. Netscrape doesn't seem to be difficult, but IE doesn't seem to want to give up the info. Currently this is what I have, but I haven't been able to test it for No Plug-in on a MAC...

<SCRIPT LANGUAGE="Javascript" TYPE="text/javascript">
<!--Begin Hide
//Set the global variable
var hasAA=false;
//End Hide-->
<SCRIPT LANGUAGE="VBScript" TYPE="text/vbscript">
<!-- //Begin Hide
on error resume next
set AAControl=CreateObject("PDF.PdfCtrl.1")
if (IsObject(AAControl)) then
End if
// End Hide-->
<SCRIPT LANGUAGE="Javascript" TYPE="text/javascript">
<!--Begin Hide
if (navigator.mimeTypes['application/pdf'])
//End Hide-->
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--Begin Hide
if (hasAA=true)
document.write("<CENTER><font color=red><B>Warning: In order to view
these PDF files you need to
download the free <A HREF='http://www.adobe.com/products/acrobat/readstep.html'>
Adobe Acrobat Plug-In</A></B></font></CENTER>");
//End Hide-->

I think writing a warning at the top for users without a plugin is
more acceptable than an alert box... I think there has got to be a
better method than what I posted above.. any ideas?? Thanks!

Dec 4th, 2002, 10:52 PM
I use this one (as a js file)...

//This script detects the following:
//Windows Media Player
//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[i].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")

Adjust it a Acrobat Reader little (see the sample usage) and it will work just fine for you aswell ;) (I hope).