项目中要判断用户是否有安装pdf阅读器以便于打印 或者是否可以打开pdf文档 这个好像没找到什么方法可以判断用户是否可以打开pdf文档 在网上找了下有判断adobe的 ,不知道有没有直接判断用户是否可以打开pdf文件的方法?
var adobeReaderInfo = { installed : false, version : "0.0", goRedirect:false, getAdobeReader : function(){ if (navigator.plugins && navigator.plugins.length) { for (var x = 0; x < navigator.plugins.length; x++) { if (navigator.plugins[x].description.indexOf("Adobe Acrobat") != -1) { adobeReaderInfo.version = parseFloat(navigator.plugins[x].description.split("Version ")[1]); if (adobeReaderInfo.version.toString().length == 1) adobeReaderInfo.version += ".0"; adobeReaderInfo.installed = true; break; } else if (navigator.plugins[x].description.indexOf("Adobe PDF Plug-In") != -1) { adobeReaderInfo.installed = true; adobeReaderInfo.version = "8+"; break; } } } else if (window.ActiveXObject) { for (x = 2; x < 10; x++) { try { oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');"); if (oAcro) { adobeReaderInfo.installed = true; adobeReaderInfo.version = x + ".0"; } } catch (e) { } } try { oAcro4 = new ActiveXObject("PDF.PdfCtrl.1"); if (oAcro4) { adobeReaderInfo.installed = true; adobeReaderInfo.version = '4.0'; } } catch (e) { } try { oAcro7 = new ActiveXObject('AcroPDF.PDF.1'); if (oAcro7) { adobeReaderInfo.installed = true; adobeReaderInfo.version = '7.0'; } } catch (e) { } } }, judgeAdobe:function(){ if(adobeReaderInfo.installed){ if(parseInt(adobeReaderInfo.version) < 7){ if(confirm("adobe reader 版本太低可能会引起打印的文件布局错位,是否更新到最新版本?")){ adobeReaderInfo.goRedirect = false; window.open("http://get.adobe.com/cn/reader/","",""); return false; }else{ adobeReaderInfo.goRedirect = true; } }else{ adobeReaderInfo.goRedirect = true; } }else{ if(confirm("请先安装adobe reader")){ window.open("http://get.adobe.com/cn/reader/","",""); return false; } } } };