代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="http://www.ca800.com/js/common.js"></script>
<title>无标题文档</title>
</head>
<body >
<ul >
<li id="flash_right_ad" style="display:none">
</li>
</ul>
<div id="result"></div>
<script>
function getRandNum(begin,end,notEqualArray){兼容notEqualArray为数字数组和单个数字
begin=parseInt(begin);
end =parseInt(end);
notEqualArray=notEqualArray||[];
if(begin>end) throw new Error("begin>end");
var stepSize= end- begin;
var rand_num=(parseInt(begin)+(parseInt(Math.random()*parseInt(stepSize+1))));
var notEqualStr=","+notEqualArray.toString()+',';
if(notEqualStr.indexOf(','+rand_num+',')>-1)
{
rand_num=getRandNum(begin,end,notEqualArray);
}
return rand_num;
}
randAdRight=function(){
ZhouJian.Dom.cleanWhitespace(document.getElementById("flash_right_ad").parentNode)
var len=arguments.length;
if(len<1) return;
var stored_ad_flag= ZhouJian.Cookie.get("ad_flag")|| (arguments.length-1);
var rand_num=getRandNum(0,len-1,stored_ad_flag);
ZhouJian.Cookie.set("ad_flag",rand_num)
var str="";
str+="<object width=\"260\" height=\"450\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,19,0\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">";
str+="<param value=\""+arguments[rand_num]+"\" name=\"movie\" >";
str+="<param value=\"high\" name=\"quality\">";
str+="<embed width=\"260\" height=\"450\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" quality=\"high\" src=\""+arguments[rand_num]+"\"\/>";
str+="";
str+="<\/object>"
document.getElementById("flash_right_ad").style.display="";
document.getElementById("flash_right_ad").innerHTML=str;
}
randAdRight("http://down.ca800.com/company/2010-3-1/20103113554171657.swf","http://down.ca800.com/company/2010-3-4/20103419193564574.swf","http://down.ca800.com/company/2010-3-1/20103113554171657.swf",
"http://down.ca800.com/company/2010-3-4/20103419193564574.swf");
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="http://www.ca800.com/js/common.js"></script>
<title>无标题文档</title>
</head>
<body >
<ul >
<li id="flash_right_ad" style="display:none">
</li>
</ul>
<div id="result"></div>
<script>
function getRandNum(begin,end,notEqualArray){兼容notEqualArray为数字数组和单个数字
begin=parseInt(begin);
end =parseInt(end);
notEqualArray=notEqualArray||[];
if(begin>end) throw new Error("begin>end");
var stepSize= end- begin;
var rand_num=(parseInt(begin)+(parseInt(Math.random()*parseInt(stepSize+1))));
var notEqualStr=","+notEqualArray.toString()+',';
if(notEqualStr.indexOf(','+rand_num+',')>-1)
{
rand_num=getRandNum(begin,end,notEqualArray);
}
return rand_num;
}
randAdRight=function(){
ZhouJian.Dom.cleanWhitespace(document.getElementById("flash_right_ad").parentNode)
var len=arguments.length;
if(len<1) return;
var stored_ad_flag= ZhouJian.Cookie.get("ad_flag")|| (arguments.length-1);
var rand_num=getRandNum(0,len-1,stored_ad_flag);
ZhouJian.Cookie.set("ad_flag",rand_num)
var str="";
str+="<object width=\"260\" height=\"450\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,19,0\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">";
str+="<param value=\""+arguments[rand_num]+"\" name=\"movie\" >";
str+="<param value=\"high\" name=\"quality\">";
str+="<embed width=\"260\" height=\"450\" type=\"application\/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" quality=\"high\" src=\""+arguments[rand_num]+"\"\/>";
str+="";
str+="<\/object>"
document.getElementById("flash_right_ad").style.display="";
document.getElementById("flash_right_ad").innerHTML=str;
}
randAdRight("http://down.ca800.com/company/2010-3-1/20103113554171657.swf","http://down.ca800.com/company/2010-3-4/20103419193564574.swf","http://down.ca800.com/company/2010-3-1/20103113554171657.swf",
"http://down.ca800.com/company/2010-3-4/20103419193564574.swf");
</script>
</body>
</html>