window.addEventListener("orientationchange", function() { // Announce the new orientation number alert(window.orientation); }, false);
上面这段代码,给通过添加一个事件监听器,探测方向的变更,值为0表示,正常的拿着手机,-90表示向右,90表示向左。
window.addEventListener("orientationchange", function() { // Announce the new orientation number alert(window.orientation); }, false);
转载于:https://www.cnblogs.com/phpcode/archive/2012/04/20/2522754.html