javascript新浪リアプロ広告実現コード
6682 ワード
今日は新浪のjsコードを調べてみました.バックスローの広告コードは学習の角度から見ても使う角度から見てもいいです.
以下は具体的なjsコードです.
以下は具体的なjsコードです.
/*
RotatorPB v3.1
Update by Dakular 2008-8-25
:new RotatorPB( )
: , ; ;cookie 24 ;
*/
if(typeof(RotatorPB)!='function'){
var RotatorPB=function (rad){
this.ary = new Array();
this.date = new Date();
this.w = rad.width;
this.h = rad.height;
this.num = rad.num;
this.o = rad.length;
this.id = RotatorPB.id++;
this.m = 'rpb_'+this.id;
this.n = new Array();
this.L = new Date();
this.e = 0;
var f;
var D = false;
var nn = 0;
//
for(var i=0; i var start = RotatorPB.strToDate(rad[i][2].replace('','').replace(' ',''));
var end = RotatorPB.strToDate(rad[i][3].replace('','').replace(' ',''),true);
if(this.date>start && this.date this.ary.push([rad[i][0], rad[i][1], rad[i][4]]);
}
}
this.o = this.ary.length;
// id
for(var i=0;i f=this.m+'_'+(i+1);
g=RotatorPB.G(f);
if(g!=''){
this.n[i]=g;
D=true;
}else {
this.n[i]=0;
}
}
if(!D){
var r=Math.ceil(Math.random()*this.o);
var t=this.m+'_'+r;
RotatorPB.S(t,this.L.getTime(),1440);
this.e=r;
if(this.o==1){RotatorPB.S('s_dl',r,1440);}
//return r;
}else {
var R=this.n.join(',').split(',');
var k=R.sort();
var max=Number(k[k.length-1]);
var min=Number(k[0]);
var F;
for(var i=0;i if(max==this.n[i]){
F=i+1;
break;
}
}
if(typeof(F)!='undefined'){
G=this.m+'_'+F;
H=Number(RotatorPB.G(G));
I=F%this.o+1;
J=this.m+'_'+I;
RotatorPB.S(J,this.L.getTime(),1440);
if(this.o==1){
I=-RotatorPB.G('s_dl');
if(I==0){I=1;RotatorPB.S('s_dl',1,1440);}
RotatorPB.S('s_dl',I,1440);
}
this.e=I;
//return I;
}
}
//Show AD
if(this.e==0 || this.ary.length==0) return; //
if(this.e==-1) return; // : /
var n = this.e-1;
var btsrc = this.ary[n][0];
var bturl = this.ary[n][1];
var bttype = btsrc.substring(btsrc.length-3).toLowerCase();
if(bttype=='.js'){ //js
document.write(''); return;
<br> }else if(bttype!='htm' && bttype!='tml'){
<br> sinabturl = "http://d1.sina.com.cn/d1images/pb/pbv4.html?"+bturl+"${}"+bttype+"${}"+btsrc;
<br> }else{
<br> sinabturl = btsrc;
<br> }
<br> try{
<br> aryADSeq.push("openWindowBack()");
<br> }catch(e){
<br> openWindowBack();
<br> }
<br> if(this.ary[n][2]!=""){ //
<br> var oImg = new Image();
<br> oImg.src = this.ary[n][2];
<br> }
<br> };
<br> RotatorPB.id=1;
<br> RotatorPB.G=function (N){
<br> var c=document.cookie.split("; ");
<br> for(var i=0;i<c.length;i++){
<br> var d=c[i].split("=");
<br> if(d[0]==N)return unescape(d[1]);
<br> }return '';
<br> };
<br> RotatorPB.S=function (N,V,Q){
<br> var L=new Date();
<br> var z=new Date(L.getTime()+Q*60000);
<br> document.cookie=N+"="+escape(V)+"; path=/; expires="+z.toGMTString()+";";
<br> };
<br> RotatorPB.strToDate = function(str,ext){
<br> var arys = new Array();
<br> arys = str.split('-');
<br> var newDate = new Date(arys[0],arys[1]-1,arys[2],9,0,0);
<br> if(ext){
<br> newDate = new Date(newDate.getTime()+1000*60*60*24);
<br> }
<br> return newDate;
<br> }
<br> var openWindowBack = function(){
<br> var popUpWin2 = open(sinabturl, (window.name!="popUpWin2")?"popUpWin2":"", "width=1,height=1,top=4000,left=3000");
<br> }
<br>};
<br>
</div>
<br>
<br> :
<br>
<div class="codetitle">
<span><u></u></span> :
</div>
<div class="codebody" id="code52817">
<br><script src="rotator_pb.js">
<br>//<![CDATA[
<br>var rpb = new Array();
<br>rpb.num = 2; //
<br><!--2220E7B88D58-->//
<br>rpb.push(["http://img.jb51.net/demo/images/beitou.jpg", "//www.jb51.net", "<startdate>2009-4-15</startdate>", "<enddate>2009-8-15</enddate>", ""]);
<br><!--$$ litong/2009-4-15 ~ 2009-8-15/B $-->
<br>new RotatorPB(rpb);
<br>//]]>
<br>
上のbeitou.jpgは写真の住所です.後ろのリンクです.開始日の終了日などは参考にしてください.