在肖像模式iPad/iPhone时禁用jQuery



如何在肖像模式下禁用我的jQuery水平滑块?这让我发疯,因为我不知道任何JavaScript,所以我不知道该怎么做。

谢谢,wouter


-edit-
这是JavaScript:JavaScript

这是大卫·沃尔什(David Walsh)的解决方案:

window.addEventListener("orientationchange", function() {
  if(window.orientation == 0 || window.orientation == 180){ //this is portrait
    //disable the slider here.
  }
  else{
    //enable the slider here
  }
}, false);

在这些更改期间,窗口。取向属性可能会更改。A 值0 [或180]表示肖像视图,-90表示设备是景观 向右旋转,90表示该设备是景观旋转到 左。

最新更新