First copy the following code into HTML, and run to see the effect
Copy Code code as follows:
<script type= "Text/javascript" >
var Currentposition,timer;
function Gotop () {
Timer=setinterval ("Runtotop ()", 1);
}
function Runtotop () {
Currentposition=document.documentelement.scrolltop | | Document.body.scrollTop;
currentposition-=10;
if (currentposition>0)
{
Window.scrollto (0,currentposition);
}
Else
{
Window.scrollto (0,0);
Clearinterval (timer);
}
}
</script>
<style type= "Text/css" >
</style>
<body>
<div style= "Height:1000px;text-align:center;font-size:200px;font-weight:bold;" > Rice </div>
<div style= "Height:1000px;text-align:center;font-size:200px;font-weight:bold;" > Eat </div>
<div style= "Height:1000px;text-align:center;font-size:200px;font-weight:bold;" > Home </div>
<div style= "Height:1000px;text-align:center;font-size:200px;font-weight:bold;" > Back </div>
<div style= "Height:1000px;text-align:center;font-size:200px;font-weight:bold;" > You </div>
<div style= "Height:1000px;text-align:center;font-size:200px;font-weight:bold;" > Belt </div>
<div id= "back-up" onclick= "Gotop ()" style= "border:1px Solid: pointer;right:10px;bottom:30px; " > Back to Top </div>
<script>
Window.scrollto (0,document.body.scrollheight);
</script>
</body>
Speed can control yourself oh.