I am developing a application using Phonegap for Android and iphone. I need to change the screen orientation when i am navigating from one page to another. Can any one tell how
You can try this:
$(window).resize(function() {
var height = $(window).height();
var width = $(window).width();
if (width > height) {
// Landscape
$("#mode").text("LANDSCAPE");
} else {
// Portrait
$("#mode").text("PORTRAIT");
}
});
Another one id window.orientation
which return 0
, 90
or -90
where:
0
stands for: portrait mode
90
stands for: landscape mode with the screen turned to the left
-90
stands for: landscape mode with the screen turned to the right
window.onorientationchange = function()
{
var orientation = window.orientation;
switch(orientation) {
case 0:
//Top side up.
break;
case -90:
//Left side up (turned 90 degrees to the right)
break;
case 90:
//Right side up (turned 90 degrees to the left)
break;
}
}
You can also see
Detect rotation of Android phone in the browser with JavaScript for info.