我试图检测移动设备,iPhone和iPad的方向更改。orientationchange事件不起作用
我使用下面的代码:
$(window).bind("orientationchange", function (event) {
alert(event.orientation);
position = $.event.special.orientationchange.orientation();
event.preventDefault();
});
这里戒备即event.orientation的值显示为“未定义”,其中正如我在一些后已阅读,它以检测取向支持。 另外在jQuery文档中,它被写入更好地使用“event.orientation”而不是“window.orientation”,但没有一个返回所需的结果,都返回“undefined”。
所以我用“$ .event.special.orientationchange.orientation();”检测方向。
但我想使用jquery文档中定义的功能作为event.orientation。如link
同样在我的代码中,“$ .mobile.orientationChangeEnabled”设置为true,如上面的链接所示。
请给我建议任何可能的解决方案。
任何帮助,将不胜感激。
在此先感谢。