马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
- <!-- AD rotator script written entirely in javascript -->
- 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<d.forms.length;i++) x=d.forms[n];
- for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
- 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<aNum; 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<amount; i++)
- document.usedBanners = -1;
- }
- var usedList = document.usedBanners;
- if (arguments.length == 2){
- var j = 0;
- var sum = 0;
- for(var i=0; i<amount; i++){
- if (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('<A HREF="'+ ADBanners.href +'" target=_blank><IMG SRC="'+ ADBanners.imgsrc +'" WIDTH="'+ ADBanners.imgwidth +'" HEIGHT="'+ ADBanners.imgheight +'" ALT="'+ ADBanners.imgalt +'" BORDER="'+ ADBanners.imgborder +'"></A>');
- else
- document.write(ADBanners.htmlcode);
- }
- var ADBanners = new Array();
- CreatBanners(ADBanners, 1);
- ADBanners[0].htmlcode = '<script type="text/javascript">google_ad_client = "pub-0614643359718668";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_channel ="";google_color_border = "FF4500";google_color_bg = "FFEBCD";google_color_link = "DE7008";google_color_url = "E0AD12";google_color_text = "8B4513";</script><script type="text/javascript" src="[url]http://pagead2.googlesyndication.com/pagead/show_ads.js[/url]"></script>';
- 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中插入
- <script language="javascript" src="adbanner.js"></script>
- 在要放广告的地方插入
- <script language=javascript>showbanner(6,6);</SCRIPT>
复制代码 |