把代码添加到第三方:
[CSS] 纯文本查看 复制代码 <style>
#pam {
position: fixed;
display: none;
bottom: 4px;
height: 53px;
right: 4px;
width: 53px;
_position: absolute;
_top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
}
#pam .top_img {
display: block;
height: 50px;
width: 50px;
background: url("https://boonkiong.com/b/p/top.png") no-repeat;
}
#pam .top_img:hover {
background-position: center bottom;
}
</style>
<div id="pam" style="display: block;"><a class="top_img" href="#"></a></div>
<script language="javascript"
type="text/javascript">
function
getScroll(id){
var obj =
document.getElementById(id);
var timer =
null;
positionFixed(obj);
if(obj){
obj.style.display =
'none';
window.onscroll=function(){
getScrollTop() > 0 ? obj.style.display = "block" :
obj.style.display = "none";
}
obj.onclick=function(){
var timer = setInterval(sMove,10);
function sMove(){
setScrollTop(getScrollTop() / 1.5);
if(getScrollTop() <
1)clearInterval(timer);
}
}
}
}
//判断IE6
function
positionFixed(obj){
var iE6 = !-[1,] &&
!window.XMLHttpRequest;
if(obj){
}
}
//获取滚动条Top
function
getScrollTop(){
return document.documentElement.scrollTop
|| document.body.scrollTop;
}
//回到顶部
function
setScrollTop(value){
document.documentElement.scrollTop =
value;
document.body.scrollTop =
value;
}
window.onload = function(){
getScroll('pam');
};
</script>
|