您的位置:首页 > 其它

回到顶部的功能

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