1. 在style.css中添加如下代码

/**返回顶部**/
#gotop{
width:45px;
height:45px;
position:fixed;
bottom:25px;
right:125px;
top:auto;
display:block;
cursor:pointer;
background: url(p_w_picpaths/top.gif) no-repeat
}
*html #gotop{
position:absolute;
bottom:auto; top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
}

css-300x54.png

2. 在footer.php中添加如下代码

<!– 返回顶部 –>
<div style=”display: none;” id=”gotop”></div>
<script type=’text/javascript’>
backTop=function (btnId){
var btn=document.getElementById(btnId);
var d=document.documentElement;
var b=document.body;
window.οnscrοll=set;
btn. (){
btn.style.display=”none”;
window.οnscrοll=null;
this.timer=setInterval(function(){
d.scrollTop-=Math.ceil((d.scrollTop+b.scrollTop)*0.1);
b.scrollTop-=Math.ceil((d.scrollTop+b.scrollTop)*0.1);
if((d.scrollTop+b.scrollTop)==0) clearInterval(btn.timer,window.οnscrοll=set);
},10);
};
function set(){btn.style.display=(d.scrollTop+b.scrollTop>100)?’block’:”none”}
};
backTop(‘gotop’);
</script>
<!– 返回顶部END –>

footer-300x117.png

3. 添加返回顶部按钮图片

把返回顶部按钮,上传到主题目录的p_w_picpaths目录下:

top.gif

本文固定链接: http://www.test-life.org/?p=718 | 软件开发测试之路-Test Space