码迷,mamicode.com
首页 > 其他好文 > 详细

页面小功能 - 回到顶部

时间:2015-09-02 23:23:20      阅读:432      评论:0      收藏:0      [点我收藏+]

标签:

<div id="to_top">
<div class="dp_float"><a><img src="${pageContext.request.contextPath}/css/gy/image/dp_icon.png" /><br />回顶部</a></div>
</div>

 

 


<%-- 返回顶部:baoxw --%>
<style>
body{margin:0; padding:0}
#to_top{ padding-bottom:0px;margin:0px; font:14px/20px arial; background:#06c; position:absolute; cursor:pointer; color:#fff}
</style>
<script>
window.onload = function(){
var oTop = document.getElementById("to_top");
var screenw = document.documentElement.clientWidth || document.body.clientWidth;
var screenh = document.documentElement.clientHeight || document.body.clientHeight;
oTop.style.left = screenw - oTop.offsetWidth +"px";
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>
<%-- 返回顶部:baoxw --%>

页面小功能 - 回到顶部

标签:

原文地址:http://www.cnblogs.com/Xiawu168/p/4779583.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!