安卓2.3系统webview不支持网页的div滚动条,各位有解决方法么
2.3系统中用webview打开网页时,里面有个div带滚动条的,但是在平板上滚动条失效,求解
温文尔雅的十八
12 years, 6 months ago
Answers
android2.3的不支持滚动条,并且scrollTop也不支持的。(设置overflow未hidden就可以支持)。
给你个方法保准OK,望采纳:
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);
总体思路:即屏蔽了系统自身的滑动,用y坐标来实现的。
Nikusyo
answered 12 years, 6 months ago