js 检测浏览器是否安装Adobe Reader插件

匿名 (未验证) 提交于 2019-12-02 23:43:01

function Check_AdobeReader() {             var displayString;             var acrobat = new Object();             acrobat.installed = false;             acrobat.version = "0.0";              if (navigator.plugins && navigator.plugins.length) {                 for (x = 0; x < navigator.plugins.length; x++) {                     if (navigator.plugins[x].description.indexOf("Adobe Acrobat") != -1) {                         acrobat.version = parseFloat(navigator.plugins[x].description.split("Version ")[1]);                         if (acrobat.version.toString().length == 1) acrobat.version += ".0";                         acrobat.installed = true;                         displayString = "Acrobat Version: " + acrobat.version;                         break;                     } else if (navigator.plugins[x].description.indexOf("Adobe PDF Plug-In") != -1) {                         acrobat.installed = true;                         acrobat.version = "8+";                         displayString = "Acrobat Version 8 or Above";                     }                 }             } else if (window.ActiveXObject) {                 for (x = 2; x < 10; x++) {                     try {                         oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');");                         if (oAcro) {                             acrobat.installed = true;                              acrobat.version = x + ".0";                             displayString = "Acrobat Version: " + acrobat.version;                         }                     }                     catch (e) { }                 }                  try {                     oAcro4 = new ActiveXObject("PDF.PdfCtrl.1");                     if (oAcro4) {                         acrobat.installed = true;                         acrobat.version = '4.0';                         displayString = 'Acrobat Version: ' + acrobat.version;                     }                 }                 catch (e) { }                  try {                     oAcro7 = new ActiveXObject('AcroPDF.PDF.1');                     if (oAcro7) {                         acrobat.installed = true;                         acrobat.version = '7.0';                         displayString = 'Acrobat Version: ' + acrobat.version;                     }                 }                 catch (e) { }             }              return acrobat;         }

function isAcrobatPluginInstall() {   var flag = false;   // 如果是firefox浏览器   if (navigator.plugins && navigator.plugins.length) {   for (x = 0; x < navigator.plugins.length; x++) {   if (navigator.plugins[x].name == 'Adobe Acrobat')   flag = true;   }   }   // 下面代码都是处理IE浏览器的情况   else if (window.ActiveXObject) {   for (x = 2; x < 10; x++) {   try {   oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');");   if (oAcro) {   flag = true;   }   } catch (e) {   flag = false;   }   }   try {   oAcro4 = new ActiveXObject('PDF.PdfCtrl.1');   if (oAcro4)   flag = true;   } catch (e) {   flag = false;   }   try {   oAcro7 = new ActiveXObject('AcroPDF.PDF.1');   if (oAcro7)   flag = true;   } catch (e) {   flag = false;   }   }   if (flag) {   return true;   } else {   alert("对不起,您还没有安装PDF阅读器软件呢,为了方便预览PDF文档,请选择安装!");   location = 'http://ardownload.adobe.com/pub/adobe/reader/win/9.x/9.3/chs/AdbeRdr930_zh_CN.exe';   }   return flag;   }

转载于:https://my.oschina.net/usenrong/blog/197881

文章来源: https://blog.csdn.net/weixin_34268310/article/details/92028940
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!