返回顶部按钮实现

  1. <div id="full" style="width:50px; height:95px; position:fixed; left:50%; top:425px; margin-left:493px; z-index:100; text-align:center; cursor:pointer;">
  2.  <a>
  3. <img src="图片绝对地址" border=0 alt="返回顶部">
  4. </a> </div><script type="text/javascript">
  5. var isie6 = window.XMLHttpRequest ? false : true; 
  6. function newtoponload() {
  7.  var c = document.getElementById("full");
  8.  function b() {
  9.  var a = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; 
  10. if (> 0) { 
  11. if (isie6) {
  12.  c.style.display = "none"; 
  13. clearTimeout(window.show); 
  14. window.show = setTimeout(function () {
  15.  var d = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
  16.  if (> 0) { 
  17. c.style.display = "block"; c.style.top = (400 + d) + "px" } }, 300) } 
  18. else { c.style.display = "block" } }
  19. else { c.style.display = "none" } } 
  20. if (isie6) {
  21.  c.style.position = "absolute" } 
  22. window.onscroll = b; b() }
  23.  if (window.attachEvent) { 
  24. window.attachEvent("onload", newtoponload)
  25.  } else { window.addEventListener("load", newtoponload, false) } 
  26. document.getElementById("full").onclick = function () { window.scrollTo(0, 0) };
  27. </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值