页面中到达顶部和底部的按钮
2015-06-02 21:04
281 查看
到达页面顶部 方法1: 在body标签下面放<a href="" name='top' id='top'></a> 在页面底部放<a href="#top">返回顶部</a> 方法2:在需要返回顶部的地方放<a href="javascript:scrollTo(0,0);">返回顶部</a> ps:scrollto(x,y)x,y表示左上角的偏移量 方法3: 不同于前面2个,缓慢移动到顶部。 <a href="javascript:gotop()" class="">gotop</a>放在页面中需要的位置 js 在下面 var timer=null; function gotop() { timer=setInterval(function () { if($(document).scrollTop()>0){ window.scrollBy(0,-100); }else{ clearInterval(timer); } },40) } 到达页面底部 方法1:缓慢到达 <a href="javascript:gobutton();">返回顶部</a> js 在下面 var timer=null; function gobutton() { timer=setInterval(function () { if($(document).scrollTop()<$(document).height()-$(window).height()){ window.scrollBy(0,100); }else{ clearInterval(timer); } },40) }
View Code
相关文章推荐
- hdu - 2645 find the nearest station (bfs水)
- 手机电池
- redis 模糊查询?
- python lambda表达式
- python sort and sorted
- C语言初探 之 printf压栈顺序(printf("%d %d %d %d %d %d\n",a++, ++a, a++, ++a, a++, ++a ))
- google blog (易經大意 登載)
- vim编辑器详解
- Mac电脑下配置maven环境变量
- openLTE编译cmake时出错,not found gnuradio
- Windows7下安装MongoDB
- 会员卡管理系统技术解析(十一)会员卡作废记录查询
- Android与MVC设计模式
- 实现医生工作站的处方模板功能的代码(十一)
- 谱聚类--SpectralClustering
- oracle用户密码过期的处理方法
- 在IDL中调用自定义Python Module
- Block 介绍
- 伪列 伪表
- C语言学习-01第一个C语言程序