js判断ie和edge是否安装Adobe Reader PDF阅读器

ie浏览器和edge浏览器,必须用Adobe Reader PDF阅读器才可以打开pdf文件,其他现代浏览器自带pdf阅读器,无需安装。

判断ie或者edge如果安装了,就浏览pdf文件;如果没安装就给出安装软件,让他下载、

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="jquery-1.10.2_d88366fd.js"></script>
    </head>
    <body>
            <img src="myzh_yitou03.png" alt="" class="aaa"/>
    </body>
    <script>
    $(function(){
            function isAcrobatPluginInstall() {
                //下面代码都是处理IE浏览器的情况 
                if((window.ActiveXObject)||(navigator.userAgent.indexOf("Trident") > -1)) {
                    for(x = 2; x < 10; x++) {
                        try {
                            oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');");
                            if(oAcro) {
                                return true;
                            }
                        } catch(e) {}
                    }
                    try {
                        oAcro4 = new ActiveXObject('PDF.PdfCtrl.1');
                        if(oAcro4)
                            return true;
                    } catch(e) {}
                    try {
                        oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
                        if(oAcro7)
                            return true;
                    } catch(e) {}
                }else{
                //chrome和FF、safrai等其他浏览器
                    return true;
                }
            };
            
            $('.aaa').bind('click',function(){
                var pdfresult=isAcrobatPluginInstall();
                if(pdfresult){
//                    已安装后跳转
                    location = '跳转到aaa.html';
                }else{
//                    未安装跳转到下载安装地址
                    alert("对不起,您还没有安装PDF阅读器软件呢,为了方便预览PDF文档,请选择安装!");
                    location = 'http://ardownload.adobe.com/pub/adobe/reader/win/9.x/9.3/chs/AdbeRdr930_zh_CN.exe';
                }
            });
        })
    </script>
</html>

 

转载于:https://www.cnblogs.com/gaidalou/p/7428426.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值