Reputation: 918
$(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.
Upvotes: 4
Views: 10560
Reputation: 16504
Most simple answer: Get the orientation (at any time in your js code) via
window.orientation
When window.orientation
returns 0
or 180
then you are in portrait mode, when returning 90
or 270
then you are in landscape mode.
Upvotes: 1
Reputation: 35
I would take into consideration this post:
http://www.matthewgifford.com/2011/12/22/a-misconception-about-window-orientation/
Upvotes: 1
Reputation: 979
$(window).bind('orientationchange', function() {
alert(window.orientation);
});
Upvotes: 8