牽狗和拖死狗還是JS!方便快捷,狗死了只需刪除或重命名JS文件了事!
/ m$ m- p, y) I8 k/ h- b2 {
5 S V8 y* l$ n$ p) ]' U7 q+ q現特發佈一段狗狗的JS代碼:)
. _+ k, D9 ~* {, g4 I; h& q$ l$ j% `3 h
希望大家用得開心,有分的請加分,有精的請加精,謝謝:)3 Q" I9 P9 o2 L, q4 a" A) i& X5 s
- E8 `9 ]5 d, c! x======================================% f0 a* V# t- f" Q& c
6 k5 E7 `& h* V' s
首先建一個文件名為adbanner的JS,代碼如下:
/ X9 K4 R* G( @6 c( ^- G1 x
, e: r3 q4 ^8 X2 m* x
; l& s( h& y. L CODE: [Copy to clipboard] 5 L7 ?. |, a0 V- X) a0 l
<!-- AD rotator script written entirely in JavaScript -->
; K1 X2 b% f3 F8 T5 T+ }% I! a<!-- Written by WenWei, 2002/03/03. E-mail: [email protected] -->
" H( |$ _1 C) V3 r" c9 T9 w5 U( J<!-- ASP 2 JS Written by 小荷, 2003/05/28. E-mail: [email protected] -->4 V* w; M# k# M
<!-- Member Of Blueidea Web Team. -->
h# |3 Q, a, j# k( v5 K4 ?/ L4 \ Z<!-- Welcome to www.blueidea.com. -->
1 b+ u+ |$ }1 D; R$ Y8 Y+ V7 E* b9 V0 W: K6 P" T" Y
function runCode() //定義一個運行代碼的函數,
, x5 r0 ^& S/ F% `1 l* n3 {4 P{
) T) J% ^* U1 y& T: f% m ` var code=event.srcElement.parentElement.children[0].value;//即要運行的代碼。& L& W% S, S' X
var newwin=window.open('','',''); //打開一個窗口並賦給變量newwin。
# T% s$ |* g) s& v( {1 p) t newwin.opener = null // 防止代碼對論談頁面修改" b/ m. R& c) w' l, d" {; y7 _
newwin.document.write(code); //向這個打開的窗口中寫入代碼code,這樣就實現了運行代碼功能。
+ O9 }3 w3 @/ h8 N& G1 [# v# o newwin.document.close();& I3 R U4 t" c4 o6 N
}, L7 `+ Y( G0 f, i
/ k0 q F8 l1 {function MM_findObj(n, d) { //v4.013 g5 e' j2 W# o
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {1 q6 S: {/ r! I5 x
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
% r @5 i7 C! a0 E3 d7 h if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];+ ]0 ? V4 `, P- Y7 u+ n
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
8 R. I( z4 @! \; B if(!x && d.getElementById) x=d.getElementById(n); return x; t7 e5 G" p* N/ y2 l' f1 h# Z" A
}* c2 e/ z0 T2 X6 k1 Z# T7 Z
$ E5 _7 `: w- }/ h8 p$ L9 f2 Z3 xfunction MM_showHideLayers() { //v3.0; K: I: v/ L1 X# F k
var i,p,v,obj,args=MM_showHideLayers.arguments;
! T2 g* C* K- t; t for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];
" W0 r$ r4 e; [& \6 T8 }1 n if (obj.style) { obj=obj.style; v=(v=='show')?'visible' v='hide')?'hidden':v; }
7 f% I1 d9 _ @' r; U+ `6 a obj.visibility=v; }4 j) Z% F/ z' W% N
}& P5 n7 K2 @0 I; k( h" p0 O
2 J* t# K- x" X
// AD Banner object* L& |# O' k" |+ g0 ~6 ~2 X7 _' p, n5 o
function ADBanner(){: N' ^* y4 L) Z& i( q9 k- C
this.htmlcode = "";// Non image banner's html code
6 l+ x, E7 a3 r( Z- t4 K' ~8 I! i; N this.href = "";// Link's href attrib
, c5 L. s, M8 r& a2 W this.imgsrc = "";// Image's src attrib
1 r+ q' I6 n; Z& L, H: G( b this.imgwidth = "";// Image's width attrib
+ K; n0 d& n: y& c this.imgheight = "";// Image's height attrib
; a4 f7 z3 ^5 t# D8 E; ~ this.imgalt = "";// Image's alt attrib
7 q0 P) e6 _8 S* n( m- h4 z1 T this.imgborder = "";// Image's border attrib
, m( M1 q$ }! ]) j0 b this.weight = 1;// Banner's show weight
/ P+ F& R! Z& i+ K G6 j$ ]3 M this.place = 1// Banner's place2 g" B$ u* Y# p+ c3 j
this.type = 1;// Banner's type
8 @# b2 A$ V; J X/ ~4 T}5 w9 k2 j, @. c% ^1 M- l, m
' U7 a0 l* q4 D6 y' {" E
// Make Banner objects array
$ g0 z8 F; a3 w0 b5 T8 r% Ffunction CreatBanners(aBanners, aNum){
% n" B3 \5 ?. y2 i for( var i=0; i<aNum; i++ ){
% i# z | j8 l8 W: A aBanners = new ADBanner();
2 |( q1 v, |. A- S9 f& R }( ?; q; Q8 a. J6 W
}
1 w/ Q' a$ R; A; I" V0 P
5 `& c. h& r$ h6 F9 r# W1 B// Show banner% t) w9 t6 Z3 S" v
function showbanner(aPlace, aType, aBannerID)- @' D6 U1 U! t2 X( v) [
{
$ i0 T$ ~3 N# R. _0 u4 y% X var amount = ADBanners.length;
; l# s# v2 K5 S6 a6 P' x var includeList = new Array(amount);! `) a' Y0 }( z4 d: v: `
4 Q2 V5 H: `& i% Y) ] if (!document.usedBanners){7 c& r' B- `8 D
document.usedBanners = new Array(amount);
9 t9 F! V% f& V2 Y3 Rfor (var i=0; i<amount; i++)
, }3 t* P" W# {9 U* L document.usedBanners = -1;2 }1 O D% V2 K& b
}
: O2 Z& u; i7 e5 @4 m3 Z
) W! @" k& t/ r9 q var usedList = document.usedBanners;# {0 n+ ]0 z. f3 O9 |
) B6 Z" D. q8 M! L9 X, } if (arguments.length == 2){
! \# Z4 z) G% L2 I/ d& ?6 m+ ?; e var j = 0;
4 {1 k. R+ Z; ^( Z& W& ^ \: @/ ] var sum = 0;% `2 |1 j/ r. S4 q8 }8 X) n# A5 o
for(var i=0; i<amount; i++){$ s! K- l4 B: {- \
if (ADBanners.place == aPlace && ADBanners.type == aType){
# d/ Q' _3 H" P& u$ ]0 K! \if (usedList != i){
g: z7 ]0 P0 e+ U' z includeList[j] = i;
) J% ~+ |* W$ `3 C' Q j++;& C0 Y1 E" e0 Z' r
sum = sum + ADBanners.weight;3 X' P! }. |' F; {+ Y8 t9 P
}; S6 V7 h$ m# T+ I0 J5 Y2 R: g
}
% z/ L; G' k3 H6 q/ M' b$ K& ~/ G}/ M& o! |4 J+ ?, k
if (sum <= 0). E1 w/ r1 I# E' z/ Z
return;' W3 B; w$ t& D+ L% x
var rndNum = Math.round(Math.random() * sum);
1 F# h5 O9 K0 |: z7 `. p h% _3 ]7 f" H
i = 0;' l" b* u1 ]! k% x, @1 Y, E
j = 0;
/ ]0 d) B5 t' K' _5 {/ ^: [; i while (true) {
2 ^, Y4 ~) i# L1 R9 Z j = j + ADBanners[includeList].weight;, H5 o8 B. {) l) y2 w
if (j >= rndNum)
3 C/ L' G" J4 [; b9 j break;5 P' [0 e# X; o4 q
i++;
% o, }- z5 P' \+ {7 Q }1 h* f$ A# U7 p' w8 K
5 {" i0 d6 V5 D+ n. E& {% M# x
i = includeList;
) Q. \ z- h$ c. P' A1 `& F% D5 Z/ w }/ J/ c: K3 ?! Z s& [0 Z
else{
9 c7 F% R, g2 V$ ^5 x4 F0 xif (aBannerID >= 0 && aBannerID < amount)
8 Y+ R( T& k% G" |, N- u i = aBannerID;+ w9 D" D* y) d( _$ H3 t/ [
else, o+ K# H1 _6 _. ^0 m/ H, p
return;9 f, u6 u. ?" x
}
- T$ p8 _" m3 `2 k
3 I+ ^+ \/ D3 k- n2 d usedList = i;
8 G1 q5 r+ _7 @& n* x$ f5 t ^5 J
if (ADBanners.htmlcode == "")
7 Z( L. _3 X+ x 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>');
# r \/ ]( z( ^7 T1 m else
( y. d; c8 F6 K4 \ document.write(ADBanners.htmlcode);
|* Z; Q% ]6 m, o8 r8 _}
1 H6 }0 S! V8 |7 a5 a% q
- [9 @ f" X# f9 Svar ADBanners = new Array();
( k i+ a, h2 W$ b9 n0 J' ~' b% d" U" f K# w5 s$ C* i
CreatBanners(ADBanners, 1);( h( y. M& O) }6 E
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>';9 [3 b5 o! @8 E: }$ O6 [3 M
ADBanners[0].weight = 20;2 G2 Q/ [, S; j
ADBanners[0].place= 6;- S9 _+ I& ]0 N/ y$ Y$ U
ADBanners[0].type = 6;
. v. F% K2 u4 G) V/ I/ i- k ~4 r+ G. p3 ~9 s$ Z
5 ~1 c6 T/ B7 W) ?3 U
8 \1 z% c& [9 J+ C5 M6 A
9 R) f, i+ q# _3 M2 u& V- i
( _- z; B* D7 l+ y- T
M: M% c3 k; w- t# ~$ b N$ U9 A, k此代碼當中CreatBanners(ADBanners, 1); 這裡的數字設置廣告數量,如果只放一個GOOGLE就設置1了.,
- P3 W: d2 J) S) Z6 @9 {: v/ i
+ A: u) B/ J7 Q3 KADBanners[0].htmlcode = 這裡裡面填寫GOOGLE AD的廣告代碼,請注意,必須寫成一行
9 I* A `; @+ T. G2 q2 r* i! R" Q, C* b+ Q0 z
ADBanners[0].place= 6;
0 J+ B4 G) v( s% mADBanners[0].type = 6; 要調用的序號,具體偶不清楚,哈哈
x- O; B+ Y5 v u. j3 ]7 N. \9 x
弄好後,在網頁HEAD中插入& n( G( J N$ a- r' m% a# y
<script language="JavaScript" src="adbanner.js"></script>2 K# n0 u6 `1 ^ p3 Q
) d6 U* T( M9 R, X! z2 N& B6 X
在要放廣告的地方插入
* U7 Z& C9 G& e7 \2 Y<SCRIPT language=JavaScript>showbanner(6,6);</SCRIPT>9 g4 c& d: C: c- _' N8 z! W
/ g, l, A* v/ I$ x# q+ J
這裡的數字是和 ADBANNER裡的數字對應的," {7 T1 u5 B( m. W7 h
* z- D K9 r( e% N" O( o& C8 e
$ {7 T% ~. a' `$ N4 K x<img src="../images/emptylogo.gif" border="0">
: Q6 Z+ s% s: \& K# i8 P# ], K3 E
……完…… |