牽狗和拖死狗還是JS!方便快捷,狗死了只需刪除或重命名JS文件了事!4 ]8 @) w$ M/ [8 v
3 G) [) ?. [$ t3 c/ K* j3 I現特發佈一段狗狗的JS代碼:)
! m- {) G3 d. } `8 W; ]% b* ?6 U$ P* B; Q' I. V
希望大家用得開心,有分的請加分,有精的請加精,謝謝:)
" V0 s' \" N2 n9 t$ q
: H" ^+ w9 v8 O6 g* i======================================
- W; C, O$ B1 G @1 s! g/ O
* F7 t+ @- p+ @首先建一個文件名為adbanner的JS,代碼如下:
0 @4 i7 h) V7 e4 a6 S( S
`. g r" n, Y6 _7 V1 p; }3 K
3 f" \* X, t! M9 q CODE: [Copy to clipboard] # U0 W8 @& [ i p+ U* g+ X! N
<!-- AD rotator script written entirely in JavaScript -->
`) M% n# P3 d- @* o: ~, t<!-- Written by WenWei, 2002/03/03. E-mail: [email protected] -->
' P; ]+ e9 O5 r) e# F# F$ P& `/ X<!-- ASP 2 JS Written by 小荷, 2003/05/28. E-mail: [email protected] -->8 z6 E8 D4 m$ }' j3 E
<!-- Member Of Blueidea Web Team. -->5 m4 e5 b% _, x- ^0 c8 N5 i
<!-- Welcome to www.blueidea.com. -->9 T$ S6 u7 H* n9 ]. p* {! y3 Y
9 _5 E) z3 o! U- H
function runCode() //定義一個運行代碼的函數,
- t) n1 i$ X- b9 {* x3 P{
E, [: b: R( Y, D9 y6 @' I: w var code=event.srcElement.parentElement.children[0].value;//即要運行的代碼。
7 r$ s# g- s7 h var newwin=window.open('','',''); //打開一個窗口並賦給變量newwin。: c2 Q7 }1 _1 b5 l: J
newwin.opener = null // 防止代碼對論談頁面修改3 t1 M" d' Y' R. ?3 |
newwin.document.write(code); //向這個打開的窗口中寫入代碼code,這樣就實現了運行代碼功能。5 J& S/ ?* J' t9 ?8 P
newwin.document.close();! E4 V$ c7 c* Z; U
}! o8 D0 k: Q3 o6 a% w+ L
# `* ^+ V' y! g) |: A0 Efunction MM_findObj(n, d) { //v4.01( w" K" U/ {0 b" B6 v2 I4 i
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {, P9 A# L4 s+ ?: L. l' P1 ?
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}7 u0 T+ Z1 Q* k3 B/ I. j5 U: [
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
6 a' j: n0 p0 |1 r2 V for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
$ G$ _, U" E- n V2 H# W if(!x && d.getElementById) x=d.getElementById(n); return x;
$ ^" y# M2 P3 @ t8 H}
% c3 _% J0 u/ A b. p$ `. ~4 r5 c3 P2 l) w( m; e' M/ N7 l2 J) T
function MM_showHideLayers() { //v3.0
7 N/ B4 C$ U* ~1 Y& Y var i,p,v,obj,args=MM_showHideLayers.arguments;# a( Q, T* m% M( _9 K3 g* p: R
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];, S1 ?1 `& d) {
if (obj.style) { obj=obj.style; v=(v=='show')?'visible' v='hide')?'hidden':v; }
8 `! N o* k/ G9 M) H, m, L obj.visibility=v; }( [+ m& v6 [$ j- [5 c
}
3 V& ~- [8 @5 w" Q% h; k; h2 z8 Q C( B2 q* e
// AD Banner object
# D( V& k0 z% o K# ffunction ADBanner(){, ]7 m7 T2 I0 Z
this.htmlcode = "";// Non image banner's html code
, A- q1 ?2 b% q5 l3 I this.href = "";// Link's href attrib
d) v4 u( i7 z4 Y this.imgsrc = "";// Image's src attrib
V1 W) w1 R4 s& T this.imgwidth = "";// Image's width attrib: `" R: f9 M) {- c$ R; C6 Y
this.imgheight = "";// Image's height attrib# o1 O6 `+ w' o
this.imgalt = "";// Image's alt attrib
. w+ r& |2 d; E9 B f this.imgborder = "";// Image's border attrib Y; C2 [; a J: K6 v
this.weight = 1;// Banner's show weight' M7 B; u4 C% U+ v4 k
this.place = 1// Banner's place1 y0 Z4 j" n' |# ]8 N8 S/ Z
this.type = 1;// Banner's type& }2 A( |- D% |: P8 e3 z
}- l, p/ W' A2 e" U( G: O' m3 d
, y# b$ i7 p9 I, y- ^ D& C$ ?// Make Banner objects array0 T$ R7 L5 H! m0 K4 \
function CreatBanners(aBanners, aNum){
d5 |4 O# R5 P- Q for( var i=0; i<aNum; i++ ){
6 x# O$ f1 }+ Z3 ~ aBanners = new ADBanner();
- x# Z0 j1 e0 q }4 g+ N i$ T/ Q- }) q# y
}( b1 o% u+ k$ B( l* O9 J( ^
; }& z* f( t( A6 a- o: _) i// Show banner
6 n" I9 c4 S% a3 U: R9 U. ffunction showbanner(aPlace, aType, aBannerID)
$ K7 m2 M- A& m7 ~, {) `+ f5 T{# F" P9 U! S$ k
var amount = ADBanners.length;7 K t1 g* R S, J* H: A" y; x3 n, @
var includeList = new Array(amount);% q- m. C5 w) D6 l4 S, [
2 z X% ~7 E7 r H if (!document.usedBanners){
9 f4 i9 T0 M1 F% J/ y& i document.usedBanners = new Array(amount);
5 A: M/ @; P) c3 p8 f/ [# o$ jfor (var i=0; i<amount; i++)* L# s6 L. N( I5 A( Q! Y
document.usedBanners = -1;; H5 R, C- Y4 l! d& O' a$ v) U1 K
}8 Y. E0 F3 m( D3 A- P6 C
! x1 o1 W5 ^9 |- W& |6 {
var usedList = document.usedBanners;
* z) l+ B4 A# D! y# u: R& U6 H7 p* M; Z. c) }
if (arguments.length == 2){
! _9 R/ t% J/ t" m5 } var j = 0;4 V9 L; [1 }# _0 m# d
var sum = 0;
Q! W8 V5 n1 t, b" K/ l; bfor(var i=0; i<amount; i++){
( `1 d; C& Z% D1 M" `2 J- N6 |if (ADBanners.place == aPlace && ADBanners.type == aType){5 i5 p% Z8 y; ?) q1 [3 }1 v2 \
if (usedList != i){
% @5 d1 E/ b- B includeList[j] = i;
3 e) ]0 q% J6 k4 d3 e3 o- d( x j++;
' K. X, q7 D0 s sum = sum + ADBanners.weight;; o) X5 h" k: _% q- O# K
}
9 o3 b' S) w. D9 z4 M, x }
, I; J" e! b. [}
% K5 S7 `! v/ @4 p4 T: y if (sum <= 0)1 k% p+ s# g+ }% d5 @
return;! ~, Y6 M) j E9 x K, ?
var rndNum = Math.round(Math.random() * sum);# U& w! I- x5 [( }9 a1 q0 I: E5 m, _
, p/ T1 _( V ]: j7 s
i = 0;
" ?3 c% I. L4 s1 W j = 0;
1 s4 ^% S t2 Y: N" q while (true) {
0 r3 E) z; H* l: q j = j + ADBanners[includeList].weight;( g2 B! j$ n9 _7 o# c$ n& q
if (j >= rndNum)0 h. X4 z' I' z, {2 G8 t0 }; f
break;6 p* g2 U: N8 ]4 @9 u
i++;, u- }+ O; s0 d' v0 i
}
4 L- E! ?2 U' ?, M A% Z# N4 r% m/ Y% j
i = includeList;% B/ M; c$ Y. x3 O5 F& K
}% j7 B% o! U9 @$ i1 ^( Z% G
else{
. Y. ^, q$ d( O2 z8 l; x( gif (aBannerID >= 0 && aBannerID < amount)9 N/ e- R" m% @, H$ T2 {1 m
i = aBannerID;0 ]8 j$ \, t& H ]: R
else# l* j) x; W: i2 F5 D- \& ?
return;
, s e: I$ {* x1 d3 L8 ] }
) y m3 g7 { E5 [# F7 B% _8 p1 z x+ {" T: g U5 U0 q ~" q
usedList = i;+ x9 ]6 y+ f, C% S) A3 C
2 M# E3 B+ p$ _" a- A if (ADBanners.htmlcode == "")
6 {% V# _# n# e8 W& ?: _7 ? 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>');
% ?) b" V" I/ G' T: Y t" W else4 ?/ K `& z# M5 |8 `
document.write(ADBanners.htmlcode);
( V/ ^7 a7 j! ^1 {" y" }: ]}' ` v( M8 Z; i0 D
) _3 x) i- c0 ? F2 t
var ADBanners = new Array();- T, v- Q2 U6 W3 Y
2 T+ W. {1 @1 i% f7 c. Y
CreatBanners(ADBanners, 1);9 U$ `, d* |( }1 S# |
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>';" `( T4 C- a) A; r' D! K
ADBanners[0].weight = 20;" z9 m5 J9 T W9 X8 P7 K+ M" m
ADBanners[0].place= 6;- B9 w$ X3 o# |
ADBanners[0].type = 6;8 O5 P; O" z* r
/ W5 O4 ~- S2 t6 ]" Q5 [7 Y& k4 s$ X
% H4 M/ b% S8 p' {" R* Y% {* [! q
, K( L4 l* u0 v4 O
+ B2 a7 M4 @" D6 y6 q
1 P3 e: g. X+ C; E0 e! Q! ?4 q& g( Q# F# D
此代碼當中CreatBanners(ADBanners, 1); 這裡的數字設置廣告數量,如果只放一個GOOGLE就設置1了.,- ]0 D( M% ~; }
. V9 x4 V' i- S; T- C- e# U& e
ADBanners[0].htmlcode = 這裡裡面填寫GOOGLE AD的廣告代碼,請注意,必須寫成一行+ s4 O5 D8 R6 f
8 F% T+ z3 [. p) T. W$ g9 B* ~0 E7 {ADBanners[0].place= 6;. l# G3 t2 K6 B: {8 I
ADBanners[0].type = 6; 要調用的序號,具體偶不清楚,哈哈0 L' J6 L" b" n& @) V% h
4 s8 x3 D* U3 r5 O弄好後,在網頁HEAD中插入! Q% h0 ~5 u5 R' e! n0 T- L. v+ J! a# ^
<script language="JavaScript" src="adbanner.js"></script>
. Q6 D9 h! r+ ?
6 _. ^' `+ X) L* T$ }在要放廣告的地方插入# G& r, ^4 W9 c' }- w, o
<SCRIPT language=JavaScript>showbanner(6,6);</SCRIPT>
7 {1 d# M1 k" H) M1 C
/ @8 r& l. i# F% G" q6 X% D這裡的數字是和 ADBANNER裡的數字對應的,+ E5 Q- S! _3 J* n1 ?2 Q
l- V0 V" ^* g$ z. ?1 ^) u2 f/ O% p6 g2 F1 B5 n) J
<img src="../images/emptylogo.gif" border="0">
1 |1 ]( a i h0 d& R
6 ?2 Z, X( l9 s p4 N ……完…… |