jquerymobile: determine device orientation

Chinchan Zu picture Chinchan Zu · May 9, 2012 · Viewed 10.5k times · Source
$(window).bind("orientationchange", function(e){
   var ow = (e.orientation=="portrait" ? "縦" : "横");
   alert("端末の向きは "+ow+" です。");
});

using the above code, i could determine if the device is in portrait or landscape mode. But my question is, is it possible to determine which side on the landscape (landscape right/ landscape left) is the device tilted, also if the device is upsidedown?

thanks guys for the support.

Answer

Hupperware picture Hupperware · May 31, 2012
$(window).bind('orientationchange', function() {
   alert(window.orientation);
});
  • 0 = Portrait orientation. This is the default value
  • -90 = Landscape orientation with the screen turned clockwise
  • 90 = Landscape orientation with the screen turned counterclockwise
  • 180 = Portrait orientation with the screen turned upside down