Skip to content

Instantly share code, notes, and snippets.

@gpessia
Created May 16, 2012 11:50
Show Gist options
  • Save gpessia/2709785 to your computer and use it in GitHub Desktop.
Save gpessia/2709785 to your computer and use it in GitHub Desktop.
iPad / iPhone on orientation change
window.onorientationchange = function(){
var orientation = window.orientation;
// Look at the value of window.orientation:
if (orientation === 0){
// iPad is in Portrait mode.
}
else if (orientation === 90){
// iPad is in Landscape mode. The screen is turned to the left.
}
else if (orientation === -90){
// iPad is in Landscape mode. The screen is turned to the right.
}
else if (orientation === 180){
// Upside down portrait.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment