页面:回到顶部
2013-01-25 11:14
155 查看
<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"><img src="/images/top.gif" alt="回到顶部" style="border: 0px;" /></a></div> '); document.write('<div style="clear:both;margin:auto;overflow:hidden;text-align:left;">'+str+'</div>'); document.writeln('</DIV>'); </script>
在界面中加入以上代码,实现回到顶部功能,(top.gif图片自己找一个换一下)
原文地址:http://www.oschina.net/code/snippet_135898_4802
相关文章推荐
- 页面回到顶部
- 基于JS实现回到页面顶部的五种写法(从实现到增强)
- 基于JavaScript实现回到页面顶部动画代码
- js常用的页面回到顶部的函数封装
- 页面回到顶部的实现及原理
- 不随页面滚动的元素(<回到顶部>或者是页面顶部信息之类的)
- 如何让页面回到顶部
- 实现页面的回到顶部功能
- 【JQ+锚标记实现点击页面回到顶部】
- jquery 插件页面回到顶部
- 常用小Demo:用js/jQuery实现回到页面顶部功能
- jquery实现点击页面回到顶部
- js刷新页面不回到顶部
- js——页面回到顶部
- 刷新页面让显示区域回到顶部
- web页面浮动回到顶部功能和浮动广告
- 基于jquery的回到页面顶部按钮
- java刷新页面不回到顶部
- 页面回到顶部的代码