Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MiguelDebruyne/10821062 to your computer and use it in GitHub Desktop.
Save MiguelDebruyne/10821062 to your computer and use it in GitHub Desktop.
JavaScript: Detect Mobile Browser
if(jQuery.browser)
{
/* SmileyWar.com Mobile Orientation Detection */
// set rules on initial load and when the screen changes size or orientation.
$(window).on("load resize",function(){
var h = $(window).height();
var w = $(window).width();
if ( w < 768) {
// small mobile screens
if(w > h) {
// small mobile screens landscape rules
}else{
// small mobile screens portrait rules
}
// all small screen rules
}else{
// large mobile screens
if(w > h) {
// large mobile screen landscape rules
}else{
// large mobile screen portrait rules
}
// all large mobile screen rules
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment