[thelist] RE: Acrobat detection
Chris Blessing
webguy at mail.rit.edu
Tue Dec 18 16:35:36 CST 2001
Hi all-
I got a couple of requests about my original question regarding Acrobat
detection, so I figured I'd post the solution I found to the list.
All I really did was search on google for "detect adobe acrobat" and
low-and-behold there were several sites that had a page dedicated to just
that: detecting Acrobat. The script used is apparently used quite a bit as
it was on all 4 top hits on google, different sites though. Here is the
code, slightly modified for IE6 (wrap-warning):
<SCRIPT LANGUAGE="VBScript">
<!-- code for IE only
sAgent = navigator.userAgent
bIsIE = CBool(InStr(sAgent,("MSIE"))>0)
bIsIE3 = CBool(InStr(sAgent,("IE 3"))> 0)
bIsIE4 = CBool(InStr(sAgent,("IE 4"))> 0)
bIsIE5 = CBool(InStr(sAgent,("IE 5"))> 0)
bIsIE6 = CBool(InStr(sAgent,("IE 6"))> 0) // added for IE6 comp.
if bIsIE and (bIsIE3 or bIsIE4 or bIsIE5 or bIsIE6) then
on error resume next
AcroOnPC = IsObject(CreateObject("Pdf.PdfCtrl.1"))
if AcroOnPC then
' do something here like location.replace
else
' do something here like msg with error
End If
end if
-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!-- code for Netscape/non-IE browsers
if (navigator.mimeTypes && navigator.mimeTypes.length){
x = navigator.mimeTypes['application/pdf'];
if (x && x.enabledPlugin){
//do something here like location.replace()
}else{
//do something here like alert(error)
}
}
-->
</SCRIPT>
Works great for me. I'm using it to write out a frameset in a new window
which holds a link back to our site (top frame) and the PDF (bottom frame).
If they don't have Acrobat they get a new window with an error message and a
link to Adobe's site.
Chris Blessing
webguy at mail.rit.edu
http://www.330i.net
More information about the thelist
mailing list