我正在使用jquery-mobile,似乎它没有检测到景观设置。我在用什么:
来自Xcode Version 4.1 Build 4B110的iphone模拟器版本4.3(238.2) jquery mobile我试图在我的mobile.js
中这样做$(window).bind('orientationchange resize', function(event){
alert(event.orientation)
})
并且转动模拟器只是在显然应该是风景时给我一个说“肖像”的警报。
我在这里做错了吗?我还尝试在我们的jammit调用中使用媒体查询:<%= include_stylesheet :landscape, :media => "all and (orientation: landscape)" %>
但无济于事。我在这里做错了吗?
主要的错误是即使在转动iphone时,显示屏仍然保持纵向宽度。
答案 0 :(得分:0)
我在jQM b2 js文件中找到了这个:
JS:
alert('Orientation: ' + jQuery.event.special.orientationchange.orientation());
这是函数本身:
// Get the current page orientation. This method is exposed publicly, should it
// be needed, as jQuery.event.special.orientationchange.orientation()
$.event.special.orientationchange.orientation = get_orientation = function() {
var elem = document.documentElement;
return elem && elem.clientWidth / elem.clientHeight < 1.1 ? "portrait" : "landscape";
};