首頁  >  文章  >  web前端  >  多广告投放代码 推荐_广告代码

多广告投放代码 推荐_广告代码

WBOY
WBOY原創
2016-05-16 19:24:181433瀏覽
adbanner.js
复制代码 代码如下:






document.write('<script>'+'ipt>'); <BR>function runCode() //定义一个运行代码的函数, <BR>{ <BR> if(1 == arguments.length) <BR> try{event = arguments[0];}catch(e){} <BR> var code=(event.target || event.srcElement).parentNode.childNodes[0].value;//即要运行的代码。 <BR> var newwin=window.open('','',''); //打开一个窗口并赋给变量newwin。 <BR> newwin.opener = null // 防止代码对论谈页面修改 <BR> newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。 <BR> newwin.document.close(); <BR>} <br><br>function MM_findObj(n, d) { //v4.01 <BR> var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { <BR> d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} <BR> if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; <BR> for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); <BR> if(!x && d.getElementById) x=d.getElementById(n); return x; <BR>} <br><br>function MM_showHideLayers() { //v3.0 <BR> var i,p,v,obj,args=MM_showHideLayers.arguments; <BR> for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; <BR> if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; } <BR> obj.visibility=v; } <BR>} <br><br>// AD Banner object <BR>function ADBanner(){ <BR> this.htmlcode = "";// Non image banner's html code <BR> this.href = "";// Link's href attrib <BR> this.imgsrc = "";// Image's src attrib <BR> this.imgwidth = "";// Image's width attrib <BR> this.imgheight = "";// Image's height attrib <BR> this.imgalt = "";// Image's alt attrib <BR> this.imgborder = "";// Image's border attrib <BR> this.weight = 1;// Banner's show weight <BR> this.place = 1// Banner's place <BR> this.type = 1;// Banner's type <BR> this.id = 0;// Banner's ID <BR>} <br><br>// Make Banner objects array <BR>function CreatBanners(aBanners, aNum){ <BR> for( var i=0; i<aNum; i++ ){ <BR> aBanners[i] = new ADBanner(); <BR> } <BR>} <br><br>// Show banner <BR>function showbanner(aPlace, aType, aBannerID) <BR>{ <BR> var amount = ADBanners.length; <BR> var includeList = new Array(amount); <br><br> if (!document.usedBanners){ <BR> document.usedBanners = new Array(amount); <BR>for (var i=0; i<amount; i++) <BR> document.usedBanners[i] = -1; <BR> } <br><br> var usedList = document.usedBanners; <br><br> if (arguments.length == 2){ <BR> var j = 0; <BR> var sum = 0; <BR>for(var i=0; i<amount; i++){ <BR>if (ADBanners[i].place == aPlace && ADBanners[i].type == aType){ <BR>if (usedList[i] != i){ <BR> includeList[j] = i; <BR> j++; <BR> sum = sum + ADBanners[i].weight; <BR> } <BR> } <BR> } <BR> if (sum <= 0) <BR> return; <BR> var rndNum = Math.round(Math.random() * sum); <br><br> i = 0; <BR> j = 0; <BR> while (true) { <BR> j = j + ADBanners[includeList[i]].weight; <BR> if (j >= rndNum) <BR> break; <BR> i++; <BR> } <br><br> i = includeList[i]; <BR> } <BR> else{ <BR>if (aBannerID >= 0 && aBannerID < amount) <BR> i = aBannerID; <BR>else <BR> return; <BR> } <br><br> usedList[i] = i; <br><br> if (ADBanners[i].htmlcode == "") <BR> document.write('<A HREF="'+ ADBanners[i].href +'" target=_blank><IMG SRC="'+ ADBanners[i].imgsrc +'" WIDTH="'+ ADBanners[i].imgwidth +'" HEIGHT="'+ ADBanners[i].imgheight +'" ALT="'+ ADBanners[i].imgalt +'" BORDER="'+ ADBanners[i].imgborder +'">'); <BR> else <BR> document.write(ADBanners[i].htmlcode); <BR> document.write('<script src=/common/jsbanner/redirect.asp?action=visit&id='+ADBanners[i].id+' >'+'cript>') <BR>} <br><br>var ADBanners = new Array(); <br><br>CreatBanners(ADBanners, 7); <br><br>ADBanners[0].htmlcode = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="533" height="104"><param name=movie value="http://gg.blueidea.com/2005/www/533-104.swf"><PARAM NAME=wmode VALUE=opaque><param name=quality value=autolow><embed src="http://gg.blueidea.com/2005/www/533-104.swf" quality=autolow pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="533" height="104"> '; <BR>ADBanners[0].weight = 10; <BR>ADBanners[0].place= 2; <BR>ADBanners[0].type = 2; <BR>ADBanners[0].id = 38; <br><br>ADBanners[1].imgsrc = "http://gg.blueidea.com/2006/chinaok/208x32.gif"; <BR>ADBanners[1].href = "http://www.chinaok.net.cn"; <BR>ADBanners[1].imgwidth = "208"; <BR>ADBanners[1].imgheight = "32"; <BR>ADBanners[1].imgalt = "建站、改版、推广,找欧科动力"; <BR>ADBanners[1].weight = 10; <BR>ADBanners[1].place= 4; <BR>ADBanners[1].type = 4; <BR>ADBanners[1].id = 42; <br><br>ADBanners[2].htmlcode = '<script type="text/javascript">google_ad_client = "pub-5841412030047197";google_alternate_color = "CCCCD4";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_channel ="7977407778";google_ad_type = "text_image";google_color_border = "6699CC";google_color_bg = "003366";google_color_link = "FFFFFF";google_color_url = "AECCEB";google_color_text = "AECCEB";</script><script></script>';
ADBanners[2].weight    = 20;
ADBanners[2].place= 6;
ADBanners[2].type = 6;
ADBanners[2].id = 46;

ADBanners[3].imgsrc    = "http://gg.blueidea.com/2006/chinaok/468x60.gif";
ADBanners[3].href = "http://www.chinaok.net.cn";
ADBanners[3].imgwidth  = "468";
ADBanners[3].imgheight = "60";
ADBanners[3].imgalt    = "建站、改版、推广,找欧科动力";
ADBanners[3].weight    = 30;
ADBanners[3].place= 5;
ADBanners[3].type = 5;
ADBanners[3].id = 56;

ADBanners[4].imgsrc    = "http://gg.blueidea.com/2006/now/208x32.gif";
ADBanners[4].href = "http://www.now.cn";
ADBanners[4].imgwidth  = "208";
ADBanners[4].imgheight = "32";
ADBanners[4].imgalt    = "域名免费试用";
ADBanners[4].weight    = 20;
ADBanners[4].place= 4;
ADBanners[4].type = 4;
ADBanners[4].id = 41;

ADBanners[5].htmlcode  = '<script>google_ad_client = "pub-5841412030047197";google_ad_width = 728;google_ad_height = 90;google_alternate_ad_url = "http://www.blueidea.com/js/google_adsense_script.html";google_ad_format = "728x90_as";google_ad_channel ="7977407778";google_ad_type = "text_image";google_color_border = "6699CC";google_color_bg = "003366";google_color_link = "FFFFFF";google_color_url = "AECCEB";google_color_text = "AECCEB";</script><script></script>

';
ADBanners[5].weight    = 10;
ADBanners[5].place= 1;
ADBanners[5].type = 1;
ADBanners[5].id = 29;

ADBanners[6].htmlcode  = '
多广告投放代码 推荐_广告代码 多广告投放代码 推荐_广告代码
';
ADBanners[6].weight    = 10;
ADBanners[6].place= 9;
ADBanners[6].type = 6;
ADBanners[6].id = 57;

调用方法:
复制代码 代码如下:

<script>showbanner(1,1);</script>
<script>showbanner(6,6);</script>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn