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
  • 相关阅读:
    Linux开发初探
    Linux开发初探
    电脑使用说明书
    电脑使用说明书
    Delegates, Events, and Anonymous Methods 委托、事件与匿名方法
    CSS haslayout
    js与flash结合使用
    sgen.exe" exited with code 1.解决方法
    selenium
    selenium支付高版本的FireFox
  • 原文地址:https://www.cnblogs.com/diony/p/4679683.html
Copyright © 2011-2022 走看看