牽狗和拖死狗還是JS!方便快捷,狗死了只需刪除或重命名JS文件了事!
. L% z$ i1 r; b3 D
6 R- m& o, g( r* T% l; O現特發佈一段狗狗的JS代碼:)
% O% O% n7 E `6 d3 L$ {) }0 X+ T! C' n# t1 Y8 Y
希望大家用得開心,有分的請加分,有精的請加精,謝謝:)
8 |( c5 m+ ~' e$ P0 r5 \" q ~- q7 h ?) |6 h! u( d6 q- a
======================================0 @/ Z4 h7 E2 Y
! \& E- `8 J/ @7 ]- T, V- @
首先建一個文件名為adbanner的JS,代碼如下:3 R) N* K0 @7 d, k. d& }/ \
. [% f- p; V+ G
- x! F$ V, C' `7 r8 e CODE: [Copy to clipboard]
% ^/ K& n S! H5 N4 _0 O6 J8 _<!-- AD rotator script written entirely in JavaScript -->& j7 h# ?# A/ j. P
<!-- Written by WenWei, 2002/03/03. E-mail: [email protected] -->
/ ?6 @+ ~( r$ u4 x1 v0 w- ?9 L<!-- ASP 2 JS Written by 小荷, 2003/05/28. E-mail: [email protected] -->
( A o/ \. o" Q& z<!-- Member Of Blueidea Web Team. -->& Q& X( Y) M) Y! X! A* u) ]
<!-- Welcome to www.blueidea.com. -->
A* e+ _5 n# a. r6 i6 J* u3 u L3 e
function runCode() //定義一個運行代碼的函數,
8 J+ F9 E e) d5 v{
0 g$ y: Q$ ]7 K$ N# `/ i var code=event.srcElement.parentElement.children[0].value;//即要運行的代碼。) y# f& K& P4 R, c
var newwin=window.open('','',''); //打開一個窗口並賦給變量newwin。
) r" R% C6 w7 | newwin.opener = null // 防止代碼對論談頁面修改
9 q- F; T! f% n: n7 ] newwin.document.write(code); //向這個打開的窗口中寫入代碼code,這樣就實現了運行代碼功能。
# J4 b: N* {( M newwin.document.close();* ~8 v+ G$ v8 ?. z" M* I# q
}3 K0 A# ~9 I0 m! `% y* S) W
' c6 i7 b* Y6 Hfunction MM_findObj(n, d) { //v4.01
4 ?& a5 |5 q* |3 A$ C/ Z7 T- @$ d. g var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {. q0 e9 c% T! q8 Y( [" K
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
+ X2 p% g M3 v7 f+ M if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];2 b9 m' {2 J8 p
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);9 G6 U9 k4 { W5 X$ s6 g3 t
if(!x && d.getElementById) x=d.getElementById(n); return x;1 B4 z0 E* G6 Z6 h7 r. k q' a& b7 }
}6 L/ l8 G, N: d& \' i" y" Q- l
( S* M2 v; j4 tfunction MM_showHideLayers() { //v3.0
1 S0 \) o# N( @ var i,p,v,obj,args=MM_showHideLayers.arguments;& y* q& s% }- ?# z" n
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];
+ b: ~4 n. O/ S if (obj.style) { obj=obj.style; v=(v=='show')?'visible' v='hide')?'hidden':v; }
# g. P" S7 C2 y* G7 S' B obj.visibility=v; }+ [6 D" S a1 [' ?! j
}. z2 ^) u# Q% R0 K
* F5 \5 V/ c4 o+ b0 H4 W
// AD Banner object M3 q8 |% i- ^1 j8 v8 x
function ADBanner(){
" f9 ~, B' w+ h& \) v& P3 V9 Y* [ this.htmlcode = "";// Non image banner's html code" L: b( j! Y4 U- |) N% _
this.href = "";// Link's href attrib
* g7 t+ a0 ?8 ~2 e" c this.imgsrc = "";// Image's src attrib
/ J; T9 u- p$ k5 D9 x- H _ this.imgwidth = "";// Image's width attrib: F# L" N8 ?: a( Y4 u- ` [
this.imgheight = "";// Image's height attrib6 A/ `5 s/ h' {9 M
this.imgalt = "";// Image's alt attrib7 p, b* V$ _* T
this.imgborder = "";// Image's border attrib5 W0 {( n5 t! k8 F* B
this.weight = 1;// Banner's show weight
5 D$ a2 E% R6 a/ U this.place = 1// Banner's place' l1 C9 X9 c5 E7 w1 J
this.type = 1;// Banner's type6 c! \; z! x, t
}: [* S/ y% ^( `2 O- j) V
! G. r- j! u0 Z7 O8 M// Make Banner objects array+ R& D8 \1 J S
function CreatBanners(aBanners, aNum){( C, Z; T1 ^. i8 E
for( var i=0; i<aNum; i++ ){3 K7 {+ B z9 K, v* L4 ?% p
aBanners = new ADBanner();
1 V( O0 Q8 s4 Z) `( Q3 d }
1 X% R- O+ j% g. z; `}
' H$ K% v2 Q+ o3 N) t
8 M% ]' [& U4 H% k// Show banner
1 j: V! [0 u# L) e( R3 {) xfunction showbanner(aPlace, aType, aBannerID)8 [4 p4 j: T0 d8 [
{8 ]7 Q- I. S% o9 N% c& c+ E6 `. E
var amount = ADBanners.length;) w2 z: ?* y# Q5 Z: T% j
var includeList = new Array(amount);
6 R; o: j7 y" U. z; ]% z$ e: o P
! k; ~) I' c( {/ w, ?* F6 j* z$ T if (!document.usedBanners){
0 H4 g% w# b/ k7 Z# u document.usedBanners = new Array(amount);( t3 o$ J M5 g, r3 D
for (var i=0; i<amount; i++), U* P) @: S4 L; }" \
document.usedBanners = -1;
9 D/ L( \$ {# T4 ~; N }
" r: `) H) i$ z' X" u6 l0 F, c# ?& d) K9 {/ ^! ]! n: P# r
var usedList = document.usedBanners;
; d+ K! w. V8 T0 n' x# A/ i, A: y' M% Q4 M$ b) v/ Y
if (arguments.length == 2){
& B2 U7 {/ X/ C! K7 ~! e3 K+ C var j = 0;
3 V/ Q$ d' I' C7 n) d" n2 U var sum = 0;( H0 J2 ?+ l# B3 G
for(var i=0; i<amount; i++){. g/ k& S% w# p0 {0 I) f; s$ g
if (ADBanners.place == aPlace && ADBanners.type == aType){
: a3 _/ Z* g! I G$ Aif (usedList != i){
& w) ~& z* h' R) k5 r includeList[j] = i;( ^, F9 c \2 ^: b- n5 e4 _9 J
j++;
% e) I4 R5 [2 R7 t! `5 ]$ M9 T) o sum = sum + ADBanners.weight;
6 q/ k/ c p' F* q3 l9 l/ f }4 P8 |; O5 ] c ~) G" N; G$ b
}
7 I3 o# s; M; V' x}
. p1 Y2 O5 `$ y) T if (sum <= 0)5 X! Z4 G8 M) D. E- r1 e: j: H& G
return;: P) N3 {8 d3 g7 r0 P" j2 r
var rndNum = Math.round(Math.random() * sum);
1 z L2 k8 p0 [. ?$ y1 F6 c3 |! G4 a% ?3 H
i = 0;2 i1 a h% ^- l8 x: g# `1 [( N
j = 0;
% V! t( ]" M% y while (true) {
% A" J, p$ A# `9 Q& w$ p j = j + ADBanners[includeList].weight;
9 b. ~( m$ K$ C% M0 q; { if (j >= rndNum)
0 b( `0 r% P* |! D break;
O7 E* L% s1 f* J: A! L i++;2 o, M7 i2 c& b1 `/ w f9 F1 {6 _
}
* l2 ]3 J: U3 x9 o1 H6 z6 L$ _( m* W7 p1 Q' K+ O$ p, G
i = includeList;# ]# v3 M% z: p2 U
}
9 V/ P% r R1 c9 m else{
6 l& @! h1 @% L+ R* Jif (aBannerID >= 0 && aBannerID < amount)$ k7 `% z; W7 A+ \8 d
i = aBannerID;
8 E5 c) U- Q8 ~3 M3 y6 a- E7 ?9 m6 felse% S* T6 p5 K7 a# i5 D- g: B
return;
' }3 C6 ]8 _- U) l3 e- V: h4 u2 P# @ }
; b8 v! S i& Z; j. s
; o* [2 {2 t9 [0 y( z5 k usedList = i;1 X5 x: b- b3 ^8 O% D: m
0 q* h/ ^1 ~, t7 S/ M
if (ADBanners.htmlcode == "")
9 G5 M) ?1 Z. r( p/ p2 c* G 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>');
. T5 C9 {+ y+ d0 ]/ G3 s else; `3 c0 a7 N2 k; ?% L4 i+ r, M
document.write(ADBanners.htmlcode);
8 x9 W% m/ c/ C4 T5 _1 I}' q0 ~; G8 W# i* M( N
0 [; F! \: t0 Tvar ADBanners = new Array();
5 E% V2 I+ h, Y4 ?: B3 r: ^, i; {0 `( E) v: l1 Q" ~
CreatBanners(ADBanners, 1);
8 b: \$ K. o$ O6 r G) OADBanners[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>';
1 }) V* M4 ~. C) ]ADBanners[0].weight = 20;
. D% d+ B6 G9 l6 ZADBanners[0].place= 6;6 U( k& Q! G$ V* y, U
ADBanners[0].type = 6;
, b) l0 B/ b4 E4 M2 I+ k7 O% {0 Q$ u) B; x2 e
3 P0 r3 {$ R8 D) J' w9 ]6 V7 U1 R8 H ) y* A$ j0 q k7 m- d& v
8 E3 W3 U: a/ @
/ y+ E# l4 h2 H- q3 d* Z* M! u0 B
2 p2 f, D5 Y$ u! K) A此代碼當中CreatBanners(ADBanners, 1); 這裡的數字設置廣告數量,如果只放一個GOOGLE就設置1了.,, \+ z; A0 o( W1 C$ t4 I
, x7 i7 ~* h2 r4 v
ADBanners[0].htmlcode = 這裡裡面填寫GOOGLE AD的廣告代碼,請注意,必須寫成一行% z2 ?; n# P2 F$ m; ]
3 _/ s. \5 O K7 c, B9 E( O" FADBanners[0].place= 6;* o3 R6 ?# p; @- _" y" a
ADBanners[0].type = 6; 要調用的序號,具體偶不清楚,哈哈7 B1 F, Y6 ^1 S2 c
/ C& F) { }. g1 f1 `5 D) f3 _
弄好後,在網頁HEAD中插入
) ]- u" p3 L/ ?7 P7 D8 e6 Y+ A<script language="JavaScript" src="adbanner.js"></script>; r. w/ ~ W6 u6 Q5 z
# P. j B3 W8 ]& N0 \: ~8 Q" \ N在要放廣告的地方插入
. k7 S- T7 \* K- Z) T& w- P' S<SCRIPT language=JavaScript>showbanner(6,6);</SCRIPT>8 ?8 o' t* l, v* a- I
% m" b9 c0 E* M) |" M3 [這裡的數字是和 ADBANNER裡的數字對應的,
8 a5 R6 n- k8 t4 w _6 X* ^
; h9 E1 V' V1 C$ I# y5 C. X
1 f0 E3 a2 U2 j9 G! T x/ B4 y% @<img src="../images/emptylogo.gif" border="0">
7 G/ ^" R$ o7 W+ L$ W' p# W' R2 y
, N. T; T7 o" h8 s ……完…… |