蓝色理想放置GOOGLEAD的JS完整代码
蓝色理想放置GOOGLEAD的JS完整代码
首先建一个文件名为adbanner的JS,代码如下
蓝色理想放置GOOGLEAD的JS完整代码
首先建一个文件名为adbanner的JS,代码如下
CODE: [Copy to clipboard]
——————————————————————————–
function runCode() //定义一个运行代码的函数,
{
var code=event.srcElement.parentElement.children[0].value;//即要运行的代码。
var newwin=window.open('’,'’,'’); //打开一个窗口并赋给变量newwin。
newwin.opener = null // 防止代码对论谈页面修改
newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
newwin.document.close();
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(”?”))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i for(i=0;!x&&d.layers&&i if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v==’show’)?’visible’:(v=’hide’)?’hidden’:v; }
obj.visibility=v; }
}
// AD Banner object
function ADBanner(){
this.htmlcode = “”;// Non image banner’s html code
this.href = “”;// Link’s href attrib
this.imgsrc = “”;// Image’s src attrib
this.imgwidth = “”;// Image’s width attrib
this.imgheight = “”;// Image’s height attrib
this.imgalt = “”;// Image’s alt attrib
this.imgborder = “”;// Image’s border attrib
this.weight = 1;// Banner’s show weight
this.place = 1// Banner’s place
this.type = 1;// Banner’s type
}
// Make Banner objects array
function CreatBanners(aBanners, aNum){
for( var i=0; i aBanners = new ADBanner();
}
}
// Show banner
function showbanner(aPlace, aType, aBannerID)
{
var amount = ADBanners.length;
var includeList = new Array(amount);
if (!document.usedBanners){
document.usedBanners = new Array(amount);
for (var i=0; i document.usedBanners = -1;
}
var usedList = document.usedBanners;
if (arguments.length == 2){
var j = 0;
var sum = 0;
for(var i=0; iif (ADBanners.place == aPlace && ADBanners.type == aType){
if (usedList != i){
includeList[j] = i;
j++;
sum = sum + ADBanners.weight;
}
}
}
if (sum <= 0)
return;
var rndNum = Math.round(Math.random() * sum);
i = 0;
j = 0;
while (true) {
j = j + ADBanners[includeList].weight;
if (j >= rndNum)
break;
i++;
}
i = includeList;
}
else{
if (aBannerID >= 0 && aBannerID < amount)
i = aBannerID;
else
return;
}
usedList = i;
if (ADBanners.htmlcode == “”)
document.write(’
‘);
else
document.write(ADBanners.htmlcode);
}
var ADBanners = new Array();
CreatBanners(ADBanners, 1);
ADBanners[0].htmlcode = ‘google_ad_client = “pub-0614643359718668″;google_ad_width = 728;google_ad_height = 90;google_ad_format = “728×90_as”;google_ad_channel =”";google_color_border = “FF4500″;google_color_bg = “FFEBCD”;google_color_link = “DE7008″;google_color_url = “E0AD12″;google_color_text = “8B4513″;‘;
ADBanners[0].weight = 20;
ADBanners[0].place= 6;
ADBanners[0].type = 6;
此代码当中CreatBanners(ADBanners, 1); 这里的数字设置广告数量,如果只放一个GOOGLE就设置1了.,
ADBanners[0].htmlcode = 这里里面填写GOOGLE AD的广告代码,请注意,必须写成一行
ADBanners[0].place= 6;
ADBanners[0].type = 6; 要调用的序号,具体偶不清楚,哈哈
弄好后,在网页HEAD中插入
在要放广告的地方插入
showbanner(6,6);
这里的数字是和 ADBANNER里的数字对应的,
————————over——————