熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

js控制滾動條緩慢滾動到頂部

2022-06-13   來源: JSP教程 

  <html> <head> <script type="text/javascript"> var currentPositiontimer; function GoTop(){ timer=setInterval("runToTop()"); } function runToTop(){ currentPosition=documentdocumentElementscrollTop || documentbodyscrollTop; currentPosition=; if(currentPosition>) { windowscrollTo(currentPosition); } else { windowscrollTo(); clearInterval(timer); } } </script> <style type="text/css"> </style> </head> <body> <div style="height:px;textalign:center;fontsize:px;fontweight:bold;">飯</div> <div style="height:px;textalign:center;fontsize:px;fontweight:bold;">吃</div> <div style="height:px;textalign:center;fontsize:px;fontweight:bold;">家</div> <div style="height:px;textalign:center;fontsize:px;fontweight:bold;">回</div> <div style="height:px;textalign:center;fontsize:px;fontweight:bold;">你</div> <div style="height:px;textalign:center;fontsize:px;fontweight:bold;">帶</div> <div id="backup" onclick="GoTop()" style="border:px solid red;height:px;width:px; position:fixed;cursor:pointer;right:px;bottom:px;"> 返回頂部 </div> <script> windowscrollTo(documentbodyscrollHeight); </script> </body> </html>


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20247.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.