牽狗和拖死狗還是JS!方便快捷,狗死了只需刪除或重命名JS文件了事!! I& j" }; o5 k4 @, P. E( O
( R0 P# F9 s. t: c$ @) U
現特發佈一段狗狗的JS代碼:)4 P _4 `: a8 _% k4 k
3 g' f: m( n6 N+ O% C
希望大家用得開心,有分的請加分,有精的請加精,謝謝:)
- w0 }9 O0 e# j+ f" Q
" h% L3 s4 ]' m g9 u- p/ m* |' g======================================
E# j+ g9 g8 F5 k" |- x* [5 x
1 T' a: v9 c# O1 d首先建一個文件名為adbanner的JS,代碼如下: Q8 S1 R& q* ], @% \+ b2 {
|+ d4 \ ^' i3 Y9 h" f6 K
: U" K* V9 G* x; Z" Y+ o5 C CODE: [Copy to clipboard] * d% ]: @; Z$ U5 W2 u
<!-- AD rotator script written entirely in JavaScript -->
4 }( K: d6 K4 N/ l" M<!-- Written by WenWei, 2002/03/03. E-mail: [email protected] -->
5 p2 a8 Z2 M% Q6 e<!-- ASP 2 JS Written by 小荷, 2003/05/28. E-mail: [email protected] -->- \& ]; i! u: m! R8 m# \% D3 x
<!-- Member Of Blueidea Web Team. -->
. D0 V) q7 _, z1 O<!-- Welcome to www.blueidea.com. -->
( K5 a+ p/ g3 U0 J' b
+ o& S- B7 D' a9 Kfunction runCode() //定義一個運行代碼的函數,* g. D1 u' e7 Y# w! u3 l3 U7 \
{
( _( L1 f9 o# X! L& o% u var code=event.srcElement.parentElement.children[0].value;//即要運行的代碼。. |7 h$ H; h" ^& z% C6 l
var newwin=window.open('','',''); //打開一個窗口並賦給變量newwin。+ ?4 S6 q) g: _
newwin.opener = null // 防止代碼對論談頁面修改# v" R/ j, G4 J1 k9 O
newwin.document.write(code); //向這個打開的窗口中寫入代碼code,這樣就實現了運行代碼功能。
' n/ L; X4 ^. o" C4 g newwin.document.close();) m _$ R8 Q& }% O/ ^1 g" Y/ g/ V" _
}' ~- d2 X: [9 `, F
/ o1 M6 W% G$ s! @function MM_findObj(n, d) { //v4.016 h- T$ ] H$ y% o6 t
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { t1 }4 w O8 c1 a3 ~8 q
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}. @6 W% q' Y, X' ^
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
( ^+ I. r1 u$ C. [ for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);+ J2 K$ H, |+ {2 C/ t2 {! K3 w! i
if(!x && d.getElementById) x=d.getElementById(n); return x;
* D1 L8 R8 D% N, Y) u( h}
$ a" s$ ^- l3 n+ v, @7 W: G# ~8 k' t+ A# j
function MM_showHideLayers() { //v3.0/ J+ l! K% W: e6 t
var i,p,v,obj,args=MM_showHideLayers.arguments;
3 ^. @/ k8 s4 y for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args))!=null) { v=args[i+2];
: _4 M( E$ P7 Y/ \9 G$ O' t if (obj.style) { obj=obj.style; v=(v=='show')?'visible'v='hide')?'hidden':v; }6 v9 P- r- R2 Q7 D3 a+ @7 n+ c
obj.visibility=v; }) J0 P. t( Y* v1 U
}
: @- { Z+ S! _. L5 z# v) c2 C" E( M: _# |" G' M+ R
// AD Banner object Y& }6 R- Q; j) }) Q3 V0 s
function ADBanner(){
4 F+ O: U4 a9 [9 D$ d' Z- G this.htmlcode = "";// Non image banner's html code6 }' P ^6 P9 u$ X
this.href = "";// Link's href attrib7 l0 q1 [ V, y
this.imgsrc = "";// Image's src attrib8 l* X7 b4 E% F z( j
this.imgwidth = "";// Image's width attrib
$ b8 g9 c: X+ Y this.imgheight = "";// Image's height attrib
! N" s* ^+ ^0 `6 a M' n4 n this.imgalt = "";// Image's alt attrib5 ]* I. P7 E2 u8 C: n+ M; R; {
this.imgborder = "";// Image's border attrib& r' }# j4 v6 ]+ o4 M/ H
this.weight = 1;// Banner's show weight
. Z" G' n, b, j" n6 K2 o$ N e this.place = 1// Banner's place+ s, j" L/ P7 p. e l, z
this.type = 1;// Banner's type
) w3 ]4 m6 S$ ~, F7 |# n}: f4 x6 n0 e/ c6 r& J& k& `/ A
, K- _6 g- ^) M// Make Banner objects array
* l% \6 B* I/ Y P, J- ?function CreatBanners(aBanners, aNum){7 E: A. w' _2 Z' V6 P8 ?
for( var i=0; i<aNum; i++ ){% i) G- `; D' T3 t% B# R0 \
aBanners = new ADBanner();% r z4 v- q& x& j
}
1 N, E6 O/ c2 k}
; t4 i" V% K2 |% Q
4 i; p! Q5 }; j2 t2 X4 m# t// Show banner
& P0 \* |6 v8 nfunction showbanner(aPlace, aType, aBannerID)
/ S/ |1 \' @9 A* K" m5 M2 v{
: l3 _, b" h: j+ t; J$ j- A$ l: B var amount = ADBanners.length;$ f6 {2 @+ r# d" `" @
var includeList = new Array(amount);3 e' y- V% C5 y0 n" E
t8 |6 }' L; s0 p* g5 @# j if (!document.usedBanners){) @6 `* e) d* b. f+ v9 _
document.usedBanners = new Array(amount);) d* F* ~; D3 Z- }* I- I, Z( m- w
for (var i=0; i<amount; i++)
0 A/ y$ }) x7 O, I0 ^ document.usedBanners = -1;0 e/ y: F6 \. C/ t E( ]# u; q H+ n# Q
}/ D. E- ?4 r+ e! D6 I! {) V& J6 v6 K
- a# t- m4 z$ ?4 Y
var usedList = document.usedBanners;
6 X; |+ j- Y: A4 \# e" `5 _ V7 N+ O4 K- ^
if (arguments.length == 2){; n9 u8 i, z" M" B3 _5 `
var j = 0;
5 t. K9 I* ~' r4 M8 K# _6 l% u2 R var sum = 0;% @: v( P' t( w& _
for(var i=0; i<amount; i++){
2 W* g: p. Y7 N! F5 `; |6 V5 p& \+ lif (ADBanners.place == aPlace && ADBanners.type == aType){
: W: q) o* M$ pif (usedList != i){
$ |+ ?3 J3 `5 P includeList[j] = i;
0 i( |$ ]: B# U* h& o7 @1 N7 I f j++;
- B# C5 y' A( b% a3 D X sum = sum + ADBanners.weight;
, d! E0 ?% S5 ~3 R, } }
; T0 ~7 ]8 Z) O; Z9 @0 r }
$ Q# e; I) R, f; ?& y: H [}9 @* Z) s' H7 j$ E6 e
if (sum <= 0)
) x4 c/ C% N# o3 d9 I2 I' [* @/ D/ ^ return; c4 T! e( Y4 a$ O3 p
var rndNum = Math.round(Math.random() * sum);
U& m9 S! O$ J4 ]* f1 e
( F# c! G0 v8 |& L/ H( r i = 0;( H( _7 P/ M W0 J
j = 0;
* z; d i5 x, y9 n, O# ^* b while (true) {
3 u- L# O; S; I: W1 u j = j + ADBanners[includeList].weight;) i2 A9 ~" C$ |) T# x
if (j >= rndNum)
5 d2 t. P/ }) r1 O& C' | break;
, b. i" Q/ b+ M i++;
3 S( l3 C. b, @ Z9 U4 l }
6 e" |/ r- f4 U6 S+ J A5 Y
! k( O. ]9 ]8 @. R) A' t0 \- p' v i = includeList;- D# R6 F1 [5 F8 u. j
}
1 I5 C+ q6 ]2 ~* @6 x) o else{
& I1 l3 Z( X+ lif (aBannerID >= 0 && aBannerID < amount)
4 }9 v1 n6 p6 A! o i = aBannerID;$ ^/ C6 h9 K# ?8 c
else
' w' K& Z K) I/ G2 \( S j5 a return;% o! J% }6 o8 J& E, U
}
$ [$ Y- \% t3 I5 V- H& Z$ o2 a7 i' k% ~# ?
usedList = i;
' E( j2 I, m" }2 z6 x( h7 ]9 z' G Q1 p2 h9 H
if (ADBanners.htmlcode == "")
, d) y. \2 Q( z# T: o 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>');
( e& J8 J& f4 ^1 p else4 @; D. I: Q: ^
document.write(ADBanners.htmlcode);& n& v& v# c: g2 A
}. s s1 h! L# N, c! s, V/ X0 }
& I0 W" G/ ~# J$ |( ]var ADBanners = new Array();# [) H D$ F8 a. c/ w$ X5 S m. G
7 ~3 Z. N8 w( ~) P% Z' U/ _CreatBanners(ADBanners, 1);" b& h8 u: S" |5 o- y# x. {5 y$ 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 C+ u- v7 c- V; }4 M
ADBanners[0].weight = 20;( \! p, [- }/ I
ADBanners[0].place= 6;- U$ N- j# L. y: P- \7 m/ z
ADBanners[0].type = 6;
0 S1 z% _7 N8 w. H9 ]/ E1 g$ r9 {: w& A8 m6 N# a* R
$ U# \8 J5 m& g6 |* h9 Y3 G 9 n5 y4 O0 N3 ?( i3 e
, o# T' n0 t: U. g) z+ p1 G
1 e. U4 ?. K4 W; x: W2 n4 Q
0 J4 R& c, \* D( z, y此代碼當中CreatBanners(ADBanners, 1); 這裡的數字設置廣告數量,如果只放一個GOOGLE就設置1了.,
; f9 u. _( z. {" E$ O, k
( ~2 l4 N5 m( a _ADBanners[0].htmlcode = 這裡裡面填寫GOOGLE AD的廣告代碼,請注意,必須寫成一行' R6 r/ t' y7 _- ~" U) u1 I0 v
. l% }/ N; T$ a# |, XADBanners[0].place= 6;
# u3 G4 A& \6 B+ _ADBanners[0].type = 6; 要調用的序號,具體偶不清楚,哈哈
+ P f( a% i% z* {# Z' R( r- p$ |& e, O
弄好後,在網頁HEAD中插入
, Y: r# f8 G( G% q2 n* m) P& }9 P<script language="JavaScript" src="adbanner.js"></script># c1 }1 D& e5 {
8 y. _' V2 ^0 x3 C& f
在要放廣告的地方插入% ?" ]" p5 ?/ k. e
<SCRIPT language=JavaScript>showbanner(6,6);</SCRIPT>
6 i* D6 r5 m' E9 b5 q; u- k4 P& m. A6 k4 D0 Y
這裡的數字是和 ADBANNER裡的數字對應的,
& k9 ?- g; k( \# {
- w9 {+ t" D/ Q: {0 s$ {0 x
/ h) C: k& a% l. s( \$ J0 G5 a. H3 K<img src="../images/emptylogo.gif" border="0">. Z" Y; W' m& O; G9 f8 O4 V
: B) g; E3 h1 H# k2 g1 G
……完…… |