• js实例--js滚动条缓慢滚动到顶部


    收集篇(已测)--

    <html>
    <head>
    <script type="text/javascript">
    var currentPosition,timer;
    var speed=10;
    function GoTop(){
    timer=setInterval("runToTop()",1);
    }
    function runToTop(){
    currentPosition=document.documentElement.scrollTop || document.body.scrollTop;
    currentPosition-=speed; //speed变量
    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;">饭</div>
    <div style="height:1000px;text-align:center;font-size:200px;font-weight:bold;">吃</div>
    <div style="height:1000px;text-align:center;font-size:200px;font-weight:bold;">家</div>
    <div style="height:1000px;text-align:center;font-size:200px;font-weight:bold;">回</div>
    <div style="height:1000px;text-align:center;font-size:200px;font-weight:bold;">你</div>
    <div style="height:1000px;text-align:center;font-size:200px;font-weight:bold;">带</div>
    <div id="back-up" onclick="GoTop()" style="border:1px solid red;height:100px;15px;position:fixed;cursor:pointer;right:10px;bottom:30px;">返回顶部</div>
    <script>
    window.scrollTo(0,document.body.scrollHeight);
    </script>
    </body>
    </html>

  • 相关阅读:
    http连接池
    消息队列场景简介
    项目中使用到的设计模式
    dubbo 问题整理
    dubbo Filter
    Elastic-Job分布式作业框架
    别被平凡淹没
    spring中@value注解需要注意
    穷人的真相:从7点忙到23点的上班者,跳出穷人圈子唯一可能是.
    ContextLoaderListener类(spring源码解析)
  • 原文地址:https://www.cnblogs.com/lanyueff/p/4601943.html
Copyright © 2020-2023  润新知