回到顶部的功能
2016-07-19 11:38
405 查看
<a class="totop" id="to_top"></a> <script> /*回到顶部的功能*/ window.onload = function(){ var oTop = document.getElementById("to_top"); var screenh = document.documentElement.clientHeight || document.body.clientHeight; oTop.style.top = screenh - oTop.offsetHeight + "px"; window.onscroll = function(){ var scrolltop = document.documentElement.scrollTop || document.body.scrollTop; oTop.style.top = screenh - oTop.offsetHeight + scrolltop +"px"; } oTop.onclick = function(){ document.documentElement.scrollTop = document.body.scrollTop =0; } } </script>
相关文章推荐
- 通过二叉树的遍历理解递归
- ubuntu上安装vim编译器
- 39 二叉树的深度和宽度以及判断是否是平衡二叉树
- Dockerfile详解
- 前端html5
- [C#][.net 4]Task 代码示例
- hibernate中的属性参数详解
- 34.A user, who is authenticated externally, logs in to a remote machine and connects to the database
- Baas
- 支付宝开发详解
- caffe源码阅读5-各种layer概述
- 安装火焰图生成工具
- javascript性能优化-repaint和reflow
- MapReduce:详解Shuffle过程
- 安卓jni开发demo
- iOS-NSTimer-pause-暂停-引用循环
- CodeForces 691C Exponential notation(模拟)
- java中final、static使用方法总结
- mongodb you can't add a second 问题
- Installing Wine on Mac OS X