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

|
网页之不断弹射的文字-特效
<style type="text/css">
7 E8 o3 z) t" M h$ S, w#supertext {. g) E& d+ m. a- x0 U
position:absolute;
6 P: j' S' [' d5 n, Y5 e$ Sleft:0;
0 m$ D% b' h# _5 h; ptop:0;( U, j& S/ d1 P) w! h P9 _
visibility:hide;
$ U* \( v+ E1 P) U: @' Tvisibility:hidden;
0 A, ?% c1 U& f% B}- W2 a1 b6 Y3 }# x, z3 A, p
</style>
: r/ \" |; V, ~% W0 U' H b6 C4 S<script language="JavaScript1.2">5 ]8 B- x9 \( s) M& ^& K8 G
<!-- 改变下的字体的大小。颜色-->( b. }* L% j0 L6 R J" ?# D- I# c
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 X7 b* G, k2 Z+ X& S* }, f: Fvar hidetimer='';. |& e# ?% z9 h$ k9 U' j% W
<!-- 改变下的弹跳速度-->2 \% w! ^; h# @( e' ]5 c/ ]
var BallSpeed = 20;
* u4 a$ ]* i _( @var contentWidth;# Y9 @% l: X/ ^* ~" U+ [% ^
var contentHeight;
+ I2 y* ^& j8 G6 h* g* gvar maxBallSpeed = 50;/ D' X5 [- h7 L2 ]! Y* N; G
. J6 t; J b3 y. L+ `* _, w
/ K) @7 D/ A: _% k/ T: c; \var xMax;3 s% ^& i8 O( I5 i
var yMax;! L/ C$ E# _3 d, L- Q
var xPos = 0;
: x: I% e8 F4 c* ~$ m' @var yPos = 0;9 T$ O% Z/ h5 b+ ^
var xDir = 'right';0 d N: s) g" V# I: F$ {
var yDir = 'down';
* n1 O4 ]2 [8 Y" j& E- c/ M" Pvar superballRunning = true;
4 a8 Q" H6 i% {4 g, q0 O2 c# [1 Z# Y. ivar tempBallSpeed;# B" x5 X6 s0 u. c* f* w
var currentBallSrc;
: Q9 S: k. `; D# i) Fvar newXDir;
$ H5 R: B8 }% R! y- q! Nvar newYDir;
% o0 @! S5 w; @. {# f. d9 e2 {1 C& C% c3 ]
function initializeBall() {
/ H, D( E3 U/ L9 S" L- N8 ^ if (document.all) {3 e5 b2 P; D! x; n9 P+ F( t! ]7 c
xMax = document.body.clientWidth8 R( U6 U' b+ [5 U5 E0 w8 d. n
yMax = document.body.clientHeight$ T/ h3 q: b5 H' I7 {
document.all("supertext").style.visibility = "visible";4 r# g. T: x! }/ G g
contentWidth=supertext.offsetWidth/ z3 Q* D4 E8 F/ x6 h
contentHeight=supertext.offsetHeight
, [* w" s0 G) X }
" N3 F, |( L% |# x5 o7 |/ B" s else if (document.layers) {3 X' w- f/ D! k
xMax = window.innerWidth;7 F: Y9 L) K% u: p( C: K1 C
yMax = window.innerHeight;( N: E9 T* f( }3 R: C( Y# W& d
contentWidth=document.supertext.document.width
5 P4 A. R8 z+ N) \ contentHeight=document.supertext.document.height
) X: @2 z* x/ i9 v document.layers["supertext"].visibility = "show";; q# L7 ]$ B1 p+ q. |
}, B% w6 R0 K9 i8 y. g6 V
setTimeout('moveBall()',400);
! f5 V4 u& ?0 f; h% s# r if (hidetimer!='')0 J# R T* a: Y9 ]" S0 }
setTimeout("hidetext()",hidetimer)3 d7 T& ` B/ c8 w; j
}
7 P# |& k6 z6 ?( j8 M |( w) Z0 X
function moveBall() {0 E+ L( H- |. F- d4 A
if (superballRunning == true) {$ h" b; c$ D0 y1 p' n) f& B
calculatePosition();
" O* g& z& E( J if (document.all) {
& t+ k. t `, F. ]* G/ q document.all("supertext").style.left = xPos + document.body.scrollLeft;
7 Z6 G2 F" v% a' y& E0 F' u document.all("supertext").style.top = yPos + document.body.scrollTop;
, M% @' n; ]- ?8 V, `; I }/ f" U1 V6 x9 x+ U2 e
else if (document.layers) {# S: P- Y9 _1 u0 f
document.layers["supertext"].left = xPos + pageXOffset;$ K" |4 ] p# x/ f2 b
document.layers["supertext"].top = yPos + pageYOffset;
7 R: i8 x) e8 }9 t0 x }
2 ], \9 S8 |$ \* J! f animatetext=setTimeout('moveBall()',20);5 U8 d3 B7 s, E% g8 R% n F
}
- B8 r' d- f6 s6 f. k& b. n. p }6 N* p4 o: d0 {7 F# i
# K; r% s( k5 \5 b
function calculatePosition() {3 |/ i* [- z! u
if (xDir == "right") {4 N0 J6 F0 _3 g( q- q
if (xPos > (xMax - contentWidth - BallSpeed)) {3 i% N- |7 B L: I, t
xDir = "left";) z( n5 J8 p' W
}
* X# e" U- P3 H* D }
# ?1 V' u* ]* `6 O. y( k- X7 Z else if (xDir == "left") {
( h6 n: x$ y9 k1 K8 C. z* s5 l if (xPos < (0 + BallSpeed)) {! [7 A" g9 a2 a
xDir = "right";
" @1 g% m2 y. h- w( T }: {# s" i% c2 S/ V' w0 h
}
1 t- Q( q! S; z k1 [5 A, P if (yDir == "down") {( x2 G3 C' ?) @1 B
if (yPos > (yMax - contentHeight - BallSpeed)) {
' W. [5 B7 Y. m" {6 X* q+ b yDir = "up";/ w2 o8 d5 u0 s6 u- j' D4 i
}9 E) r" E, Y/ d5 j% Y
}
$ R O+ T) y' i1 _4 f else if (yDir == "up") {+ w7 r K# S+ w5 M$ @; s
if (yPos < (0 + BallSpeed)) {/ V% v/ Q1 C; x& }: ^9 \
yDir = "down";% F; Z3 G0 X, ~8 q0 Q( K7 \6 U) m- q
}# E8 L$ m% q1 n3 u0 i
}& H# v8 m( }! R0 X9 m2 m
if (xDir == "right") {2 ?" ^: P4 K- k7 S
xPos = xPos + BallSpeed;/ \; f6 r* t& |
}2 I5 [/ j5 |) d* x) [# j
else if (xDir == "left") {- \0 u& H: k' F0 O' w
xPos = xPos - BallSpeed;5 q. y6 S5 q% [; C: U+ L" q
}
& O! g0 Z: B7 k1 x8 U/ [ else {
$ O3 _$ `( n: \# v0 S! Z6 } l xPos = xPos;. E( M8 f+ f1 M/ Z* B
}5 g3 E2 W) ^& N& c6 A2 ?1 h: r9 b
if (yDir == "down") {
7 X9 G5 U, T- |7 u4 A2 O7 A yPos = yPos + BallSpeed;1 \& t* L( W! m
}
7 J! n0 g w- T' J# l/ E# c1 G else if (yDir == "up") {
0 s$ a% r9 Z- L3 b% { yPos = yPos - BallSpeed;
( _" d* D5 Q1 V: @ }
# |" G* o6 h- }3 @$ a* B else {
% P: [' @9 k; `: y0 @+ z" s" u yPos = yPos;
. G# E+ o9 C% @; P8 X }
9 B1 J9 Z; S" a) T }0 c! ~6 G, E, B
W5 d- v/ d8 `# p6 f+ V0 A- D
function hidetext(){$ G+ X9 ~7 R8 D1 h
if (document.all)# w0 V+ {0 e: Q \
supertext.style.visibility="hidden"5 s( y8 Z7 C, z k2 \1 @
else if (document.layers)3 T2 ]+ S0 Y: G( Z4 [9 ~
document.supertext.visibility="hide"
$ i* M" D/ u# Y* FclearTimeout(animatetext)& d8 H: i7 }: |" b q' q7 d, N
}
4 |3 M; a& f# D& X
9 B2 B" W7 Q& f4 kif (document.all||document.layers){
7 ~: |1 g1 g) E; qdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 {; V9 h# Z" X% {6 Twindow.onload = initializeBall;
$ I# [, \" _ Q, dwindow.onresize = new Function("window.location.reload()");, L( n) n" U, m
}
^& w2 V" K5 Y
" I7 y4 E2 H. I- ?4 L</script> |
|