开发者

How can i detect if client browser have adobe reader plugin installed

开发者 https://www.devze.com 2023-02-20 23:08 出处:网络
How can i check with php or js, if client bro开发者_高级运维wser for adobe reader plugin is installed?Give this a go:

How can i check with php or js, if client bro开发者_高级运维wser for adobe reader plugin is installed?


Give this a go: http://thecodeabode.blogspot.com/2011/01/detect-adobe-reader-plugin.html


You might be able to detect it through navigator.plugins.


This has worked for me.

function isAcrobatReaderInstalled() {
                    var isInstalled = false;
                    if (window.ActiveXObject) {
                        var control = null;
                        try {
                            // AcroPDF.PDF is used by version 7 and later
                            control = new ActiveXObject('AcroPDF.PDF');
                        } catch (e) { }
                        if (!control) {
                            try {
                                // PDF.PdfCtrl is used by version 6 and earlier
                                control = new ActiveXObject('PDF.PdfCtrl');
                            } catch (e) { }
                        }
                        if (control)
                            isInstalled = true;
                    } else {
                        // Check navigator.plugins for "Adobe Acrobat" or "Adobe PDF Plug-in"*
    for (var i = 0; i<navigator.plugins.length; i++) 
            {   
                  var n = navigator.plugins[i].name;                              
                    if (n.indexOf('Adobe Acrobat') > -1 || n.indexOf('Adobe PDF') > -1)
                    {
                            isInstalled = true; 
                            break;
                    }
            }
                    }   
                    return isInstalled;
                }


Mac OS X doesn't require Adobe Reader at all and Safari displays them directly in the browser window.

Do not force Adobe Reader and do not force the file to download instead of just displaying it.

0

精彩评论

暂无评论...
验证码 换一张
取 消