javascript - Changing the color based on it's value... take 2 -


similar question last week here.

again, need return value green if it's true , red if it's false. logic right, it's styling won't work, i'm not sure why?

js

    var getacrobatinfo = function () {         var nopdf = 'no pdf viewer installed';          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 || navigator.appversion.indexof('trident/') > 0) {                     return "ie";                 } else if (useragent.indexof("firefox") > -1) {                     return "firefox";                 } else {                     //return "ie";                     return useragent;                 }             }();         };          var getactivexobject = function (name) {             try {                 return new activexobject(name);             } catch (e) { }         };          var getnavigatorplugin = function (name) {             (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') {                     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 nopdf;             }         }          return {acrobat: isacrobatinstalled()};     };      var info = getacrobatinfo();     var pdf = document.getelementbyid('acrobat');      if (info.acrobat) {         pdf.classlist.add('green');         pdf.innerhtml = 'true';     }     else {         pdf.classlist.add('red');         pdf.innerhtml = 'false';     }     } 

html

    <tr>         <td>pdf viewer enabled:</td>         <td id="acrobat"></td>    </tr> 

css

#pdf.green {   color: #33cc33;   font-weight: bold; } #pdf.red {   color: #ff0000;   font-weight: bold; } 


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -