我在网页里面实现了20个flash的随机显示,代码是这样的:
<SCRIPT LANGUAGE="JavaScript">
var how_many_ads = 19;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;if (ad == 1) {swf="flash/1.swf";}
else if (ad == 2) {swf="flash/2.swf";}
else if (ad == 3) {swf="flash/3.swf";}
else if (ad == 4) {swf="flash/4.swf";}
else if (ad == 5) {swf="flash/5.swf";}
else if (ad == 6) {swf="flash/6.swf";}
else if (ad == 7) {swf="flash/7.swf";}
else if (ad == 8) {swf="flash/8.swf";}
else if (ad == 9) {swf="flash/9.swf";}
else if (ad == 10) {swf="flash/10.swf";}
else if (ad == 11) {swf="flash/11.swf";}
else if (ad == 12) {swf="flash/12.swf";}
else if (ad == 13) {swf="flash/13.swf";}
else if (ad == 14) {swf="flash/14.swf";}
else if (ad == 15) {swf="flash/15.swf";}
else if (ad == 16) {swf="flash/16.swf";}
else if (ad == 17) {swf="flash/17.swf";}
else if (ad == 18) {swf="flash/18.swf";}
else if (ad == 19) {swf="flash/19.swf";}
else if (ad == 0) {swf="flash/20.swf";}
document.write('<td bgcolor=139BD9><embed SRC=\"' + swf + '\" menu=false quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="360"></embed></td>');
</SCRIPT>
现在的问题是:
要实现当我在文件夹flash中添加新的flash的时候,不用修改代码就可以直接显示了.
请问要怎么写代码?????我自己认为上面这个代码是静态的,要实现动态随机读取flash文件可怎么搞??????急啊!!!!!!!!!!!
<SCRIPT LANGUAGE="JavaScript">
var how_many_ads = 19;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;if (ad == 1) {swf="flash/1.swf";}
else if (ad == 2) {swf="flash/2.swf";}
else if (ad == 3) {swf="flash/3.swf";}
else if (ad == 4) {swf="flash/4.swf";}
else if (ad == 5) {swf="flash/5.swf";}
else if (ad == 6) {swf="flash/6.swf";}
else if (ad == 7) {swf="flash/7.swf";}
else if (ad == 8) {swf="flash/8.swf";}
else if (ad == 9) {swf="flash/9.swf";}
else if (ad == 10) {swf="flash/10.swf";}
else if (ad == 11) {swf="flash/11.swf";}
else if (ad == 12) {swf="flash/12.swf";}
else if (ad == 13) {swf="flash/13.swf";}
else if (ad == 14) {swf="flash/14.swf";}
else if (ad == 15) {swf="flash/15.swf";}
else if (ad == 16) {swf="flash/16.swf";}
else if (ad == 17) {swf="flash/17.swf";}
else if (ad == 18) {swf="flash/18.swf";}
else if (ad == 19) {swf="flash/19.swf";}
else if (ad == 0) {swf="flash/20.swf";}
document.write('<td bgcolor=139BD9><embed SRC=\"' + swf + '\" menu=false quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="360"></embed></td>');
</SCRIPT>
现在的问题是:
要实现当我在文件夹flash中添加新的flash的时候,不用修改代码就可以直接显示了.
请问要怎么写代码?????我自己认为上面这个代码是静态的,要实现动态随机读取flash文件可怎么搞??????急啊!!!!!!!!!!!
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head><body>
<SCRIPT LANGUAGE="JavaScript">
var how_many_ads = 19;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
/*
if (ad == 1) {swf="flash/1.swf";}
else if (ad == 2) {swf="flash/2.swf";}
else if (ad == 3) {swf="flash/3.swf";}
else if (ad == 4) {swf="flash/4.swf";}
else if (ad == 5) {swf="flash/5.swf";}
else if (ad == 6) {swf="flash/6.swf";}
else if (ad == 7) {swf="flash/7.swf";}
else if (ad == 8) {swf="flash/8.swf";}
else if (ad == 9) {swf="flash/9.swf";}
else if (ad == 10) {swf="flash/10.swf";}
else if (ad == 11) {swf="flash/11.swf";}
else if (ad == 12) {swf="flash/12.swf";}
else if (ad == 13) {swf="flash/13.swf";}
else if (ad == 14) {swf="flash/14.swf";}
else if (ad == 15) {swf="flash/15.swf";}
else if (ad == 16) {swf="flash/16.swf";}
else if (ad == 17) {swf="flash/17.swf";}
else if (ad == 18) {swf="flash/18.swf";}
else if (ad == 19) {swf="flash/19.swf";}
else if (ad == 0) {swf="flash/20.swf";}
*/
swf="flash/"+ad+".swf";
document.write('<td bgcolor=139BD9><embed SRC=\"' + swf + '\" menu=false quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="600" height="360"></embed></td>');
</SCRIPT>
</body>
</html>
但是
how_many_ads
应该是可变的
也就是文件夹里面文件的数目-1才行