我試圖檢測移動設備,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,如上面的鏈接所示。
請給我建議任何可能的解決方案。
任何幫助,將不勝感激。
在此先感謝。