牽狗和拖死狗還是JS!方便快捷,狗死了只需刪除或重命名JS文件了事!
6 R5 [$ L- ~8 N1 Q: Y
4 O7 H3 c/ o: o4 h現特發佈一段狗狗的JS代碼:)
- C2 p; [" U4 H0 a) Y0 L6 s& E7 q3 E3 G9 ]& b/ U, I4 V- H- y
希望大家用得開心,有分的請加分,有精的請加精,謝謝:)7 M: l( [2 W5 f# ?& S
- F/ F \& K% ^) B% V. g; ^! K2 O; D======================================
k& G, V. v( d; n0 W: B/ \
! E" U/ j; f' W* u% @* D首先建一個文件名為adbanner的JS,代碼如下:
2 e3 ~ w1 f) b( t$ ~
+ x/ k+ U6 t& B& i! ]
: T- p" L$ a- n9 {6 a CODE: [Copy to clipboard]
! z! L2 @6 ]$ L! c1 K- }<!-- AD rotator script written entirely in JavaScript -->
" `2 |3 w) C X0 }! B. e<!-- Written by WenWei, 2002/03/03. E-mail: [email protected] -->
2 ^. S: l- Q1 Z" l* ]% }$ s<!-- ASP 2 JS Written by 小荷, 2003/05/28. E-mail: [email protected] -->' q; J; {! E8 R' p) p+ C" V
<!-- Member Of Blueidea Web Team. -->4 f4 s" f @5 F4 L) R0 H
<!-- Welcome to www.blueidea.com. -->0 X, ?* C) j8 s+ k) g5 y
% A1 J" y9 r gfunction runCode() //定義一個運行代碼的函數,
/ P% f) m9 u+ L! D z{
' i% E: |2 t1 e, N& b var code=event.srcElement.parentElement.children[0].value;//即要運行的代碼。: ~8 q \, n! v) ^$ c$ C# D8 j& G% U
var newwin=window.open('','',''); //打開一個窗口並賦給變量newwin。2 J$ H1 L4 Q6 v3 Q
newwin.opener = null // 防止代碼對論談頁面修改
6 U8 {' J; C+ i0 l! n newwin.document.write(code); //向這個打開的窗口中寫入代碼code,這樣就實現了運行代碼功能。' B2 P8 a5 x2 T: H7 c4 Q
newwin.document.close();( ] `: q( v. u+ I$ k
}
# O+ ^# j" B5 p! b, {6 n x8 {
: t% z/ B5 ]9 p! k9 W y/ e' [function MM_findObj(n, d) { //v4.01: `9 ~9 w {! P# W: \
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {: Y- E) a0 V& W) E0 J8 K9 W
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}5 w* x+ @ Y, h+ K2 t: z
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];5 C( _1 x' N) t* I
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);9 o9 c0 ^1 A! F! h
if(!x && d.getElementById) x=d.getElementById(n); return x;
8 v- l e. P9 _' n}$ ~9 M$ E [0 g: @9 a6 i. e
& g& a, q& C: f6 Wfunction MM_showHideLayers() { //v3.0, ~1 A' t3 s" A* b- c8 K
var i,p,v,obj,args=MM_showHideLayers.arguments;
% J, [. \' l! ~: s5 R for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];/ Z' l" z! @5 ?% ?) W6 W
if (obj.style) { obj=obj.style; v=(v=='show')?'visible'v='hide')?'hidden':v; }
( m: T/ s) j$ p! v/ P$ Y2 V2 Q% T obj.visibility=v; }& h) c4 x1 o' W! k) _5 M5 u- ^ J
}9 Y+ y) O0 B* u* h: _
+ N0 [1 u1 K3 y" Z7 P
// AD Banner object
2 J. ]- Q& r/ E- V" Dfunction ADBanner(){' A; k2 N% R/ W0 C/ {) w
this.htmlcode = "";// Non image banner's html code1 c* A1 G, i8 W* y: `) `" C
this.href = "";// Link's href attrib
% L% E2 s; D, n# E+ P N: Z. J8 I+ i this.imgsrc = "";// Image's src attrib
5 s. W+ _% i' E this.imgwidth = "";// Image's width attrib) d# s E" T. V, H" t1 w/ f/ }
this.imgheight = "";// Image's height attrib
; b2 s( ?" h% L this.imgalt = "";// Image's alt attrib# y! Y, W* o" Y: {6 Z
this.imgborder = "";// Image's border attrib; Z6 a" I7 D( ?# b: U" p
this.weight = 1;// Banner's show weight7 K+ T4 C; J+ F; } z% ^5 b' t# H
this.place = 1// Banner's place- b0 O& t, \0 f; |4 \
this.type = 1;// Banner's type1 S) ]" Y' s7 G: u3 J' j- }5 @
}& x& v9 l& J: C: \% K
* c& U& J/ u9 _1 q+ y// Make Banner objects array
6 L; [0 j6 a! `( j4 T( Ofunction CreatBanners(aBanners, aNum){. w! U1 h u K4 Q
for( var i=0; i<aNum; i++ ){
) o7 L: ]1 m" k8 x. E9 s. P aBanners = new ADBanner();* X2 j2 q& ? R
}& h+ K3 @' u, n8 z
}( D/ s) v+ ?. a1 f( A4 q- A
" O0 O3 }& X8 X( ^! P
// Show banner
! `+ I, {5 Y( L! h0 {" m. |; lfunction showbanner(aPlace, aType, aBannerID)2 k" ?9 |; m$ \7 O0 O
{2 s ~; l4 B$ t# J) |
var amount = ADBanners.length;6 n0 n8 K8 M/ m) H, F, ?
var includeList = new Array(amount);
& u) F8 T V/ I a# e# h5 K
9 f) h/ w% q" e if (!document.usedBanners){
7 S$ a: z ~/ c document.usedBanners = new Array(amount);
( P) q0 ~3 U/ D: Lfor (var i=0; i<amount; i++)
6 X$ ^% M! Y p* O document.usedBanners = -1; A$ X6 A" @, ?' D1 U+ h' ]- k V
}
! M0 E0 A- J1 b1 m! l. @3 K: S' c i4 t. N
var usedList = document.usedBanners;
# ~; O" c2 w0 G' L6 q) P! D6 c. C5 O2 U9 M, U5 C! j$ \
if (arguments.length == 2){& p2 b$ W, [; X+ C% G4 O
var j = 0;( v( i# T) Z$ {9 t* O3 ]7 l
var sum = 0;
, g8 m! o5 @. y- sfor(var i=0; i<amount; i++){
/ Q2 A# B+ h+ E% \7 b3 @" Bif (ADBanners.place == aPlace && ADBanners.type == aType){
3 j0 I4 h) W% H) ]if (usedList != i){ v7 ]/ E5 Z0 a
includeList[j] = i;# X' B2 i2 }9 n( ]! o! J+ w
j++;2 @( a2 Z/ Q1 g$ X7 b
sum = sum + ADBanners.weight;7 y* J: s1 m, c" x6 X' Z
}
/ \1 D; o( |9 K6 { }( J, d/ B: {/ `$ {; x6 k
}
% [! x1 E8 k$ `# w if (sum <= 0)' ^# A' c/ j7 M9 e* k& Q: ^$ f* l1 Y# L
return;( B+ [. B& \" `! m, Q
var rndNum = Math.round(Math.random() * sum);9 B7 f# E6 T$ b4 o
9 |# C. t* H& m" Y: K; g+ N# C0 b i = 0;
9 f( c$ M5 U2 p) R, ]1 x j = 0;4 C5 l9 ?4 o* w$ ^
while (true) {
& h! C# |, @; J/ q j = j + ADBanners[includeList].weight;/ E- W* w1 j) o5 X
if (j >= rndNum)
8 H) M# e1 \1 r' K6 ] L break;
% T4 B4 d# u! k. P6 l1 I, s i++;
) \7 y" ?0 k0 h3 h }6 S' n# K! M3 S% T' [
2 q$ \1 m5 c8 u% V5 q m
i = includeList;
3 A U' \. w0 H2 j: z3 \ }
+ Y6 Z$ h* I" V else{8 }) N, \9 s2 L; G
if (aBannerID >= 0 && aBannerID < amount)% a; v2 e/ F* B. D$ i+ B$ H$ M g
i = aBannerID;- F ~* d/ m; W1 ]" G8 Z
else
- X. Y9 t+ D# r3 [# q return;
9 Q7 X) s! V1 I: n7 w- N* J }
3 ~/ p% R* d( X4 P
5 h$ i* K$ v: v H) {+ Z usedList = i;
8 z& r& F- @7 a$ L/ d4 P4 p
. v. T. f. h$ [* ` if (ADBanners.htmlcode == "")
7 |/ C6 X7 ^3 [/ o& |* I6 B 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>');
5 M5 c9 Q. }+ t! S) s b else; e/ b+ `+ O4 q. `6 j6 ?* e" Y* L
document.write(ADBanners.htmlcode);* F: U8 E8 o& q% l6 j0 D8 J+ d
}
9 Q" h B) |# D& R: ], \; S& V; U3 w$ @$ t# ^" K: E
var ADBanners = new Array();$ c' H* B3 t! n6 f
+ c8 u* I" ]: S2 w: A9 eCreatBanners(ADBanners, 1);1 i7 o4 S$ u/ v+ Z0 z2 I0 n
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="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';8 y5 s" y! R1 i& s& O) \
ADBanners[0].weight = 20;
. v' ^$ D; C8 J# r1 J: IADBanners[0].place= 6;% _! o, J0 z6 z! H( p: ^. f
ADBanners[0].type = 6;' b' D+ p5 d- m( S: @
7 [3 Q1 k4 i) s h
) R, K J4 M6 D+ T1 d7 m
, r6 `0 N6 F' { 5 F! M( Q3 C6 q! g0 f
q% U1 \" f- Z/ F q4 d: w& R
6 S, y# z( q, j' ~, l, q# p
此代碼當中CreatBanners(ADBanners, 1); 這裡的數字設置廣告數量,如果只放一個GOOGLE就設置1了.,1 X. ?) ]8 O' |4 A, U
A8 p* Q$ b OADBanners[0].htmlcode = 這裡裡面填寫GOOGLE AD的廣告代碼,請注意,必須寫成一行, J% w1 y. Q! L& s9 r8 e0 T
7 X1 m4 u8 s \- W" ?9 S6 r: KADBanners[0].place= 6;
8 T7 e1 `- V- ?+ f/ H0 MADBanners[0].type = 6; 要調用的序號,具體偶不清楚,哈哈
: H* s: ?: o. C* Q: Z% A- _, a1 F" M; C
弄好後,在網頁HEAD中插入
9 F" m5 u+ r) o6 W2 J- M [6 V<script language="JavaScript" src="adbanner.js"></script>
0 g% w! q1 {( j4 O' l- O7 h. X" c! i& A" L2 [
在要放廣告的地方插入. ]. o. C! e' c* ?
<SCRIPT language=JavaScript>showbanner(6,6);</SCRIPT>
3 T' }% v* y7 z+ |+ U3 X U
' S$ _/ [5 q- g' `0 H4 K h這裡的數字是和 ADBANNER裡的數字對應的,
" H' v3 c$ q* `+ \
p* A# }( W+ ]7 S* u5 O5 l N+ m: t+ r- z- A& }
<img src="../images/emptylogo.gif" border="0">
0 l4 B, E" V% ~: g9 Q. N% J/ u. v Q
……完…… |