js link

此博客使用JavaScript代码实现滚动链接展示功能。定义数组存放链接图片,通过自定义函数对数组元素随机排序,利用多个函数控制链接滚动显示,包括初始化、开始滚动和滚动操作等,实现了动态展示多个链接的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 <SCRIPT>
var marqueeContent=new Array();   //定义一个数组,用来存放显示内容
marqueeContent[0]='<a href="http://www.chinavisual.com" target="_blank"><img src="images/link/chinavisual.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[1]='<a href="http://www.blueidea.com" target="_blank"><img src="images/link/blueidea.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[2]='<a href="http://www.dolcn.com" target="_blank"><img src="images/link/dollogo88.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[3]='<a href="http://www.pconline.com.cn/pcedu/" target="_blank"><img src="images/link/pconline.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[4]='<a href="http://www.5d.cn/" target="_blank"><img src="images/link/5dmedia.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[5]='<a href="http://www.chinadu.org/" target="_blank"><img src="images/link/chinadu.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[6]='<a href="http://www.themex.net/" target="_blank"><img src="images/link/themex_logo.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[7]='<a href="http://www.52design.com/" target="_blank"><img src="images/link/52logo.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[8]='<a href="http://arts.tom.com/" target="_blank"><img src="images/link/artu.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[9]='<a href="http://www.ionly.com.cn/" target="_blank"><img src="images/link/ionly.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[10]='<a href="http://www.cn-media.com/" target="_blank"><img src="images/link/mtzg.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[11]='<a href="http://www.cgtimes.com.cn/" target="_blank"><img src="images/link/cgtime.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[12]='<a href="http://www.newwebpick.com/" target="_blank"><img src="images/link/newwebpick.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[13]='<a href="http://www.mydeskcity.com/" target="_blank"><img src="images/link/MYdesk.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[14]='<a href="http://www.colorbird.com/" target="_blank"><img src="images/link/qsnlinklogo.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[15]='<a href="http://www.chinavfx.net/" target="_blank"><img src="images/link/vfxlogo.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[16]='<a href="http://www.aougu.com/" target="_blank"><img src="images/link/aougu.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[17]='<a href="http://www.cnbeta.com/" target="_blank"><img src="images/link/logo_cnbeta.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[18]='<a href="http://www.yy-s.com/" target="_blank"><img src="images/link/yy_logo.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[19]='<a href="http://tech.163.com/school/" target="_blank"><img src="images/link/neteaseLOGO.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[20]='<a href="http://www.netfriends.com.cn/" target="_blank"><img src="images/link/wysjlogo.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[21]='<a href="http://www.flashempire.com/" target="_blank"><img src="images/link/flashempire.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[22]='<a href="http://union.163.com/" target="_blank"><img src="images/link/neteaselm_logo.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[23]='<a href="http://www.1studio.net/" target="_blank"><img src="images/link/logo_1studio.gif" width="88" height="31" border="0"></a>  ';
marqueeContent[24]='<a href="http://www.smartphones.com.cn/" target="_blank"><img src="images/link/mobile_31logo.gif" width="88" height="31" border="0"></a>  ';

 

var marqueeInterval=new Array();  //定义一些常用而且要经常用到的变量
var marqueeId=0;
var marqueeDelay=7000;
var marqueeHeight=35;

//接下来的是定义一些要使用到的函数
Array.prototype.random=function() {
 var a=this;
 var l=a.length;
 for(var i=0;i<l;i++) {
  var r=Math.floor(Math.random()*(l-i));
  a=a.slice(0,r).concat(a.slice(r+1)).concat(a[r]);
  }
 return a;
 }
function initMarquee() {
 marqueeContent=marqueeContent.random();
 var str='';
 for(var i=0;i<Math.min(24,marqueeContent.length);i++) str+=(i>0?'':'')+marqueeContent[i];
// document.write('<span id=marqueeBox style="overflow:hidden;height:'+marqueeHeight+'px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval(/'startMarquee()/',marqueeDelay)"><span>'+str+'</span></span>');
 document.write('<span id=marqueeBox style="overflow:hidden;height:'+marqueeHeight+'px"><span>'+str+'</span></span>');
 marqueeId+=2;
 if(marqueeContent.length>23)marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay);
 }
 
function startMarquee() {
 var str='';
 for(var i=0;(i<24)&&(marqueeId+i<marqueeContent.length);i++) {
  str+=(i>0?'':'')+marqueeContent[marqueeId+i];
  }
 marqueeId+=24;

 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-1)){
  clearInterval(marqueeInterval[1]);
  }
 }
initMarquee();
</SCRIPT>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值