iPad doesn't trigger resize event going from vertical to horizontal?

后端 未结 7 724
醉酒成梦
醉酒成梦 2020-12-08 00:33

Has anyone noticed this behavior? I\'m trying to write a script that will trigger upon a resize. It works fine on normal browsers, works fine on iPhone, but on iPad, will on

7条回答
  •  旧巷少年郎
    2020-12-08 01:22

    1. do a nice check if your platform is iPad,
    2. handle the iOS specific event orientationchange by catching window.onorientationchange

      if(navigator.platform == 'iPad') {
          window.onorientationchange = function() {
              // handle orientationchange event
              // (here you can take advantage of the orientation property
              //     - see the good answer above by Vincent)
          }       
      }
      

提交回复
热议问题