If the webpage is too long, you usually use the anchor tag to quickly return to the TOP
<A href = "# header" title = "back to top"> top </a> is really simple, but some experts make this simple:
Foreign demo address: http://tonyyoo.com/v2/
Clicking the TOP button does not directly jump to the TOP of the page, but scroll up .. The longer the page, the faster the scrolling speed...
After research, four JavaScript codes are used:
<Script type = "text/javascript" src = "scripts/prototype. lite. js"> </script>
<Script type = "text/javascript" src = "scripts/moo. fx. js"> </script>
<Script type = "text/javascript" src = "scripts/moo. fx. pack. js"> </script>
<Script type = "text/javascript" src = "scripts/pageScroll. js"> </script>
It looks complicated .. I don't know if the code that can be simplified can achieve the same effect ..
After the onload of the page, traverse all the hyperlinks to determine whether there is # header in href. If yes, trigger scrollTo...
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml"> <pead> <title> runcode </title> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "/> <meta name =" Author "content =" Sheneyan "/> <body onload =" s2top () "> </body> <p> </p> go to header </body>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]