网络编程
位置:首页>> 网络编程>> JavaScript>> js 数组随机字符串(广告不重复)

js 数组随机字符串(广告不重复)

  发布时间:2024-04-18 09:37:20 

标签:js,数组,随机字符串

比较好的地方就是js数组的操作,不重复的数组id显示,完美实现。

<script language="JavaScript" type="text/JavaScript"> theAds=new Array(); shu =13; dot=''; theAds[1]='asp之家第一条'; theAds[2]='asp之家第二条'; theAds[3]='asp之家第三条'; theAds[4]='asp之家第四条'; theAds[5]='asp之家第五条'; theAds[6]='asp之家第六条'; theAds[7]='asp之家第七条'; theAds[8]='asp之家第八条'; theAds[9]='asp之家第九条'; theAds[10]='asp之家第十条'; theAds[11]='asp之家第十一条'; theAds[12]='asp之家第十二条'; theAds[13]='asp之家第十三条'; adshu=shu+1 function Quickpick() { var ball for( ball = 1; ball < adshu; ball++) { this[ball] = parseInt(Math.random() * shu + 1); for(var list = 0; list < ball; list++) { if(this[list] == this[ball]) { list = ball; ball--; } } } return this; } var idx; var ballball = new Array(shu); ballball = this.Quickpick(); for(idx = 1; idx < adshu; idx++){ document.write(dot+theAds[ballball[idx]]+'<br>'); if (idx < shu){document.write('')}} //document.write(dot+theAds2); </script>


 


0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com