javascript - Using navigator.plugins to determine Java version -


the following javascript code inform browser's enabled plugins (yeah, know doesn't work on ie, ie there's deployjava):

if ((navigator.plugins) && (navigator.plugins.length)) {      (var bb = 0, l = navigator.plugins.length; bb < l; bb++) {        var vv = navigator.plugins[bb].name + "<br>";         document.write(vv);      }    }

i have java 6.22 installed relevant line written page this:
java(tm) platform se 6 u22

my question is: how can complement above code returns major version (6) , update (22) found in (or anyone's) browser?

i think best way work regular expression, not it.

i think easiest (read: hackiest) solution this:

var plugin_name = navigator.plugins[bb].name if (plugin_name.tolowercase().indexof("java") != -1) {     var parts = plugin_name.split(" ").reverse();     // if plugin has update     if(plugin_name.match(/u[0-9]+/)) {         // grab end of plugin name , remove non numeric chars         var update = parts[0].replace(/[^0-9]/, "");         // grab major version , remove non numeric chars         var major = parts[1].replace(/[^0-9]/, "");         // print major number , update number         console.log(major);         console.log(update);     } else {         var update = "0";         // grab major version , remove non numeric chars         var major = parts[0].replace(/[^0-9]/, "");         // print major number , update number         console.log(major);         console.log(update);     }   } 

you can throw code in loop through plugins , replace console.log whatever logic appropriate given major , update number.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -