<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030" /> </head> <body style="text-align: center;"> <div style="height: 0px;"> </div> <div id="gobottombtn"> 返回底部 </div> <div style="height: 1500px;"> </div> <div id="gotopbtn"> 返回顶部 </div> <script type="text/javascript"> btop = document.getElementById('gotopbtn'); btop.onclick = function() { document.documentElement.scrollTop = 0; } window.onscroll = sb; function sb() { btop.style.display = "block"; }
bottom = document.getElementById('gobottombtn'); bottom.onclick = function() { document.documentElement.scrollTop = 1500; } window.onscroll = sp; function sp() { bottom.style.display = "block"; } </script> </body> </html>