JavaScript實現的回到頂部代碼,可跟隨滾動條滾動,這是網小編在百度空間看到的代碼,不知道原作者是誰,在代碼中的“回到頂部”按鈕原本是一個圖片,由于圖片路徑不正確,所以被小編替換為文字鏈接,您可以自行修改哦。
演示:
<div style="height:2800px;"><script type="text/javascript">var w = 240;var h = 59;var str = "";var obj = document.getElementById("divStayTopLeft");if (obj)str = obj.innerHTML;if( typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat'){document.writeln('<DIV style="z-index:9;right:0;bottom:0;height:'+h+'px;width:'+w+'px;overflow:hidden;POSITION:fixed;_position:absolute; _margin-top:expression(document.documentElement.clientHeight-this.style.pixelHeight+document.documentElement.scrollTop);">');}else {document.writeln('<DIV style="z-index:9;right:0;bottom:0;height:'+h+'px;width:'+w+'px;overflow:hidden;POSITION:fixed;*position:absolute; *top:expression(eval(document.body.scrollTop)+eval(document.body.clientHeight)-this.style.pixelHeight);">');}document.writeln('<div style="clear:both;margin:auto;height:59px;font-size:16px;overflow:hidden;font-weight:bold;text-align:left;"><a href="javascript:scroll(0,0)" hidefocus="true">回到頂部</a></div> ');document.write('<div style="clear:both;margin:auto;overflow:hidden;text-align:left;">'+str+'</div>');document.writeln('</DIV>');</script><br /><center>如不能顯示效果,請按Ctrl+F5刷新本頁,更多網頁代碼:<a href='http://www.vxbq.cn/' target='_blank'>http://www.vxbq.cn/</a></center>提示:可修改后代碼再運行!
上一篇 網店推廣秘籍:網店一夜走紅的18個絕招
下一篇 十一條經驗教你如何打響自己論壇的知名度
程序員人生,我編程,我富裕,記住wfuyu網,php教程,php學習,php手冊,CMS模版制作
聲明:本站大部分內容是作者原創,少部分收集于互聯網供大家一起學習,原版權很多不明,如有侵權請聯系本站,謝謝!
粵ICP備14040726號-1?? 2015-2020 程序員人生 版權所有