detect - Detecting Adobe Reader in ie11 with JavaScript -


i trying detect adobe reader plugin ie11, reason returns null. lead believe because ie11 doesn't use same plugin name older versions of internet explorer, not sure.

i got code directly site (a user website!): http://thecodeabode.blogspot.com/2011/01/detect-adobe-reader-plugin.html

the code works brilliantly until ie11 on windows 7, returns null in getacrobatversion.

here full code it's easier all:

var getacrobatinfo = function() {        var getbrowsername = function() {         return this.name = this.name || function() {           var useragent = navigator ? navigator.useragent.tolowercase() : "other";            if(useragent.indexof("chrome") > -1)        return "chrome";           else if(useragent.indexof("safari") > -1)   return "safari";           else if(useragent.indexof("msie") > -1)     return "ie";           else if(useragent.indexof("firefox") > -1)  return "firefox";           return useragent;         }();       };        var getactivexobject = function(name) {         try { return new activexobject(name); } catch(e) {}       };        var getnavigatorplugin = function(name) {         for(key in navigator.plugins) {           var plugin = navigator.plugins[key];           if(plugin.name == name) return plugin;         }       };        var getpdfplugin = function() {         return this.plugin = this.plugin || function() {           if(getbrowsername() == 'ie') {             //             // load activex control             // acropdf.pdf used version 7 , later             // pdf.pdfctrl used version 6 , earlier             return getactivexobject('acropdf.pdf') || getactivexobject('pdf.pdfctrl');           }           else {             return getnavigatorplugin('adobe acrobat') || getnavigatorplugin('chrome pdf viewer') || getnavigatorplugin('webkit built-in pdf');           }         }();       };        var isacrobatinstalled = function() {         return !!getpdfplugin();       };        var getacrobatversion = function() {         try {           var plugin = getpdfplugin();            if(getbrowsername() == 'ie') {             var versions = plugin.getversions().split(',');             var latest   = versions[0].split('=');             return parsefloat(latest[1]);           }            if(plugin.version) return parseint(plugin.version);           return plugin.name          }         catch(e) {           return null;         }       }       // returned object       return {         browser:        getbrowsername(),         acrobat:        isacrobatinstalled() ? 'installed' : false,         acrobatversion: getacrobatversion()       };     };      var info = getacrobatinfo();     if(info.acrobat){         //ie11 return false if have adobe reader because it's terrible browser.         document.write('<img src="img/syschkerr.gif" alt="" border="0">');         document.write('<span style="color: ' + errcol + '"><strong>not installed</strong></span>');         document.write('<br /><br />some of our applications require adobe reader. can download adobe reader ');         document.write('<a href="http://get.adobe.com/reader/" target="_blank">here</a>.');     }else{         document.write('<img src="img/syschkpas.gif" alt="" border="0">');         document.write('<span style="color: ' + pascol + '"><strong>installed</strong></span>');         document.write('<br /><br />version ' + info.acrobatversion + ' installed.');     } 

if(useragent.indexof("msie") > -1) no longer job in ie11 because the user agent string has changed. ie11, have trident.

mediaelement.js worked around this so:

t.isie = (nav.appname.match(/microsoft/gi) !== null) || (ua.match(/trident/gi) !== null); 

so guess might trick you?

  else if(useragent.indexof("msie") > -1 || useragent.indexof("trident") > -1)  return "ie"; 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -