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>
