<style>
.dhMarquee {width:100px;height:108px;text-align:left;margin:0px;padding:0px;border:1px solid #000;overflow:hidden;white-space:nowrap;}
.mqdemo {margin:0px;padding:0px;border:0px;}
.dhScrollA {font-size:12px;display:block;padding:2px;}
</style>
<div id="mq" class="dhMarquee" onmouseover="iScrollAmount=0" onmouseout="iScrollAmount=1">
<div id="mqdemo" class="mqdemo">
<a class="dhScrollA" href="javascript:alert('1')">月圆之夜1</a>
<a class="dhScrollA" href="javascript:alert('2')">紫禁之颠2</a>
<a class="dhScrollA" href="javascript:alert('3')">西门吹雪3</a>
<a class="dhScrollA" href="javascript:alert('4')">天外飞仙4</a>
<a class="dhScrollA" href="javascript:alert('5')">太阳之夜5</a>
<a class="dhScrollA" href="javascript:alert('6')">紫禁之谷6</a>
<a class="dhScrollA" href="javascript:alert('7')">西门吹风7</a>
<a class="dhScrollA" href="javascript:alert('8')">天外飞碟8</a>
<a class="dhScrollA" href="javascript:alert('1')">月圆之夜9</a>
<a class="dhScrollA" href="javascript:alert('2')">紫禁之颠10</a>
<a class="dhScrollA" href="javascript:alert('3')">西门吹雪11</a>
<a class="dhScrollA" href="javascript:alert('4')">天外飞仙12</a>
<a class="dhScrollA" href="javascript:alert('5')">太阳之夜13</a>
<a class="dhScrollA" href="javascript:alert('6')">紫禁之谷14</a>
<a class="dhScrollA" href="javascript:alert('7')">西门吹风15</a>
<a class="dhScrollA" href="javascript:alert('8')">天外飞碟16</a>
</div>
</div>
<script language="javascript">
var speed = 30;
//滚动对象
var oMarquee = document.getElementById("mq");
//内容对象
var omqdemo = document.getElementById("mqdemo");
var h = oMarquee.offsetHeight;
var odl = omqdemo.offsetHeight;
var x = parseInt(h/odl)+1;
for(var i=0;i<x;i++){
var o = omqdemo.cloneNode(true);
oMarquee.appendChild(o);
}
var iScrollAmount = 1
var myMar;
function scroll(){
oMarquee.scrollTop += iScrollAmount;
var ol = oMarquee.scrollTop;
if(odl-ol<=0){
window.clearTimeout(myMar);
oMarquee.scrollTop = 0;
}else{
if(ol%h!=0){
myMar = window.setTimeout(scroll,speed);
}else{
window.clearTimeout(myMar);
}
}
}
var t = 6000;
function clipShow(){
scroll();
window.setTimeout(clipShow,t);
}
window.setTimeout(clipShow,t);
</script>
不断滚动的新闻代码
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 不断滚动的新闻代码
相关推荐
-      mootools实例:更改div的透明度动画效果
-      jquery获取当前类在第几个li上面
-      mootools应用:获取复选框中选中的值
-      使用javascript设置下拉框的默认值
-      一款漂亮的黑色风格JS焦点图,使用简单
-      javascript自动获取标题中的关键词
-      用jquery的siblings来实现tab选项卡功能
-      jquery框架操作checkbox控件