【发布时间】:2012-06-19 15:08:16
【问题描述】:
我正在尝试检测移动设备、iphone 和 ipad 中的方向变化。
我正在使用以下代码:
$(window).bind("orientationchange", function (event) {
alert(event.orientation);
position = $.event.special.orientationchange.orientation();
event.preventDefault();
});
这里的警报值,即 event.orientation 显示为“未定义”,正如我在一些帖子中读到的那样,它确实支持检测方向。 同样在 jquery 文档中,它被编写为更好地使用“event.orientation”而不是“window.orientation”,但这些都没有返回所需的结果,都返回“未定义”。
所以我使用了“$.event.special.orientationchange.orientation();”检测方向。
但我想将 jquery 文档中定义的功能用作 event.orientation。如link
另外,在我的代码中,“$.mobile.orientationChangeEnabled”设置为 true,如上面的链接所示。
请为此建议我任何可能的解决方案。
任何帮助将不胜感激。
提前致谢。
【问题讨论】:
标签: jquery-mobile orientation screen-orientation