zoukankan      html  css  js  c++  java
  • 用webview打开网页时,里面有个div带滚动条的,但是在平板上滚动条失效

    android2.3的不支持滚动条,并且scrollTop也不支持的。(设置overflow未hidden就可以支持)。
    function noBarsOnTouchScreen(arg)
    {
     

    var elem, tx, ty;

      if('ontouchstart' in document.documentElement ) {
              if (elem = document.getElementByIdx_x(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);
    来源:http://www.myexception.cn/web/411975.html
  • 相关阅读:
    百度--买帽子
    网易--双核处理器
    京东--通过考试
    简单错误记录
    链表中的倒数第k个结点
    数值的整数次方
    二进制中1的个数
    TCP 三次握手
    旋转数组的最小数字
    用两个栈实现队列
  • 原文地址:https://www.cnblogs.com/diony/p/4679683.html
Copyright © 2011-2022 走看看