Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquerymobile: determine device orientation

$(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.

like image 319
Chinchan Zu Avatar asked Dec 27 '22 01:12

Chinchan Zu


2 Answers

$(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
like image 77
Hupperware Avatar answered Jan 08 '23 18:01

Hupperware


I would take into consideration this post:

http://www.matthewgifford.com/2011/12/22/a-misconception-about-window-orientation/

like image 31
moimikey Avatar answered Jan 08 '23 17:01

moimikey