| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 576 人关注过本帖
标题:如何改才能一次显示多条信息呢?
只看楼主 加入收藏
chenxingg
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-1-5
结帖率:0
收藏
 问题点数:0 回复次数:3 
如何改才能一次显示多条信息呢?

一个向上滚动的文字信息
现在实现的是单条滚动
如何修改才能实现多条同时滚动?

代码如下:

<script>
var marqueeContent=new Array(); //滚动主题

marqueeContent[0]='<a href="http://www.51adn.com/" target="_blank">+ 111111111111111111111111</a>';
marqueeContent[1]='<a href="http://www.51adn.com/" target="_blank">+ 222222222222222222222222</a>';
marqueeContent[2]='<a href="http://www.51adn.com/" target="_blank">+ 333333333333333333333333</a>';
marqueeContent[3]='<a href="http://www.51adn.com/" target="_blank">+ 4444444444444444444444444</a>';
marqueeContent[4]='<a href="http://www.51adn.com/" target="_blank">+ 55555555555555555555555555。</a>';

var marqueeInterval=new Array(); //定义一些常用而且要经常用到的变量
var marqueeId=1;
var marqueeDelay=4000;
var marqueeHeight=60;
function initMarquee() {
var str=marqueeContent[0];
document.write('<div id=marqueeBox style="overflow:hidden;height:'+marqueeHeight+'px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval(\'startMarquee()\',marqueeDelay)"><div>'+str+'</div></div>');
marqueeId++;
marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay);
}
function startMarquee() {
var str=marqueeContent[marqueeId];
marqueeId++;
if(marqueeId>=marqueeContent.length) marqueeId=0;
if(marqueeBox.childNodes.length==1) {
var nextLine=document.createElement('DIV');
nextLine.innerHTML=str;
marqueeBox.appendChild(nextLine);
}
else {
marqueeBox.childNodes[0].innerHTML=str;
marqueeBox.appendChild(marqueeBox.childNodes[0]);
marqueeBox.scrollTop=0;
}
clearInterval(marqueeInterval[1]);
marqueeInterval[1]=setInterval("scrollMarquee()",10);
}
function scrollMarquee() {
marqueeBox.scrollTop++;
if(marqueeBox.scrollTop%marqueeHeight==marqueeHeight){
clearInterval(marqueeInterval[1]);
}
}
initMarquee();
</script>

搜索更多相关主题的帖子: target blank 单条 href 
2007-09-19 13:51
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 

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


[编程论坛] ASP超级群:49158383  敲门暗号:ASP编程
龍艺博客 http://www.
2007-09-19 15:47
chenxingg
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-1-5
收藏
得分:0 

谢谢
但是我如果不想让它有连接怎么办呢?


另:能不能解释一下上边的代码?
谢谢

[此贴子已经被作者于2007-9-20 15:13:00编辑过]


淘服网www.
2007-09-20 14:59
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 

<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">
<span class="dhScrollA">月圆之夜1</span>
<span class="dhScrollA">紫禁之颠2</span>
<span class="dhScrollA">西门吹雪3</span>
<span class="dhScrollA">天外飞仙4</span>
<span class="dhScrollA">太阳之夜5</span>
<span class="dhScrollA">紫禁之谷6</span>
<span class="dhScrollA">西门吹风7</span>
<span class="dhScrollA">天外飞碟8</span>

<span class="dhScrollA">月圆之夜9</span>
<span class="dhScrollA">紫禁之颠10</span>
<span class="dhScrollA">西门吹雪11</span>
<span class="dhScrollA">天外飞仙12</span>
<span class="dhScrollA">太阳之夜13</span>
<span class="dhScrollA">紫禁之谷14</span>
<span class="dhScrollA">西门吹风15</span>
<span class="dhScrollA">天外飞碟16</span>
</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 = 5000;
function clipShow(){
scroll();
window.setTimeout(clipShow,t);
}
window.setTimeout(clipShow,t);
</script>


[编程论坛] ASP超级群:49158383  敲门暗号:ASP编程
龍艺博客 http://www.
2007-09-20 15:14
快速回复:如何改才能一次显示多条信息呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017853 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved