Recognize iOS devices and react to different orientations.
var isiPad = navigator.userAgent.match(/iPad/i);
var isiPhone = navigator.userAgent.match(/iPhone/i);
var orientation = 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.
}