电脑技术学习

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

dn001

<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>