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

2019-10-25 11:48:40 织梦安装使用
  • 文章介绍
从网易撬过来的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("");
break;
case "html":
document.write("");
break;
case "flash":
document.write("");
break;
default:
document.write("");
}
}
column02.prototype.dispColumn02 = dispColumn02;
columns02 = new Array();
// flash , html , img 代表三种不同的广告模式
// 200 之类的数目是设置出现的机率
columns020 = new column02("http://smsimg.163.com/honey/honey_ad.swf","",200,"flash");//主广告
columns021 = new column02("http://smsimg.163.com/honey/honey_photo.swf","",800,"flash"); //上传图片免月租
columns022 = 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 += columns02i.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 += columns02i.chance;
if (randomly_selected_chance <= chance_limit) {
columns02i.dispColumn02();
break;
}
}
}
this_column02 = randomColumn02();

脚本之家测试代码,chance越大显示的几率越大

运行代码复制代码 保存代码

上一篇:javascript实现的简易的DatePicker日..

下一篇:基于jquery的slideDown和slideUp做手..

专业的织梦模板定制下载站,在线购买后即可下载!

商业源码

跟版网模板,累计帮助5000+客户企业成功建站,为草根创业提供助力!

立刻开启你的建站之旅

QQ在线客服

服务热线

织梦建站咨询