Tiggles ツ
10/16/2017 - 1:54 PM

[Dynamic Body Class] Detect OS and device and add to the class of the body. Put this in the doc.ready #javascript

[Dynamic Body Class] Detect OS and device and add to the class of the body. Put this in the doc.ready #javascript

    /* ==========================================================================
      adds browser/OS to body class
      ========================================================================== */
      
        $.each($.browser, function(i) {
          $('body').addClass(i);
          return false;
        });

        var os = [
          'iphone',
          'ipad',
          'windows',
          'mac',
          'linux'
        ];

        var match = navigator.appVersion.toLowerCase().match(new RegExp(os.join('|')));
        if (match) {
          $('body').addClass(match[0]);
        }