Instance
The code is as follows |
Copy Code |
<script language= "JavaScript" type= "Text/javascript" > Theads=new Array (); Shu = 13; Dot= '; theads[1]= ' www.111cn.net first '; Theads[2]= ' www.111cn.net second '; Theads[3]= ' www.111cn.net third '; Theads[4]= ' www.111cn.net fourth '; Theads[5]= ' www.111cn.net fifth '; Theads[6]= ' www.111cn.net sixth '; theads[7]= ' www.111cn.net seventh '; Theads[8]= ' www.111cn.net eighth '; theads[9]= ' www.111cn.net nineth '; Theads[10]= ' www.111cn.net tenth '; theads[11]= ' www.111cn.net 11th '; theads[12]= ' www.111cn.net 12th '; theads[13]= ' www.111cn.net 13th '; 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> |
Look at an array of random sort functions
The code is as follows |
Copy Code |
var wangwanglist = [' Consulting online ', ' consulting online1 ', ' consulting Online2 ', ' consulting online3 ']; /** * Random pre * @param Wang Wang Name list & nbsp; * @returns HTML code **/ function Randomwangwang (A) { var b,c; var X = []; var j=0; for (i=a.length;i>=1;i--) { C=math.floor (Math.random () * a.length); X[j] = Outwangwangcode (A[c]); A.splice (c,1) j + +; } return X } /** * Convert to HTML link form * @param Wang Wang name * @returns HTML code **/ function Outwangwangcode (n) { var _n = encodeURIComponent (n); var html= '; html = ' <li><a class=img title= Click here to send me a message href= http://amos.im.alisoft.com/msg.aw?v=2&uid= ' +_n+ ' &site= Cntaobao&s=1&charset=utf-8 "Target=_blank> '"; html = ' </A> ' +n+ ' </LI> '; return HTML; } /** * Go out full list * @param write mode or return mode * @returns HTML code **/ function writewangwanghtml (write) { var html = ' <UL> '; var x = Randomwangwang (wangwanglist); for (i in X) { HTML + x[i]; } html = ' </UL> '; return HTML; } Display code document.write (writewangwanghtml ()); |