快捷控制滚动条到页面顶部TOP

如果页面太长,通过此方法可能做个连接的东西实现.

<style type="text/css">
<!--
#floater {position:absolute; visibility:visible}
-->
</style>
<script language="JavaScript">
<!--
 self.onError=null;
 currentX = currentY = 0; 
 whichIt = null;          
 lastScrollX = 0; lastScrollY = 0;
 NS = (document.layers) ? 1 : 0;
 IE = (document.all) ? 1: 0;
 <!-- STALKER CODE -->
 function heartBeat() {
  if(IE) {
     diffY = document.body.scrollTop;
      diffX = 0;
         }
     if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
  if(diffY != lastScrollY) {
                 percent = .1 * (diffY - lastScrollY);
                 if(percent > 0) percent = Math.ceil(percent);
                 else percent = Math.floor(percent);
   if(IE) document.all.floater.style.pixelTop += percent;
   if(NS) document.floater.top += percent;
                 lastScrollY = lastScrollY + percent;
     }
  if(diffX != lastScrollX) {
   percent = .1 * (diffX - lastScrollX);
   if(percent > 0) percent = Math.ceil(percent);
   else percent = Math.floor(percent);
   if(IE) document.all.floater.style.pixelLeft += percent;
   if(NS) document.floater.top += percent;
   lastScrollY = lastScrollY + percent;
  } 
 } 
 if(NS || IE) action = window.setInterval("heartBeat()",1);
//-->
</script>

<!--top Start-->
<div id="floater" style="position:absolute; left:755px; top:320px; width:26px; height:24px; z-index:0">
 <A onfocus=this.blur(); href="#top"><img src="/img/top.gif" border=0></a>
</div>
<!--top End-->

版权声明:
作者:Kiyo
链接:https://www.wkiyo.cn/html/2008-01/i293.html
来源:Kiyo's space
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>