WEB开发网
开发学院网页设计JavaScript JavaScript腾讯的不间断滚动函数 支持向上、向左滚... 阅读

JavaScript腾讯的不间断滚动函数 支持向上、向左滚动

 2009-05-04 20:04:47 来源:WEB开发网   
核心提示:<style>.gundongnews{ width:218px; height:150px; overflow:hidden;}.gundongnews ul{width:218px;line-height:30px;overflow:hidden;}.gundongnews li{line-height

<style>
.gundongnews{
 width:218px;
 height:150px;
 overflow:hidden;
}
.gundongnews ul{width:218px;line-height:30px;overflow:hidden;}
.gundongnews li{line-height:30px; height:30px}
</style>
<script type="text/javascript">
  function gungun(demo,demo1,demo2,fang){
 this.demo = demo;
 this.demo1 = demo1;
 this.demo2 = demo2;
 this.fang = fang;
 var speed=33
demo2.innerHTML=demo1.innerHTML
  function Marquee(){
   if(fang=="left"){
  if(demo2.offsetWidth-demo.scrollLeft<=0)
    demo.scrollLeft-=demo1.offsetWidth;
    else{
    demo.scrollLeft++
    }
  }
  if(fang=="up"){
  if(demo2.offsetHeight-demo.scrollTop<=0)
  demo.scrollTop-=demo1.offsetHeight
  else{
  demo.scrollTop++
   }
  
  }
 
}
 var MyMar=setInterval(Marquee,speed)
  demo.onmouSEOver=function() {clearInterval(MyMar)}
  demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
  //rongcuo
  if(arguments.length!==4){
   alert("错误的参数!")
  }
 }
  function getObject(objectId) {
  if(document.getElementById && document.getElementById(objectId)) {
// W3C DOM
return document.getElementById(objectId);
  } else if (document.all && document.all(objectId)) {
// MSIE 4 DOM
return document.all(objectId);
  } else if (document.layers && document.layers[objectId]) {
// NN 4 DOM.. note: this won't find nested layers
return document.layers[objectId];
  } else {
return false;
  }
}

new gungun(getObject("study_list"),getObject("study_list1"),getObject("study_list2"),"up")
</script>
<div id="study_list" class="gundongnews">
 <div id="study_list1">
 <ul>
  <li>164101***400</li>
  <li>334205***400</li>
  <li>164101***400</li>
  <li>334205***400</li>
  <li>164101***400</li>
  <li>334205***400</li>
  <li>164101***400</li>
 </ul>
 </div>
 <div id="study_list2"></div>
</div>
<script language="Javascript" type="text/javascript">new gungun(getObject("study_list"),getObject("study_list1"),getObject("study_list2"),"up")</script>

Tags:JavaScript 腾讯 间断

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接