Android不支持web页滚动

来源:互联网 发布:杭州橙群网络怎么样 编辑:程序博客网 时间:2024/05/29 13:38

Android不支持web页滚动,以下答案来源网络其他人的回答,德问网上有。

测试以下方法可行。

function noBarsOnTouchScreen(arg){  var elem, tx, ty;  if('ontouchstart' in document.documentElement ) {          if (elem = document.getElementById(arg)) {              elem.style.overflow = 'hidden';              elem.ontouchstart = ts;              elem.ontouchmove = tm;          }  }  function ts( e )  {    var tch;    if(  e.touches.length == 1 )    {      e.stopPropagation();      tch = e.touches[ 0 ];      tx = tch.pageX;      ty = tch.pageY;    }  }  function tm( e )  {    var tch;    if(  e.touches.length == 1 )    {      e.preventDefault();      e.stopPropagation();      tch = e.touches[ 0 ];      this.scrollTop +=  ty - tch.pageY;      ty = tch.pageY;    }  }}//调用的时候:noBarsOnTouchScreen(divId);

0 0
原创粉丝点击