Posted By

Freese on 03/21/10


Tagged

web


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

RM


Browser Detection + Apply Classes to HTML Element


 / Published in: JavaScript
 

  1. // jQBrowser v0.2: http://davecardwell.co.uk/javascript/jquery/plugins/jquery-browserdetect/
  2. eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(c/a))+String.fromCharCode(c%a+161)};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('Ö ¡(){® Ø={'¥':¡(){¢ £.¥},'©':{'±':¡(){¢ £.©.±},'¯':¡(){¢ £.©.¯}},'¬':¡(){¢ £.¬},'':¡(){¢ £.¶},'º':¡(){¢ £.º},'':¡(){¢ £.Á},'':¡(){¢ £.À},'½':¡(){¢ £.½},'¾':¡(){¢ £.¾},'¼':¡(){¢ £.¼},'·':¡(){¢ £.·},'':¡(){¢ £.Â},'³':¡(){¢ £.³},'':¡(){¢ £.Ä},'':¡(){¢ £.Ã},'':¡(){¢ £.Å},'¸':¡(){¢ £.¸}};$.¥=Ø;® £={'¥':'¿','©':{'±':²,'¯':'¿'},'¬':'¿','':§,'º':§,'':§,'':§,'½':§,'¾':§,'¼':§,'·':§,'':§,'³':§,'':§,'':§,'':§,'¸':§};Î(® i=0,«=».ì,°=».í,¦=[{'¤':'','¥':¡(){¢/Ù/.¨(°)}},{'¤':'','¥':¡(){¢ Û.³!=²}},{'¤':'','¥':¡(){¢/È/.¨(°)}},{'¤':'','¥':¡(){¢/Þ/.¨(°)}},{'ª':'','¤':'ß Ñ','¥':¡(){¢/à á â/.¨(«)},'©':¡(){¢ «.¹(/ã(\d+(?:\.\d+)+)/)}},{'¤':'','¥':¡(){¢/Ì/.¨(«)}},{'¤':'','¥':¡(){¢/Í/.¨(°)}},{'¤':'','¥':¡(){¢/Ï/.¨(«)}},{'¤':'Ð','¥':¡(){¢/Ð/.¨(«)}},{'ª':'·','¤':'å Ñ','¥':¡(){¢/Ò/.¨(«)},'©':¡(){¢ «.¹(/Ò (\d+(?:\.\d+)+(?:b\d*)?)/)}},{'¤':'','¥':¡(){¢/æ|Ó/.¨(«)},'©':¡(){¢ «.¹(/è:(\d+(?:\.\d+)+)/)}}];i<¦.Ë;i++){µ(¦[i].¥()){® ª=¦[i].ª?¦[i].ª:¦[i].¤.Õ();£[ª]=É;£.¥=¦[i].¤;® ­;µ(¦[i].©!=²&&(­=¦[i].©())){£.©.¯=­[1];£.©.±=Ê(­[1])}ê{® Ç=Ö ë(¦[i].¤+'(?:\\s|\\/)(\\d+(?:\\.\\d+)+(?:(?:a|b)\\d*)?)');­=«.¹(Ç);µ(­!=²){£.©.¯=­[1];£.©.±=Ê(­[1])}}×}};Î(® i=0,´=».ä,¦=[{'ª':'¸','¤':'','¬':¡(){¢/é/.¨(´)}},{'¤':'','¬':¡(){¢/Ô/.¨(´)}},{'¤':'Æ','¬':¡(){¢/Æ/.¨(´)}}];i<¦.Ë;i++){µ(¦[i].¬()){® ª=¦[i].ª?¦[i].ª:¦[i].¤.Õ();£[ª]=É;£.¬=¦[i].¤;×}}}();',77,77,'function|return|Private|name|browser|data|false|test|version|identifier|ua|OS|result|var|string|ve|number|undefined|opera|pl|if|aol|msie|win|match|camino|navigator|mozilla|icab|konqueror|Unknown|flock|firefox|netscape|linux|safari|mac|Linux|re|iCab|true|parseFloat|length|Flock|Camino|for|Firefox|Netscape|Explorer|MSIE|Mozilla|Mac|toLowerCase|new|break|Public|Apple|Opera|window|Konqueror|Safari|KDE|AOL|America|Online|Browser|rev|platform|Internet|Gecko|Windows|rv|Win|else|RegExp|userAgent|vendor'.split('|')))
  3.  
  4. /* ----------------------------------------------------------------- */
  5.  
  6. var aol = $.browser.aol(); // AOL Explorer
  7. var camino = $.browser.camino(); // Camino
  8. var firefox = $.browser.firefox(); // Firefox
  9. var flock = $.browser.flock(); // Flock
  10. var icab = $.browser.icab(); // iCab
  11. var konqueror = $.browser.konqueror(); // Konqueror
  12. var mozilla = $.browser.mozilla(); // Mozilla
  13. var msie = $.browser.msie(); // Internet Explorer Win / Mac
  14. var netscape = $.browser.netscape(); // Netscape
  15. var opera = $.browser.opera(); // Opera
  16. var safari = $.browser.safari(); // Safari
  17.  
  18. var userbrowser = $.browser.browser(); //detected user browser
  19.  
  20. //operating systems
  21.  
  22. var linux = $.browser.linux(); // Linux
  23. var mac = $.browser.mac(); // Mac OS
  24. var win = $.browser.win(); // Microsoft Windows
  25.  
  26. //version
  27.  
  28. var userversion = $.browser.version.number();
  29.  
  30. /* ----------------------------------------------------------------- */
  31.  
  32. if (mac == true) {
  33.  
  34. $("html").addClass("mac");
  35.  
  36. } else if (linux == true) {
  37.  
  38. $("html").addClass("linux");
  39.  
  40. } else if (win == true) {
  41.  
  42. $("html").addClass("windows");
  43.  
  44. }
  45.  
  46. /* ----------------------------------------------------------------- */
  47.  
  48. if (userbrowser == "Safari") {
  49.  
  50. $("html").addClass("safari");
  51.  
  52. } else if (userbrowser == "Firefox") {
  53.  
  54. $("html").addClass("firefox");
  55.  
  56. } else if (userbrowser == "Camino") {
  57.  
  58. $("html").addClass("camino");
  59.  
  60. } else if (userbrowser == "AOL Explorer") {
  61.  
  62. $("html").addClass("aol");
  63.  
  64. } else if (userbrowser == "Flock") {
  65.  
  66. $("html").addClass("flock");
  67.  
  68. } else if (userbrowser == "iCab") {
  69.  
  70. $("html").addClass("icab");
  71.  
  72. } else if (userbrowser == "Konqueror") {
  73.  
  74. $("html").addClass("konqueror");
  75.  
  76. } else if (userbrowser == "Mozilla") {
  77.  
  78. $("html").addClass("mozilla");
  79.  
  80. } else if (userbrowser == "Netscape") {
  81.  
  82. $("html").addClass("netscape");
  83.  
  84. } else if (userbrowser == "Opera") {
  85.  
  86. $("html").addClass("opera");
  87.  
  88. } else if (userbrowser == "Internet Explorer") {
  89.  
  90. $("html").addClass("ie");
  91.  
  92. } else {}
  93.  
  94. $("html").addClass("" + userversion + "");

Report this snippet  

You need to login to post a comment.