Search code examples
internet-explorerdetectionpdf-viewer

Detect Pdf reader in MsIE


I use an IFrame to view a Pdf document when a link within that IFrame is clicked. However, on machines without the reader, the link will prompt for download. Is there a way, that the same link can prompt the user to download a reader when it detects no reader instead? I thought I have seen this somewhere. Thanks!


Solution

  • This works for me in IE:

    <script>
    var p;
    try {
    p = new ActiveXObject('AcroExch.Document');
    }
    catch (e) {
    // active x object could not be created
    document.write('doesnt look like the PDF plugin is installed...');
    }
    if (p) {
        document.write('does look like the pdf plugin is installed!');
    }
    </script>
    

    Found it here. ..but modified to remove the "endif"