html - how to detect distro / os to apply css -


i using <!--[if statement detect type of browser user has realized same browser (version , build) can produce different result on different operating systems. safari shows ok on windows distorted on ubuntu. best way detect specific browser specific os, ubuntu or debian?

ppk has great method that:

var browserdetect = {     init: function () {         this.browser = this.searchstring(this.databrowser) || "an unknown browser";         this.version = this.searchversion(navigator.useragent)             || this.searchversion(navigator.appversion)             || "an unknown version";         this.os = this.searchstring(this.dataos) || "an unknown os";     },     searchstring: function (data) {         (var i=0;i<data.length;i++) {             var datastring = data[i].string;             var dataprop = data[i].prop;             this.versionsearchstring = data[i].versionsearch || data[i].identity;             if (datastring) {                 if (datastring.indexof(data[i].substring) != -1)                     return data[i].identity;             }             else if (dataprop)                 return data[i].identity;         }     },     searchversion: function (datastring) {         var index = datastring.indexof(this.versionsearchstring);         if (index == -1) return;         return parsefloat(datastring.substring(index+this.versionsearchstring.length+1));     },     databrowser: [         {             string: navigator.useragent,             substring: "chrome",             identity: "chrome"         },         {   string: navigator.useragent,             substring: "omniweb",             versionsearch: "omniweb/",             identity: "omniweb"         },         {             string: navigator.vendor,             substring: "apple",             identity: "safari",             versionsearch: "version"         },         {             prop: window.opera,             identity: "opera",             versionsearch: "version"         },         {             string: navigator.vendor,             substring: "icab",             identity: "icab"         },         {             string: navigator.vendor,             substring: "kde",             identity: "konqueror"         },         {             string: navigator.useragent,             substring: "firefox",             identity: "firefox"         },         {             string: navigator.vendor,             substring: "camino",             identity: "camino"         },         {       // newer netscapes (6+)             string: navigator.useragent,             substring: "netscape",             identity: "netscape"         },         {             string: navigator.useragent,             substring: "msie",             identity: "explorer",             versionsearch: "msie"         },         {             string: navigator.useragent,             substring: "gecko",             identity: "mozilla",             versionsearch: "rv"         },         {       // older netscapes (4-)             string: navigator.useragent,             substring: "mozilla",             identity: "netscape",             versionsearch: "mozilla"         }     ],     dataos : [         {             string: navigator.platform,             substring: "win",             identity: "windows"         },         {             string: navigator.platform,             substring: "mac",             identity: "mac"         },         {                string: navigator.useragent,                substring: "iphone",                identity: "iphone/ipod"         },         {             string: navigator.platform,             substring: "linux",             identity: "linux"         }     ]  }; browserdetect.init(); 

and have browserdetect object:

alert(browserdetect.os); alert(browserdetect.browser); 


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -