Javascript returns the top source code, and javascript returns the top code.
<div style="display:none" id="goTopBtn"></div>
<script type="text/javascript">function goTopEx(){ var obj=document.getElementById("goTopBtn"); function getScrollTop(){ return document.documentElement.scrollTop || document.body.scrollTop } function setScrollTop(value){document.documentElement.scrollTop = value; document.body.scrollTop = value; } window.onscroll=function(){getScrollTop()>0?obj.style.display="":obj.style.display="none";} obj.onclick=function(){ var goTop=setInterval(scrollMove,10); function scrollMove(){ setScrollTop(getScrollTop()/1.1); if(getScrollTop()<1)clearInterval(goTop); } } }goTopEx();
Implementation 2:
# Scrolltop {
Visibility: hidden;
Position: fixed;
Bottom: 100px;
Display: block;
Margin:-30px 0 0 2px;
Width: 40px;
Background: # f4f4f4;
Border: 1px # cdcdcd solid;
Border-radius: 3px;
Border-top: 0;
Cursor: pointer;
}
# Scrolltop: hover {
Text-decoration: none;
}
. Ie6 # scrolltop {
Position: absolute;
Bottom: auto;
}
# Scrolltop {
Display: block;
Width: 30px;
Height: 24px;
Padding: 3px 5px;
Line-height: 12px;
Text-align: center;
Color: #787878;
Text-decoration: none;
Background: url (http://www.unitymanual.com/static/image/common/scrolltop.png) no-repeat 0 0;
Border-top: 1px # cdcdcd solid;
}
A. scrolltopa: hover {
Background-position:-40px 0px! Important;
}
A. replyfast {
Background-position: 0-30px! Important;
}
A. replyfast: hover {
Background-position:-40px-30px! Important;
}
A. returnlist, a. returnboard {
Background-position: 0-60px! Important;
}
A. returnlist: hover, a. returnboard: hover {
Background-position:-40px-60px! Important;
}
# Scrolltop a B {
Visibility: hidden;
Font-weight: normal;
}
<Div style = "left: auto; right: 0px; visibility: visible;" id = "scrolltop">
<Span hidefocus = "true"> <a title = "Back to Top" onclick = "window. scrollTo ('0', '0') "class =" scrolltopa "> <B> Back to Top </B> </a> </span>
</Div>