470,810 Members | 873 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Testing for PDF

Is there any way to test for the presence of the Adobe Acrobat plug-in
in Internet Explorer? It's doable in Netscape but so far I cannot get
it to work in MSIE.
Jul 23 '05 #1
1 1656
TravelMan wrote:
Is there any way to test for the presence of the Adobe Acrobat plug-in
in Internet Explorer? It's doable in Netscape but so far I cannot get
it to work in MSIE.


A quick search of the Google turned up this code:

<!-- Check if browsers have PDF support and
record if we need to use VBScript detection
method if the number of MIME types is 0. -->
<script type="text/javascript">
// Variable to keep track of user's PDF support
var hasPDFSupport = false;

// Variable to indicate whether we need to use
// VBScript method to detect PDF support
var useVBMethod = false;

// Internet Explorer returns 0 as the number of
// MIME types, so this code will not be executed
// by it. This is our indication to use VBScript
// to detect PDF support.
if (navigator.mimeTypes != null &&
navigator.mimeTypes.length > 0) {

if (navigator.mimeTypes["application/pdf"] != null) {
hasPDFSupport = true;
}
} else {
useVBMethod = true;
}
</script>
<!-- Visual Basic Script to detect support of Adobe PDF
plug-in. This code is not run on browsers which report
they have MIME types, and it is also not run by
browsers which do not have VBScript support. -->
<script language="VBScript">
On Error Resume Next
If useVBMethod = true Then
hasPDFSupport = IsObject(CreateObject("PDF.PdfCtrl.6"))
End If
</script>

Note that PDF.PdfCtrl.6 is for Adobe Reader 6, I believe the object name
is different for other versions, so you may want to test them all (just
change "6" to "5" to test the presence of version 5 I believe, but you may
need to do some research if that doesn't work).

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Hugh Cowan | last post: by
reply views Thread by Jonathan Allen | last post: by
reply views Thread by Brian Russell | last post: by
4 posts views Thread by Peter Rilling | last post: by
72 posts views Thread by Jacob | last post: by
58 posts views Thread by nw | last post: by
reply views Thread by Matthew Fitzgibbons | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.