Skip to content

Instantly share code, notes, and snippets.

@ctcherry
Forked from KruegerDesigns/ios.html.class.js
Created February 1, 2012 18:28
Show Gist options
  • Select an option

  • Save ctcherry/1718490 to your computer and use it in GitHub Desktop.

Select an option

Save ctcherry/1718490 to your computer and use it in GitHub Desktop.

Revisions

  1. ctcherry revised this gist Feb 1, 2012. 1 changed file with 22 additions and 8 deletions.
    30 changes: 22 additions & 8 deletions iOSclass
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,24 @@
    // adds ios class to html tag
    // adds mobile class, and mobile os to html tag
    jQuery(document).ready(function($){
    var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
    if (agentID) {

    $('html').addClass('ios');

    }
    var deviceAgent = navigator.userAgent.toLowerCase();

    if (deviceAgent.match(/(iphone|ipod|ipad)/)) {
    $('html').addClass('ios');
    $('html').addClass('mobile');
    }

    if (deviceAgent.match(/android/)) {
    $('html').addClass('android');
    $('html').addClass('mobile');
    }

    if (deviceAgent.match(/blackberry/)) {
    $('html').addClass('blackberry');
    $('html').addClass('mobile');
    }

    if (deviceAgent.match(/(symbianos|^sonyericsson|^nokia|^samsung|^lg)/)) {
    $('html').addClass('mobile');
    }

    });
  2. Adam Krueger created this gist Feb 1, 2012.
    10 changes: 10 additions & 0 deletions iOSclass
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    // adds ios class to html tag
    jQuery(document).ready(function($){
    var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
    if (agentID) {

    $('html').addClass('ios');

    }
    });