페이지 정보 스크롤 블록

6512 단어 JavaScripthtmlIE
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>    </title>
    <!-- author:chendonghua -->
    <!--         html    IE      -->
  </head>
  <body>
    <div style="width:400px;"><font size="5" color="red">2009        666</font></div>
    <div id="demo" style="overflow:hidden;width:320px; height:260px;float:none;border-style:dotted;">
      <ul class="padding10" style="padding-top:5px; padding-bottom:5px;">
	 <li>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;te">  ·   </span></div>
          <div style="float:left; width:300px;">  <span style="margin-left:15px;">77 </span><span style="margin-left:15px;">620   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">   -   ·    </span></div><br>
          <div style="float:left; width:300px;">   <span style="margin-left:15px;">68 </span><span style="margin-left:15px;">600   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">  ·  </span></div>
          <div style="float:left; width:300px;">  <span style="margin-left:15px;">58 </span><span style="margin-left:15px;">580   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">   ·   </span></div>
          <div style="float:left; width:300px;">  <span style="margin-left:15px;">57 </span><span style="margin-left:15px;">450   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">   ·    </span></div>
          <div style="float:left; width:300px;">  <span style="margin-left:15px;">50 </span><span style="margin-left:15px;">430   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">   ·    </span></div>
          <div style="float:left; width:300px;">  <span style="margin-left:15px;">48 </span><span style="margin-left:15px;">420   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">   ·      </span></div>
          <div style="float:left; width:300px;">  <span style="margin-left:15px;">81 </span><span style="margin-left:15px;">310   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">KP-  </span></div><br>
          <div style="float:left; width:300px;">  <span style="margin-left:15px;">76 </span><span style="margin-left:15px;">300   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">   -     </span></div>
          <div style="float:left; width:300px;">   <span style="margin-left:15px;">40 </span><span style="margin-left:15px;">280   </span></div>
	   <div class="clr"></div>
	   <div style="width:300px; float:left">   <span style="margin-left:15px;">  ·     </span></div>
          <div style="float:left; width:300px;">  <span style="margin-left:15px;">88 </span><span style="margin-left:15px;">270   </span></div>
	   <div class="clr"></div>
	 </li>
      </ul>
    </div>
    <script type="text/javascript">
	function next(elem){    
	   	 do{    
	               elem=elem.nextSibling;    
	        }while(elem&&elem.nodeType!=1);    
		 return elem;    
	}    
       function first(elem){    
	        elem=elem.firstChild;    
	        return elem && elem.nodeType!=1?next(elem):elem;    
	}
	var Marquee = {
		init : function(id,speed){
			this.speed = speed || 50;
			this.boxID = id;
			this.scrollBox = document.getElementById(id);
			this.appendBox=first(this.scrollBox).cloneNode(true);
			this.scrollBox.appendChild(this.appendBox);
			this.objs = {
				scrollBox : this.scrollBox,
				appendBox : this.appendBox,
				speed : this.speed,
				id : this.boxID
			};
			return this;
		},
		scrollUp : function(){
			var self = this.objs;
			self.begin = function(){
				self.doScr = setInterval(function(){
					if(self['appendBox'].offsetHeight<=self['scrollBox'].scrollTop){
						self['scrollBox'].scrollTop-=self['appendBox'].offsetHeight;
					}else{
						self['scrollBox'].scrollTop++;
					}
				},self.speed);
			}
			self.begin();
			self.scrollBox.onmouseover = function(){
				clearInterval(self.doScr);
			}
			self.scrollBox.onmouseout = function(){
				self.begin();
			}
		}
	}
	Marquee.init("demo",50).scrollUp();
    </script>
  </body>
</html>

좋은 웹페이지 즐겨찾기