Testing for PDF

T

TravelMan

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.
 
G

Grant Wagner

TravelMan said:
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 <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_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-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top