广告轮播代码

<script type="text/javascript">
var randoms = {
	ads_codes: ['1','2','3'],
  ------------> 修改为你的广告地址
	ads_weight: [10,10,10],
    ------------> 广告权重

	get_random: function(weight) {
		var s = eval(weight.join('+'));
		var r = Math.floor(Math.random() * s);
		var w = 0;
		var n = weight.length - 1;
		for(var k in weight){w+=weight[k];if(w>=r){n=k;break;}};
		return n;
	},
	init: function() {

		var rand = randoms.get_random(randoms.ads_weight);
		document.write(randoms.ads_codes[rand]);

	}
}
randoms.init();
</script>

弹出时间间隔: ads_timer秒内只弹一次(设置为0则为刷新弹)

<script type="text/javascript">
var randoms = {
	ads_codes: ['1','2','3'],
	ads_weight: [10,10,10],
	ads_timer: 10,
	get_cookie: function(n) {
		var a = document.cookie.match(new RegExp("(^| )" + n + "=([^;]*)(;|$)"));
		if (a != null) return decodeURI(a[2]);
		return null;
	},

	get_random: function(weight) {
		var s = eval(weight.join('+'));
		var r = Math.floor(Math.random() * s);
		var w = 0;
		var n = weight.length - 1;
		for(var k in weight){w+=weight[k];if(w>=r){n=k;break;}};
		return n;
	},
	init: function() {
		if (randoms.get_cookie('XCY_cookie_XCY')) return;

		var rand = randoms.get_random(randoms.ads_weight);
		document.write(randoms.ads_codes[rand]);
		var time = new Date();
		time.setTime(time.getTime() + randoms.ads_timer * 1000);
		document.cookie = 'XCY_cookie_XCY=1;expires=' + time.toGMTString() + ';path=/;';

	}
}
randoms.init();
</script>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。