页面小功能

<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 --%>

原文地址:https://www.cnblogs.com/rick168/p/4779583.html