欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

从网易扒过来的js调用广告显示文件(随机几率)

程序员文章站 2023-12-13 14:40:34
从网易撬过来的js调用广告显示文件 只有下面短短几行代码可以随机显示flash和gif广告,还不错 复制代码 代码如下:function column02(imgsource,url,chance,t...
从网易撬过来的js调用广告显示文件
只有下面短短几行代码可以随机显示flash和gif广告,还不错
复制代码 代码如下:

function column02(imgsource,url,chance,type) {
this.imgsource = imgsource;
this.url = url;
this.chance = chance;
this.type = type;
}
function dispcolumn02() {
with (this)
switch (type){
case "img":
document.write("<a href=" + url + " target=_blank><img src=" + imgsource + " width=480 height=250 border=0></a>");
break;
case "html":
document.write("<iframe width=480 height=250 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no bordercolor=#000000 src="+ imgsource + "></iframe>");
break;
case "flash":
document.write("<embed src="+imgsource+" quality=high width=480 height=250 type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash></embed>");
break;
default:
document.write("");
}
}
column02.prototype.dispcolumn02 = dispcolumn02;
columns02 = new array();
// flash , html , img 代表三种不同的广告模式
// 200 之类的数目是设置出现的机率
columns02[0] = new column02("http://smsimg.163.com/honey/honey_ad.swf","",200,"flash");//主广告
columns02[1] = new column02("http://smsimg.163.com/honey/honey_photo.swf","",800,"flash"); //上传图片免月租
columns02[2] = new column02("http://smsimg.163.com/honey/honey_gold.swf","",800,"flash"); //登陆送金币
//columns02[] = new column02("f","",100,"");// (20030422~20030722)
sum_of_all_chances = 0;
for (i = 0; i < columns02.length; i++) {
sum_of_all_chances += columns02[i].chance;
}
function randomcolumn02() {
chance_limit = 0;
randomly_selected_chance = math.round((sum_of_all_chances - 1) * math.random()) + 1;
for (i = 0; i < columns02.length; i++) {
chance_limit += columns02[i].chance;
if (randomly_selected_chance <= chance_limit) {
columns02[i].dispcolumn02();
break;
}
}
}
this_column02 = randomcolumn02();

测试代码,chance越大显示的几率越大
相关标签: 调用广告 随机

上一篇:

下一篇: