// 判断屏幕是否旋转
    function orientationChange() {
        switch(window.orientation) {
            case 0:
                alert("肖像模式 0,screen-width: " + screen.width + "; screen-height:" + screen.height);
                break;
            case -90:
                alert("左旋 -90,screen-width: " + screen.width + "; screen-height:" + screen.height);
                break;
            case 90:
                alert("右旋 90,screen-width: " + screen.width + "; screen-height:" + screen.height);
                break;
            case 180:
                alert("风景模式 180,screen-width: " + screen.width + "; screen-height:" + screen.height);
                break;
        };};
    // 添加事件监听
    addEventListener('load', function(){
        orientationChange();
        window.onorientationchange = orientationChange;
    });

  

相关文章:

  • 2021-09-22
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2021-12-18
相关资源
相似解决方案