First, copy the following code to an html file.
Copy codeThe Code is as follows:
<Html>
<Head>
<Script type = "text/javascript">
Var currentPosition, timer;
Function GoTop (){
Timer = setInterval ("runToTop ()", 1 );
}
Function runToTop (){
Currentpositionexcepdocument.doc umentElement. 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>
</Head>
<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;"> band </div>
<Div id = "back-up" onclick = "GoTop ()" style = "border: 1px solid red; height: 100px; width: 15px; position: fixed; cursor: pointer; right: 10px; bottom: 30px; "> return to the top </div>
<Script>
Window. scrollTo (0, document. body. scrollHeight );
</Script>
</Body>
</Html>
You can control the speed by yourself.