返回列表 发帖

网页之不断弹射的文字-特效

<style type="text/css">1 h( e3 @  f0 m) s. L
#supertext {
9 m2 }: ^2 b- }7 `3 Vposition:absolute;# m  S2 k" R! l% `' F9 l9 m
left:0;2 x5 B6 g( j) y% f, G
top:0;) L( E  Y/ ?  p( C7 ~- t- y
visibility:hide;- H" B  t$ F  Y
visibility:hidden;: R2 w) g, d5 d, \" [/ m
}
2 x% C% t" d5 z</style>
4 a' j( z" s  w- R. ^+ ^<script language="JavaScript1.2">
& M" C$ X# F3 k<!-- 改变下的字体的大小。颜色-->
; f0 u1 j0 D/ s3 @/ ~var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'9 r- ], G: {( d
var hidetimer='';
: h' P; E% e" Q: e<!-- 改变下的弹跳速度-->. {" c/ e6 W! ], _! k6 _' Q
var BallSpeed = 20;
: M' f- I7 T$ _* Svar contentWidth;' K8 x' X' b0 _3 m# D3 N% J
var contentHeight;
+ S4 m6 N& C. h( R& \' o( Ivar maxBallSpeed = 50;
& w  k! s: N7 Z' K1 e4 r% c! h' u1 u9 X# N2 f9 H$ g6 j  D

6 C3 F* g% v/ ~( v! Mvar xMax;
* S' K: Y5 q% t8 b  vvar yMax;
* v* m! \) y7 k3 \' m) jvar xPos = 0;
& e3 H2 b, ]2 K8 `. T1 Q( Gvar yPos = 0;
0 v0 e6 U9 B3 {; S/ B9 Q5 svar xDir = 'right';. b+ i- H8 K# O) U, {( K. D8 n
var yDir = 'down';: N) ?' U2 ?. \' h. ^3 ~
var superballRunning = true;# }' G# @4 z; a* Z
var tempBallSpeed;
1 k/ M# f% R$ X8 u; B) K& dvar currentBallSrc;
7 X9 }% [: _4 w5 r, a" B/ avar newXDir;1 h' s) ~7 A( o# C+ O( f
var newYDir;
7 B: [  ^8 a. A2 V& s. S) X! s4 h, Z  @
function initializeBall() {$ g6 T6 y( m3 C2 l: d7 Q. o3 c. J6 V
   if (document.all) {% ^) D* |5 {; q& f. `
      xMax = document.body.clientWidth
: R) F8 }. x% M& T      yMax = document.body.clientHeight
& u1 Y, h- q" p/ u* E; K& z      document.all("supertext").style.visibility = "visible";
' F6 f$ k; L' I      contentWidth=supertext.offsetWidth/ y8 @! t! d. B! q7 r
      contentHeight=supertext.offsetHeight! l6 e) w) S: B5 R6 P( O
      }
- S2 p8 N/ V  Z6 e   else if (document.layers) {* H0 X1 z+ t1 D1 [" h9 @
      xMax = window.innerWidth;
: g) R8 R& J% J5 ^# q+ P      yMax = window.innerHeight;
) g% L2 b8 Z. x$ ]& U! U      contentWidth=document.supertext.document.width
' L% k# x# g) R+ w      contentHeight=document.supertext.document.height
2 @; d& f% h8 G9 a8 d      document.layers["supertext"].visibility = "show";
9 e. w5 K- V  M1 B1 j, O      }- O* g3 v: ?( ^3 Z: r
   setTimeout('moveBall()',400);7 u# N' d7 W3 t
   if (hidetimer!='')/ h# C% U% l+ ?  l# h
   setTimeout("hidetext()",hidetimer)  S& Z$ z, e3 V* T3 ~( |2 E
   }5 z! I8 K! K8 X

0 ~$ S8 ]1 C  M6 {# |# c7 ffunction moveBall() {- l% e7 Y6 c) L% [! {
   if (superballRunning == true) {
7 S2 _( b* |) x! b( h4 k      calculatePosition();( b& y7 b! }( O7 `: h! T/ R) D
      if (document.all) {
& P8 u2 @8 [3 W* x& J         document.all("supertext").style.left = xPos + document.body.scrollLeft;) m" \% V/ y. q' ]; p% {( O3 ?
         document.all("supertext").style.top = yPos + document.body.scrollTop;
/ x, c% f$ W; Z8 @3 x7 L         }. ]7 R/ R" m% z- L5 e
      else if (document.layers) {
6 Y- i" |) K6 N* ~. |* @5 O         document.layers["supertext"].left = xPos + pageXOffset;
: }9 F7 D* ^3 M( f0 ]6 F         document.layers["supertext"].top = yPos + pageYOffset;
0 Q. j7 r' ^. f4 I         }& C1 |7 W! G5 D1 T! X
      animatetext=setTimeout('moveBall()',20);
7 ^, y) D! K( V" u2 ^& l; F      }  r% u) Y7 m7 z3 r" m
   }
- H6 D" F8 i' @* J. V; Y; f: j+ n$ T+ A# B2 P/ m0 E' p7 V
function calculatePosition() {& J' k$ u  n  ?/ u& u
   if (xDir == "right") {: V$ V/ E1 z; o1 Q9 m: x
      if (xPos > (xMax - contentWidth - BallSpeed)) {9 p7 N9 [9 ^2 P% ?5 [
         xDir = "left";3 s- j( E) b: o' i! h
         }
9 s6 ^5 ^2 E# U) u# z: P9 b$ z, G      }* `3 w/ H$ ]' \/ h$ Y8 \
   else if (xDir == "left") {
4 u  F  o$ Z% c: t6 F      if (xPos < (0 + BallSpeed)) {
9 @1 g2 h4 a) _* D! \0 k4 j         xDir = "right";' Y* A) T: f1 Y
         }
$ b* R; |4 a# ]- |      }/ K, R! i  A1 q6 |' x3 s3 r2 ^
   if (yDir == "down") {3 d  ?' w& _# _7 F, m# z* W
      if (yPos > (yMax - contentHeight - BallSpeed)) {
$ b, u) J8 T' H( B- W         yDir = "up";& y6 `! X# \/ d" q7 R6 {
         }3 f% {# g6 V; q+ E6 P5 w
      }% m' i: w- h5 w
   else if (yDir == "up") {
1 ~& Z) X+ N2 T- v/ n0 B8 t      if (yPos < (0 + BallSpeed)) {
, J- s( t- s. D7 c$ Q. @) f         yDir = "down";
! N% y- b- C4 ^2 P         }
1 h0 `6 I0 G% H6 k* J% G6 {      }
! f+ n/ \/ ?' G5 [6 R   if (xDir == "right") {
: W( z: n* H2 M: M# y- q6 H! Y1 `      xPos = xPos + BallSpeed;3 ]9 P6 W/ \5 Q' }
      }
9 x+ Q) O" G  U5 F& P   else if (xDir == "left") {
1 S! i6 n/ q- R. [$ v$ p      xPos = xPos - BallSpeed;
+ F6 j6 u' B& {* f& T1 f/ Z      }
& O" ~( j7 D5 d8 k9 ]3 w   else {' d3 y) Y" B8 S( [; f$ b* ?
      xPos = xPos;8 Z- D- G  t9 T4 m8 W# ^8 T1 o% z
      }
" j1 f" {' t) `9 h: r   if (yDir == "down") {. \! f" {9 I$ V) o% @$ ^/ q
      yPos = yPos + BallSpeed;
! y. F/ D& y  c. n6 `      }
" S, b& d$ I% I4 H& `  T   else if (yDir == "up") {
+ |* e6 a& Z+ a5 W5 P2 S      yPos = yPos - BallSpeed;6 l9 t: |6 A( T" r2 m) Q) C
      }
2 J$ ^8 ?6 z1 P4 v( \% O   else {# C7 Q7 `3 H2 N0 C9 H( M
      yPos = yPos;! D( a+ l' n- f, @5 P1 u9 S/ n2 a1 K
      }; \9 ~* I" i+ l* @* ?" G* f( j
   }* s' P$ }8 P# G! x3 h0 x

: P& |7 u3 n" `( P8 Q) hfunction hidetext(){
2 w8 H- ?8 \3 Mif (document.all)
( U4 n) Q$ b" M2 P8 ^6 w4 bsupertext.style.visibility="hidden"% O) S$ Z! ]3 k8 F- h" |3 b
else if (document.layers)/ w1 z/ s1 y5 v' l; I0 d; w# E
document.supertext.visibility="hide"
. Q# Q! e; F: n3 C2 j/ G0 {; Y! jclearTimeout(animatetext)
: l8 V+ C1 I* s0 H/ `7 O! M}
2 ^" G) A' o  Q% Y8 t7 S+ @1 e9 [6 M. Z
if (document.all||document.layers){
" f" U8 X8 x( q/ {document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'): D6 I6 q. g- ]+ v9 b1 [
window.onload = initializeBall;$ F9 D  u$ g- T: N  D! {
window.onresize = new Function("window.location.reload()");" t' {9 F" x# |! s! m* U8 o
}
9 ^, k" \; A2 u( o" k, n: ^1 M. P2 Q; h9 w) A
</script>

返回列表
【捌玖网络】已经运行: