admin管理员组文章数量:1391974
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 it can be done through either java script or jquery ?
Thank you
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 it can be done through either java script or jquery ?
Thank you
Share Improve this question asked Jul 20, 2012 at 3:52 tilaktilak 4,7016 gold badges35 silver badges46 bronze badges 3- I think you can't, since neither JavaScript nor jQuery (wrote in JavaScript) can do this as far as I know. – davidbuzatto Commented Jul 20, 2012 at 3:55
- Do you mean "adapt my output to the current screen orientation", not "change the device's screen orientation"? – ryandenki Commented Jul 20, 2012 at 3:59
- You know jQuery can't do anything that JavaScript can't do, right? (Because jQuery is "just" a JavaScript library.) – nnnnnn Commented Jul 20, 2012 at 4:05
1 Answer
Reset to default 6You 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 mode90
stands for: landscape mode with the screen turned to the left-90
stands for: landscape mode with the screen turned to the rightwindow.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.
本文标签: How can i change Screen Orientation using javascript or JqueryStack Overflow
版权声明:本文标题:How can i change Screen Orientation using javascript or Jquery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744658995a2618129.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论