Testing for PDF

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TravelMan

    #1

    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.
  • Grant Wagner

    #2
    Re: Testing for PDF

    TravelMan wrote:
    [color=blue]
    > 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.[/color]

    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.mime Types != null &&
    navigator.mimeT ypes.length > 0) {

    if (navigator.mime Types["applicatio n/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="VBScr ipt">
    On Error Resume Next
    If useVBMethod = true Then
    hasPDFSupport = IsObject(Create Object("PDF.Pdf Ctrl.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 <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * 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


    Comment

    Working...