|
  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之不断弹射的文字-特效
<style type="text/css">
! \1 D! ?( E' P#supertext {
, L: h9 Y* c G& U+ X5 rposition:absolute;
6 E! Q$ J4 [1 Fleft:0;
: f2 I+ v) b5 _8 Q2 C5 G& Ktop:0;. @2 F8 Z j3 d" K; G: r+ e
visibility:hide;
6 N% e2 D2 l: W1 K' Q) evisibility:hidden;! P7 u; p, g' q( V
}8 r0 w2 B9 q* N! y P- H$ Z
</style>, v& v/ _2 q- |( w
<script language="JavaScript1.2">; y- u, i( ^) X( l1 y6 _% _
<!-- 改变下的字体的大小。颜色-->* b0 Q; v- b. {8 I& k
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
$ q! H% l" ^ N) qvar hidetimer='';
: I+ J' f: @0 U6 D<!-- 改变下的弹跳速度-->
. g2 D/ L$ t; X/ b+ U/ _var BallSpeed = 20;
# X- S5 z: I$ x8 wvar contentWidth;
1 T0 U: w7 m, i3 }var contentHeight;; G5 G: T% q4 x+ m. \
var maxBallSpeed = 50;
) a$ W8 H [2 m/ F8 }! W* Y
, \9 I$ }) b8 p& s' n- k7 S$ a0 { M& M
var xMax;4 s( q5 S; {" q' {9 [
var yMax;
3 Q% i8 N' x" {& F% ? ?var xPos = 0;
! B) S: G o9 @) ]3 ivar yPos = 0;
, w# n& }; w1 U0 |5 q& Svar xDir = 'right';
& [ ?) N/ e9 c1 C5 j" E; U, d; B3 f6 Lvar yDir = 'down';
' K- z( X7 f1 O0 H* uvar superballRunning = true;
) e$ v4 h7 s0 A* \/ U0 evar tempBallSpeed;
6 m6 ~1 T" j* Ivar currentBallSrc;
! M$ n6 @5 z9 }4 n3 B: m8 i2 Fvar newXDir;6 a2 G/ b- ^/ K2 Y! Z
var newYDir;
7 }9 ?8 o i8 J7 B8 Y/ s
2 D6 O; x4 m- R4 B I9 ?function initializeBall() {
& }" c4 E6 L6 V R' i. h6 P if (document.all) {, J, K) X$ A. m. I6 p4 L8 h4 ?0 K
xMax = document.body.clientWidth0 _6 G8 h" |5 w. o
yMax = document.body.clientHeight2 _8 ?6 g6 ~4 p2 t H1 M( a
document.all("supertext").style.visibility = "visible";
) a) L/ e: }/ q contentWidth=supertext.offsetWidth1 z$ q5 e% ]) r7 r4 S- ]
contentHeight=supertext.offsetHeight W$ v, H* [/ I# Y* R# C
}% P8 N U" d( D
else if (document.layers) {0 V4 m; V% c1 S y% F
xMax = window.innerWidth;
# t1 O5 ?( _2 E, R9 B yMax = window.innerHeight;. k5 j- P; g# ^2 d2 k/ \
contentWidth=document.supertext.document.width
: K% _5 n w8 m- m2 c contentHeight=document.supertext.document.height+ s8 e, ]$ m4 i6 G! K. P/ C5 N/ J% n
document.layers["supertext"].visibility = "show";
# Y9 K6 v- q; f! U }
5 q- G/ |- I8 h! F setTimeout('moveBall()',400);6 m1 Q4 }! _: v# R% d+ Q& J" m
if (hidetimer!='')
* }7 o5 H& ~6 r) K& }) b( [ setTimeout("hidetext()",hidetimer)# ^$ ]& e9 U% f6 A
}( B0 z: @5 g7 p$ p$ e
9 a+ ~* L- E# o4 r; X1 x+ G" k7 dfunction moveBall() {- ^$ e8 l7 f u. n" g/ ?
if (superballRunning == true) {" O$ c/ X7 J" b% c
calculatePosition();8 @6 C- W, }. z
if (document.all) {
$ A1 f" t0 t5 v9 Q1 y document.all("supertext").style.left = xPos + document.body.scrollLeft;; o& `' M$ [1 F1 u o
document.all("supertext").style.top = yPos + document.body.scrollTop;
! I9 S9 d% a% [1 f. X }, C* s Z& B c! q6 |" D
else if (document.layers) {
- @! n1 h3 b) p, ^) L3 M) _$ b$ n, n* v document.layers["supertext"].left = xPos + pageXOffset;' d6 O* Z$ O6 @1 N2 o
document.layers["supertext"].top = yPos + pageYOffset;' ]% L" d9 D! A
}
: C, Y: ]* V: I! a) k7 r animatetext=setTimeout('moveBall()',20);1 _4 o0 b- x( I( l/ W6 i* b& |8 I" E
}# e: q; f" I' b9 i& k
}
) ?( M! M0 A+ T
5 Q! G* V" n R& j" r% }function calculatePosition() {* O; l: q, p- l% X
if (xDir == "right") {$ }+ a6 @, Z: I$ Q6 s0 C
if (xPos > (xMax - contentWidth - BallSpeed)) {! S0 B; Z7 G0 y9 P( b' ?" O
xDir = "left";
d0 H) p' @0 V& i }* ?& e7 |0 [/ K1 p! n. L( I
}
6 y5 g! _' A) v' T+ i! W ^9 a else if (xDir == "left") {# n5 v0 l: i' t2 W, Z2 s- y
if (xPos < (0 + BallSpeed)) {+ ?% v4 G% Y ^ L4 L/ t$ B- Q. L
xDir = "right";; E; ]( Q' y; x7 ]6 y7 ]2 N9 B
}
! L; N# P9 k; l# l }
8 y F4 C0 K: o7 p7 k6 D- A" a if (yDir == "down") {
$ @% z; D0 l# {' M& t3 k if (yPos > (yMax - contentHeight - BallSpeed)) {
% ?; R& q L: C @& M" K yDir = "up";
4 }* s/ }* m! \: L: F$ n# S: I5 X }
; m! O3 X2 P$ D0 o' E }
: q$ X6 C- a& q6 x, m" T else if (yDir == "up") {- N- H W/ s! M4 ~0 C! c9 B& l/ `) ^
if (yPos < (0 + BallSpeed)) {
7 F& w* f' a5 @. z yDir = "down";
- `! F/ V9 u! ]/ D, E4 ? }' s5 ^- n6 h/ D( w1 |5 @
}
+ Z$ |6 S+ p; g8 z if (xDir == "right") {7 p V* ^3 E; s
xPos = xPos + BallSpeed;
7 v# T% M1 c# W; Q, e }% z1 s* O9 F/ ?: k& q! A& o1 s7 G
else if (xDir == "left") {
0 w) l. t2 F, j8 } xPos = xPos - BallSpeed;8 o- W* e/ |+ r2 V6 w, t$ x: z P
}
, O; J, a" ?& j( L' ^' W else {/ O5 U; m% a3 Q
xPos = xPos;, h7 v, x% X# U4 @9 a% }
}
, s$ O1 Y& y0 j if (yDir == "down") {9 B% w1 @, d1 t- x
yPos = yPos + BallSpeed;
/ z( ?* ?7 B3 ?# r1 p: B2 c }
% U! ^" x, g- _8 D' |4 x else if (yDir == "up") {4 @4 m) P# j/ T8 u
yPos = yPos - BallSpeed;+ j, y5 J8 s6 n$ `) F4 {# j
}
/ y" a4 [4 ]* |# i3 c else {
+ B1 \# @* w; y( _7 v9 F0 k yPos = yPos;
5 o S! p. ^( x! ]8 m }7 R2 ? D8 I8 o; p5 p
}
$ g, a% P, i) J3 k) X: N# c$ {9 D# @3 U8 s
function hidetext(){
% C, H2 F" R3 h0 |3 u8 Fif (document.all)3 ]! i4 l1 D- F" I8 Y
supertext.style.visibility="hidden"
3 h) g/ b' W$ a! O2 Belse if (document.layers)- @9 a) V3 t- f8 u! V
document.supertext.visibility="hide"
- T6 d0 L2 S$ sclearTimeout(animatetext)
# T W6 F, i7 _# G# N% l/ |8 C}
" N7 D; e% D5 [; u$ w9 K1 N/ X
$ L2 p; e, }0 ]$ \if (document.all||document.layers){6 g" p- @; F# e& I( ]" Y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" D% U/ l1 O. \4 i4 v1 ?: I' ?/ ?window.onload = initializeBall;
5 T+ M+ `$ t8 J! U& pwindow.onresize = new Function("window.location.reload()");! b, P- w" n& K$ U8 b0 a5 S
}
: ]5 F: k. o) n- n& t
6 y+ y3 r N( V% m8 b" w</script> |
|