[英]How can i change Screen Orientation using javascript or Jquery?
I am developing a application using Phonegap for Android and iphone. 我正在使用适用于Android和iPhone的Phonegap开发应用程序。 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 ?
谁能说出如何通过java脚本或jquery完成它?
Thank you 谢谢
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: 另一个ID
window.orientation
其返回0
, 90
或-90
其中:
0
stands for: portrait mode 0
代表:人像模式
90
stands for: landscape mode with the screen turned to the left 90
代表:横向模式,屏幕向左旋转
-90
stands for: landscape mode with the screen turned to the right -90
代表:横向模式,屏幕向右旋转
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. 使用JavaScript来检测浏览器中Android手机的旋转以获取信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.