Skip to content

Instantly share code, notes, and snippets.

@agustibr
Created May 23, 2013 00:55
Show Gist options
  • Save agustibr/5632072 to your computer and use it in GitHub Desktop.
Save agustibr/5632072 to your computer and use it in GitHub Desktop.
Detect iOS devices orientation with jQuery
/*
* http://pixelhunter.me/post/28843693624/detect-orientation-jquery
*/
function checkMode() {
var o = window.orientation;
if (o != 90 && o != -90) {
// here goes code for portrait...
} else {
// here goes for landscape...
}
}
// check orientation on page load
checkMode();
// listen for orientation changes
$(window).bind('orientationchange', function() {
checkMode();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment