关于方向更改的JavaScript警报会在Android上永远重新开始

时间:2012-05-30 10:56:18

标签: javascript android device-orientation

此代码会在更改移动设备的方向时创建警报。它适用于我的iPhone,但在我的Android上,警报一直在触发,有效地使页面不可行。代码在dom上运行。

function orientation() {

    alert('orientation change');
    // return false;
}   
window.onorientationchange = orientation;

任何人都知道为什么会这样吗?如果有一个解决方案使用它我使用jQuery为这个网站。谢谢

更新 - 此代码完全相同:

var supportsOrientationChange = "onorientationchange" in window, orientationEvent =     supportsOrientationChange ? "orientationchange" : "resize";

  window.addEventListener(orientationEvent, function() {
     alert ('orientation changed');
  }, false);

0 个答案:

没有答案
相关问题