我正在使用适用于Android和iPhone的Phonegap开发应用程序.从一页导航到另一页时,我需要更改屏幕方向.谁能说出如何通过java脚本或jquery完成它?
谢谢
解决方法:
您可以尝试以下方法:
$(window).resize(function() {
var height = $(window).height();
var width = $(window).width();
if (width > height) {
// Landscape
$("#mode").text("LANDSCAPE");
} else {
// Portrait
$("#mode").text("PORTRAIT");
}
});
@H_502_12@
另一个id window.orientation返回0、90或-90,其中:
> 0代表:人像模式
> 90代表:横向模式,屏幕向左旋转
> -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;
}
}
@H_502_12@
你也可以看到
信息Detect rotation of Android phone in the browser with JavaScript.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。