javascript返回頂端源碼,javascript返回頂端

來源:互聯網
上載者:User

javascript返回頂端源碼,javascript返回頂端

<div style="display:none" id="goTopBtn"><img src="http://www.unitymanual.com/m/Manual/img/top.png" width="54" height="54" border="0"></div>

<script type="text/javascript">function goTopEx(){        var obj=document.getElementById("goTopBtn");        function getScrollTop(){                return document.documentElement.scrollTop || document.body.scrollTop            }        function setScrollTop(value){document.documentElement.scrollTop = value;   document.body.scrollTop = value;            }            window.onscroll=function(){getScrollTop()>0?obj.style.display="":obj.style.display="none";}        obj.onclick=function(){            var goTop=setInterval(scrollMove,10);            function scrollMove(){                    setScrollTop(getScrollTop()/1.1);                    if(getScrollTop()<1)clearInterval(goTop);                }        }    }goTopEx();




實現2:

#scrolltop{
    visibility:hidden;
    position:fixed;
    bottom:100px;
    display:block;
    margin:-30px 0 0 2px;
    width:40px;
    background:#f4f4f4;
    border:1px #cdcdcd solid;
    border-radius:3px;
    border-top:0;
    cursor:pointer;
}

#scrolltop:hover{
    text-decoration:none;
}

.ie6 #scrolltop{
    position:absolute;
    bottom:auto;
}

#scrolltop a{
    display:block;
    width:30px;
    height:24px;
    padding:3px 5px;
    line-height:12px;
    text-align:center;
    color:#787878;
    text-decoration:none;
    background:url(http://www.unitymanual.com/static/image/common/scrolltop.png) no-repeat 0 0;
    border-top:1px #cdcdcd solid;
}

a.scrolltopa:hover{
    background-position:-40px 0px !important;
}

a.replyfast{
    background-position:0 -30px !important;
}

a.replyfast:hover{
    background-position:-40px -30px !important;
}

a.returnlist,a.returnboard{
    background-position:0 -60px !important;
}

a.returnlist:hover,a.returnboard:hover{
    background-position:-40px -60px !important;
}

#scrolltop a b{
    visibility:hidden;
    font-weight:normal;
}

<div style="left: auto; right: 0px; visibility: visible;" id="scrolltop">
   
  <span hidefocus="true"><a title="返回頂部" onclick="window.scrollTo('0','0')" class="scrolltopa"><b>返回頂部</b></a></span>
   
</div>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.