在纵向模式iPad / iPhone时禁用Jquery

时间:2012-10-26 20:05:33

标签: javascript jquery html css

如何在纵向模式下禁用我的jquery水平滑块? 它让我疯狂,因为我不知道任何javascript,所以我不知道该怎么做。

谢谢, 沃特


CNC中
这是Javascript: Javascript

1 个答案:

答案 0 :(得分:3)

以下是来自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);
  

在这些更改期间,window.orientation属性可能会更改。一个   值为0 [或180]表示纵向视图,-90表示设备为横向   向右旋转,90表示设备横向旋转到   左边。

相关问题