回到顶部效果加在适当的网页中会给访问者一个很好的浏览体验,以下是网上整理的javascrip回到顶部代码,代码中的w,h分别代表距离屏幕右下角的距离(像素);Top.gif是图片样式,地址由自己指定,复制到网页代码中即可 ,更多回到顶部点这里查看:动态回到顶部
JavaScript Code复制内容到剪贴板
- <!--
- var w = 32;
- var h = 20;
- 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:30px;font-size:16px;overflow:hidden;font-weight:bold;text-align:left;"><a href="javascript:scroll(0,0)" hidefocus="true"><img src="/PLUGIN/GoTop/Top.gif" alt="" title="Go to Top" style="border: 0px;" /></a></div> ');
- document.write('<div style="clear:both;margin:auto;overflow:hidden;text-align:left;">'+str+'</div>');
- document.writeln('</DIV>');
- -->
效果如网站右下角显示