JavaScript implementation returns to the top of the code and can follow the scroll bar to scroll. This is the code shown by the Helper's house editor in Baidu space. I don't know who the original author is, the "Back to Top" button in the Code is originally an image. Because the image path is incorrect, it is replaced by a text link by a small editor. You can modify it on your own.
Demo:
<Div style = "height: 2800px;"> <script type = "text/javascript"> var w = 240; var h = 59; var str = ""; var obj = document. getElementById ("divStayTopLeft"); if (obj) str = obj. innerHTML; if (typeof document. compatMode! = 'Undefined' & document. compatMode! = 'Background') {document. writeln ('<DIV style = "z-index: 9; right: 0; bottom: 0; height:' + h + 'px; width: '+ w + 'px; overflow: hidden; POSITION: fixed; _ position: absolute; _ margin-top: expression(document.documentelement.clientheightthis.style.pixelheight#document.doc umentElement. scrollTop); "> ');} else {document. writeln ('<DIV style = "z-index: 9; right: 0; bottom: 0; height:' + h + 'px; width: '+ w + 'px; overflow: hidden; POSITION: fixed; * position: absolute; * top: expression (eval (document. body. scrollTop) + eval (document. body. clientHeight)-this. style. pixelHeight); "> ');} document. writeln ('<div style = "clear: both; margin: auto; height: 59px; font-size: 16px; overflow: hidden; font-weight: bold; text-align: left; "> <a href =" javascript: scroll (0, 0) "hidefocus =" true "> Back to Top </a> </div> '); document. write ('<div style = "clear: both; margin: auto; overflow: hidden; text-align: left;">' + str + '</div> '); document. writeln ('</DIV>'); </script> <br/> <center> If the page cannot be displayed, press Ctrl + F5 to refresh the page. For more page code: <a href =' http://www.bkjia.com/ 'Target = '_ blank'> http://www.bkjia.com/ </A> </center>
Tip: the code can be modified before running!