`

js如何判断用户晃动手机的方向

 
阅读更多
function doOnOrientationChange()
  {
    switch(window.orientation)
    { 
      case -90:
      case 90:
        alert('landscape');
        break;
      default:
        alert('portrait');
        break;
    }
  }

  window.addEventListener('orientationchange', doOnOrientationChange);

  // Initial execution if needed
  doOnOrientationChange();
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics