您的位置:首页 > 移动开发

用webview打开网页时,里面有个div带滚动条的,但是在平板上滚动条失效

2015-07-27 11:29 393 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: