A lot of Sina's Advertising Code has been widely spread by the majority of webmasters. If you have time to look at it, their code is all written class, a lot of good things. Today, I checked Sina's js Code and found a back-cast Advertising Code, which is good from both the learning and usage perspectives. But I found a problem that will be blocked.
The following is the specific js Code.
The Code is as follows:
/*
Carousel back-cast RotatorPB v3.1
Update by Dakular 2008-8-25
Format: new RotatorPB (AD array)
Note: The first access appears randomly, and then the access sequence is carousel; expired ads are automatically filtered; cookie time is 24 hours; when the number of commercial ads is insufficient
*/
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;
// Filter invalid ads
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;
// Obtain the 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 no advertisement is displayed, It is not displayed.
If (this. e =-1) return; // when there is only one advertisement, the first or odd refresh is always displayed.
Var n = this. The 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 ('