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

|
网页之不断弹射的文字-特效
<style type="text/css">! y# g0 y' U' I# ~5 D
#supertext {
. z5 c+ j/ r$ |4 k; R1 x1 [position:absolute;
4 ?( s" @+ ^0 m. Y4 ?left:0;% h7 }/ w) _; V, S4 ]
top:0;# Y" g: _; X$ f( R
visibility:hide;
% H4 P" k* C/ |/ a7 zvisibility:hidden;
/ ]* M7 x1 Q! Q}/ b6 y2 j; X) H% |5 N3 G
</style>
5 e' Q) Z3 N* t0 l* l# O/ K' S<script language="JavaScript1.2">0 @: U# E2 k9 E) r' }
<!-- 改变下的字体的大小。颜色-->$ h- m/ H" f+ H9 f
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. g/ ^/ g) {9 f
var hidetimer='';' N" p' F/ }2 p1 r+ [, H9 U+ P
<!-- 改变下的弹跳速度-->
# s4 ^6 x" B3 E3 g7 ?$ d7 X) Gvar BallSpeed = 20;5 U2 N. S$ m/ k8 ?
var contentWidth;8 V5 P5 ^) k3 Z8 ?* O
var contentHeight;6 v6 ~8 y9 t0 m+ _* u
var maxBallSpeed = 50;
9 {1 S0 R* z0 x' l1 a8 p3 ?
$ _9 P1 ~2 Y7 s* k0 r# j' G1 C( N- e1 f- h
var xMax;
8 F" r' R, q3 O1 G6 ]+ pvar yMax;
! r0 m4 r4 o3 gvar xPos = 0; D) i: [5 \: `! m1 `
var yPos = 0;
) E1 S$ T/ V( ~+ qvar xDir = 'right';
2 {: s* o9 H. ]2 ], T& a+ ivar yDir = 'down';
: {* Q/ _% H% e3 y. Uvar superballRunning = true;
7 h; n; v/ _( Wvar tempBallSpeed;
! x* y- q2 E5 ~* e3 J/ S8 G: q5 Hvar currentBallSrc;: E- G( ~5 E! n U
var newXDir;/ J9 |2 v9 E0 h: j m Q- ^$ x6 m3 {
var newYDir;
& E; j# j6 F/ C' g
* |: B* u$ d. p* R$ f7 u! f# r8 Afunction initializeBall() {1 @4 R _- f: h3 ~& d2 z0 ~
if (document.all) {5 H8 w9 {+ E9 i- W/ d
xMax = document.body.clientWidth5 ^3 _0 O% S0 I3 K k
yMax = document.body.clientHeight7 K L! p; I4 u) w' ]4 d; \
document.all("supertext").style.visibility = "visible";7 V# _) x3 n& D5 {2 T
contentWidth=supertext.offsetWidth
) i+ j1 o$ \0 A- J9 ^0 r/ F. ?5 o contentHeight=supertext.offsetHeight
" x: k* g' G0 z& o4 V. ?) H/ N }
+ a0 V5 {9 d9 @* l2 ` else if (document.layers) {- V4 o) g* n; \; A. V& ]( \
xMax = window.innerWidth;1 b6 d8 |, v4 A: A" {! D
yMax = window.innerHeight;
F1 q: w1 e5 N* U2 Z/ b contentWidth=document.supertext.document.width
1 _7 }. @, X5 _8 ^- g- J9 {- Y5 a contentHeight=document.supertext.document.height
X% T$ X9 x- O$ w! V. F1 c$ U. a) F* W document.layers["supertext"].visibility = "show";
4 m( Y7 z& E7 r) D }/ g U" S9 |+ a, r
setTimeout('moveBall()',400);
1 C6 t) i/ \# S; H7 X if (hidetimer!='')
( d( ]" d0 K+ s2 Z4 G setTimeout("hidetext()",hidetimer)
/ C9 i2 [ _. G3 B0 r }
3 H, r' t! Y6 |2 x/ t3 V7 A: Y+ n0 E/ B
function moveBall() {
0 _8 `# w. {! `. r if (superballRunning == true) {$ L$ e7 V3 C- { W+ e/ y+ c
calculatePosition();
+ c4 \" ]4 E1 q4 H8 D; G5 X' K if (document.all) {
3 J. w0 H. z! `1 r0 S* s6 w document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 m2 l1 K' V# T% L L document.all("supertext").style.top = yPos + document.body.scrollTop;- k# ?7 y9 m4 a* Q3 O4 g% ^* x! a
}1 A2 F. h6 W4 [% ^! p
else if (document.layers) {
0 [- [6 F4 _$ O# D A document.layers["supertext"].left = xPos + pageXOffset;0 @/ M# j5 P9 r* ~! u' X
document.layers["supertext"].top = yPos + pageYOffset;7 D) ^; y; n8 q& }2 I- _5 @
}; f$ H: l' _ X2 ? \
animatetext=setTimeout('moveBall()',20);8 F" f( p: f$ L% S
}7 B1 L6 [" v! V% J' }" v
}
( ~" ^! X$ E$ ]( u7 R$ X
7 G0 \1 y& M3 ?. Pfunction calculatePosition() {
2 Z0 N) u) h! ?: M0 U if (xDir == "right") {
5 u$ Y5 |5 B* P t+ f if (xPos > (xMax - contentWidth - BallSpeed)) {
8 a( A' m l9 ^; s G6 I- c3 a xDir = "left";
* q% S+ Y& j+ M1 K! j* D6 _ _ }
8 f3 V9 M0 _8 z }5 e8 B( s- {. w
else if (xDir == "left") {
1 q3 h" y0 K. J5 ] if (xPos < (0 + BallSpeed)) {! \6 g# M; O1 l$ V$ q
xDir = "right";$ K& j3 G! y. K+ `1 T- z6 W7 F. H4 B" s3 c
}
. J% Z$ r+ k4 z+ | ], y }
L' v: |# ~" R+ M, F+ x1 h# W- O if (yDir == "down") {
/ Q' G5 c) ]% W8 v6 S/ u w if (yPos > (yMax - contentHeight - BallSpeed)) {# R" N! X3 x) g- S$ F* K. ?
yDir = "up";
% B& \: m3 I) n1 u( D7 O/ { }' e( l+ `, v. D
}
/ e! j3 D4 E) R3 ` else if (yDir == "up") {8 U4 x( c6 ?! N, p4 s% C
if (yPos < (0 + BallSpeed)) {" X+ b3 e" @5 t" _8 d9 w
yDir = "down";
4 j8 V& Z5 q; F X2 F }2 K7 m* Q2 A7 y& s% l& h+ }) N) p: j
}
6 V' `% k" I' N) p1 y# Y3 ], Z if (xDir == "right") {
) D* j% T6 ^- @4 p( C6 V( G xPos = xPos + BallSpeed;
; K! f! Z# G- d }! C, O$ f' E1 t8 d
else if (xDir == "left") {/ m W; o1 c8 b5 ]# U* A
xPos = xPos - BallSpeed;
$ M3 U# {9 s. C1 \$ B3 `8 s# h }* N+ m6 T/ Y. q; a Y# x# x9 T( Q
else {
* p! ?' z0 ?, [ xPos = xPos;6 G, K5 j- O( x+ ^
}
! t! ^+ M& p6 k, S0 P' a if (yDir == "down") {7 ?* _% U2 D. u8 e$ y& B5 |
yPos = yPos + BallSpeed;
* ?' {+ A/ I y) s }) |8 ~2 y* B" p2 J
else if (yDir == "up") {
4 A4 ~% X* r W9 t yPos = yPos - BallSpeed;% @ _0 \% ]' o0 X) n6 G7 y) q
}6 _7 y7 ?+ b" |2 o
else {
: x( i6 C- `1 M yPos = yPos;
% U6 t6 N3 e }# f; k( r6 ~7 d% r }$ _; }& Z* M8 F2 n0 ^: o
}1 }7 k- i8 O1 o+ Y: `: T
7 W' r$ D5 u; `, q! cfunction hidetext(){
8 Z; n% b; l! i& U, ?5 ?if (document.all)3 p) L! {0 Z8 C% B: |3 W) O6 H
supertext.style.visibility="hidden"7 p0 L1 l* o# f* X/ g
else if (document.layers)
5 W# l5 L3 M( l- h! }document.supertext.visibility="hide". W* U; W9 Y/ v) z- l
clearTimeout(animatetext)
3 t. P! ]1 E: Y" N( {1 g+ ?}
' G( z% j* [: y, T1 \, Z
& l, A' d ?$ N6 k7 [- Z4 Xif (document.all||document.layers){7 P2 |1 u. p9 t1 U( C$ j- B1 x R
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 Q) E/ z- ` {, R+ Jwindow.onload = initializeBall;
# F! c$ g2 o% k% ]window.onresize = new Function("window.location.reload()");9 I; N& H% O9 l! n+ e3 M/ ?
}( e D: ~1 E& h0 p$ W z* G
' W2 p3 f }+ D# u% c1 L8 d8 }
</script> |
|