牽狗和拖死狗還是JS!方便快捷,狗死了只需刪除或重命名JS文件了事!
8 F: E4 L5 I' g. O* k2 }" Z4 ?" T/ ^" S0 f* A
現特發佈一段狗狗的JS代碼:)
8 S" u+ S/ H7 G: ?+ R6 G3 c* ]9 j& u" }0 [
希望大家用得開心,有分的請加分,有精的請加精,謝謝:)3 F5 I1 f) K9 p
1 f! h2 t4 H( v======================================
, q2 t/ z: l( a) M, O( J! r8 x/ f1 R/ q( U
首先建一個文件名為adbanner的JS,代碼如下:% Y. t( ]7 V. k$ {2 X2 _2 y: |
2 f: |6 m. d; d- r7 `0 u4 k& N# T
' D* y# {, L1 v: t6 ]
CODE: [Copy to clipboard] 6 s- d2 P6 G/ j6 u% F3 l
<!-- AD rotator script written entirely in JavaScript -->
! ~$ i7 d, ~7 ^( M+ v<!-- Written by WenWei, 2002/03/03. E-mail: [email protected] -->8 y; ]. c" C3 P- @% S2 X
<!-- ASP 2 JS Written by 小荷, 2003/05/28. E-mail: [email protected] -->
: \: X8 b1 G& c7 c+ N3 }" ^<!-- Member Of Blueidea Web Team. -->5 K9 O: u2 g( H$ ~6 b0 ]
<!-- Welcome to www.blueidea.com. -->( V% D% z, H# [( r5 P
% `3 K! [3 A$ }) }: ofunction runCode() //定義一個運行代碼的函數,, V: U* t; m) u
{
9 G3 X# g& N6 g7 X5 B4 |' x var code=event.srcElement.parentElement.children[0].value;//即要運行的代碼。9 M/ I" n+ ` C( }9 l& U
var newwin=window.open('','',''); //打開一個窗口並賦給變量newwin。* E$ ~4 f0 o" R* A8 F: ]
newwin.opener = null // 防止代碼對論談頁面修改# ~5 B. ]/ d* N0 f# h" `
newwin.document.write(code); //向這個打開的窗口中寫入代碼code,這樣就實現了運行代碼功能。% k& z4 Q+ E! u% v
newwin.document.close();
8 c/ O- m1 X: l5 Z; b} s0 r; ?/ U$ |
" l8 W& h; @0 Z/ Q; M1 d
function MM_findObj(n, d) { //v4.01* c) \( e, v6 [% x8 S
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
& w4 v* v1 Z, S7 n$ c: C d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
2 x1 ^0 P2 D+ O9 e9 z if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];6 s& D# B5 k, f- `- V, e% C7 z
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
: [0 }5 }4 |$ z; u) k if(!x && d.getElementById) x=d.getElementById(n); return x; s) R! l/ k3 _* K
}
5 K F2 l: w( i: o- `7 u
6 b' b% T9 B* w$ Lfunction MM_showHideLayers() { //v3.0
7 o2 u g" k0 x6 } B# \ var i,p,v,obj,args=MM_showHideLayers.arguments;
' g$ `4 W! B3 I: Z3 u+ W% B7 \$ l- d for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];% H/ q5 O2 q2 O, J3 _- W
if (obj.style) { obj=obj.style; v=(v=='show')?'visible'v='hide')?'hidden':v; }) `, |. m' V6 E) \) e
obj.visibility=v; }; B/ Z9 d9 ?2 q6 j0 d0 z
}
: S2 A; Q7 K8 K9 T7 o; J
+ h2 k8 p) a { c' O# A// AD Banner object
3 W: S- X# z& I( K# ?+ i- W7 { d, ~& Yfunction ADBanner(){
! k# S6 t0 Z1 { this.htmlcode = "";// Non image banner's html code
3 V3 t' [ j6 j0 ], k( |% I this.href = "";// Link's href attrib
. J8 ]0 Y3 Q) D! f( d) ~3 E: l this.imgsrc = "";// Image's src attrib
$ Q x9 p2 q4 Y* A0 m& z this.imgwidth = "";// Image's width attrib
9 q& g% @( i& K this.imgheight = "";// Image's height attrib+ g( P/ C" i5 T6 p& l, G5 Y
this.imgalt = "";// Image's alt attrib: n" [/ n9 T6 V" f
this.imgborder = "";// Image's border attrib
! k5 y0 f- C& k* V1 w this.weight = 1;// Banner's show weight$ B L* q7 G+ {! F* H
this.place = 1// Banner's place
" [, n% w$ r- B this.type = 1;// Banner's type" [* ]4 y2 H' E4 B9 R" P1 Y" S! l
}
- N8 n: A+ ~6 v/ z. O+ p2 f! |% i; l9 N+ G
// Make Banner objects array
: F) T- c. j7 E$ B" dfunction CreatBanners(aBanners, aNum){
! ?7 p. _& B' x) {. V for( var i=0; i<aNum; i++ ){
0 r1 _/ V4 U4 a& l3 X7 t H6 M aBanners = new ADBanner();
, b% a% D2 h0 l% d+ G4 a }8 a( t6 Q8 o6 b$ E; v8 J, {) d0 n/ @
}1 H0 }; | z0 L* ], r* p% `
1 a8 \) r7 l) D; \! V1 r( ]
// Show banner& C* f' b* G( ~3 t
function showbanner(aPlace, aType, aBannerID)
" n4 F8 ]5 h2 L5 X' M# K/ s0 ~{/ k6 @9 V% F/ p9 A
var amount = ADBanners.length;$ p/ M1 c' u9 B f/ G* y) ~1 E0 N4 \
var includeList = new Array(amount);
3 o. b) Z) q' B/ S) }* a# Y$ w% M. m! v2 H3 \" v
if (!document.usedBanners){
+ M. u* B& i. o document.usedBanners = new Array(amount);) {6 _ V0 O$ I8 u0 w
for (var i=0; i<amount; i++)
# F- F! p. D( z8 N) C+ R document.usedBanners = -1;
0 X. J3 z, A% e( S( w }
* U4 g3 R x' C6 e8 [0 g/ {/ v
; H6 U1 T: G% ] E3 G* E5 ` var usedList = document.usedBanners;
, H" i3 |" T K; P# X J) n7 c9 W0 n/ a S4 ?% `
if (arguments.length == 2){
8 v. s, }' `! k4 r6 y% R var j = 0;
8 b4 ^: ?8 @# U; N6 ? var sum = 0;& x$ z* U3 |, s) x3 @: e* O
for(var i=0; i<amount; i++){3 [$ ~( d8 a! X! K
if (ADBanners.place == aPlace && ADBanners.type == aType){% I0 z% d3 A* x* j
if (usedList != i){
* C' I& M: e8 M% C3 E0 y includeList[j] = i;
( q; p* E# z' C7 ^* P j++;
' B( |3 r( C6 l! W* r sum = sum + ADBanners.weight;! P+ w. P) \# |+ i5 A; i+ g
}- r. p2 y) V6 A4 ]% n5 x( e
}- r( s# c' u: \0 @" {8 z- ^0 { V" y
}' X% @/ m1 `) ^9 m) C
if (sum <= 0)
x! H8 T# i) y$ k4 ?, u9 g return;) Z. f; m L% y/ H
var rndNum = Math.round(Math.random() * sum);' D* R! z: e6 J6 o! }/ X& J
8 |. ]# r) _! k. \
i = 0;
) @5 _/ Y* {2 ]' N6 G N j = 0;
: h7 `# H. k, r+ b3 X9 @) ~ while (true) {& c/ c- T6 S8 V) z8 Q8 X
j = j + ADBanners[includeList].weight;! u- s( L* c; S5 k
if (j >= rndNum)
- K) | I: l. \3 O3 X break;) \& ]# ?4 c4 d/ t+ h
i++;
: ^+ v# F3 {& ~& {9 a8 T L }
6 L; K6 F4 @% x S6 T6 S
1 `/ q" w( b) i! t Y% h" G5 n i = includeList;
3 y# c E& A9 G: k1 J }: h' i( e) c7 @# X2 ^; U
else{( P: M3 f) G; v- P( ?& K
if (aBannerID >= 0 && aBannerID < amount), b' Z, c. w( |; m" v) B# o/ F
i = aBannerID;
3 }" v; L- G8 W4 H+ W2 @else
6 I0 p3 S U: F' q return;) k4 m- s1 H, Q* v$ b
}; j6 g' [4 ?! ^! g- q3 X% T
$ _8 F, Q ?& L, l1 f$ h
usedList = i;
) i7 ^2 y" y4 l% I k
) W! C; v6 A/ n9 {/ f if (ADBanners.htmlcode == ""), d$ Q, l, ]8 Y& \
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>');
1 N+ u, M1 N% N2 G/ u else
! m/ J r% O# k document.write(ADBanners.htmlcode);
* g, Y: V- k2 b! B: ^% c% ^1 j) f}
5 d5 @( f2 D4 {- _ Z" \( R8 s0 |2 E* m7 ]; [7 p
var ADBanners = new Array();
+ z1 u0 I* z( e8 E* S& F
9 N' d' l8 A7 ICreatBanners(ADBanners, 1);
: C s$ l1 v0 b8 tADBanners[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 D& f5 T6 f0 H4 p0 C/ O1 a2 OADBanners[0].weight = 20;' T# x- H$ B) K% J2 M
ADBanners[0].place= 6;
. _' Z$ [, B/ N4 A$ ZADBanners[0].type = 6;% v4 c# o7 n! O, T3 R
1 B' B5 @3 C. v! M
0 P/ d c: c4 S& W- _
5 A X: u% w5 c
# u A- W- \! I! z" R) L: a' {! ~
6 ~* K1 F( C3 K- ]* e* p7 h
+ N! A% x% b: Z" q此代碼當中CreatBanners(ADBanners, 1); 這裡的數字設置廣告數量,如果只放一個GOOGLE就設置1了.,
6 |6 ?5 y5 f; j( s
& n" h& O9 I1 @$ wADBanners[0].htmlcode = 這裡裡面填寫GOOGLE AD的廣告代碼,請注意,必須寫成一行
6 H" b1 L- Q0 ? r
- t$ U3 R; E0 G: ^2 LADBanners[0].place= 6;
5 u% S- M. i' V8 \" U& g3 v, QADBanners[0].type = 6; 要調用的序號,具體偶不清楚,哈哈
5 x* O# R8 z7 P4 H% l3 O F# ^5 f6 A/ @
弄好後,在網頁HEAD中插入, w8 a. l3 v) w# b' Q$ @
<script language="JavaScript" src="adbanner.js"></script>
+ Z/ @, H, |; t, i, t
! A, H& B# k+ Q/ B$ X& Q0 s在要放廣告的地方插入5 _/ T7 F( S+ i9 x8 Y" ^
<SCRIPT language=JavaScript>showbanner(6,6);</SCRIPT>3 k* ~- p" F; h
2 H( }# {8 g( d3 @& l2 t這裡的數字是和 ADBANNER裡的數字對應的,$ {' u4 z2 I$ W& g8 A) f! y
% g) ~, J$ P7 T& i
/ f( r' i9 { j; p1 M3 n<img src="../images/emptylogo.gif" border="0">( j! F- P3 X3 L
8 K$ w$ F1 a) U N ……完…… |