用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
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
相关文章推荐
- 【进阶android】Volley源码分析——Volley的流程
- web app变革之rem
- Unity Array数组
- Android Handler 异步消息处理机制的妙用 创建强大的图片加载类
- hdu5303(15年多校集训第二轮1004题delicious apple)
- Code Forces 558 A. Lala Land and Apple Trees(水~)
- Unity导入FBX文件部分模型丢失材质的BUG
- iOS Sprite Kit教程之真机测试以及场景的添加与展示
- android学习记录(三)百度地图错误---只有一个电话显示帧,没有地图内容。
- Swift学习笔记(十四)——字符,常量字符串与变量字符串
- Android学习笔记(0)
- MyBasketball 第一篇
- android bindService()
- android imageview围绕中心旋转动画
- iOS 性能优化:Instruments 工具的救命三招
- 测试你的 In-app Billing 程序
- iOS利用Runtime自定义控制器POP手势动画
- iOS DEV info 启动画面 icon
- 【Android】Android布局中实现圆角边框
- iOS tableView索引