返回列表 发帖

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

<style type="text/css">4 H) A: }- b# J& ?9 Y; |
#supertext {
; K8 S, B% j9 r7 x* v- lposition:absolute;6 w4 n# {! \5 G; E+ |9 U1 @" e$ U5 q
left:0;% T/ ]% B$ \) g5 Z5 _8 H1 t
top:0;& R& \1 C- z1 x! P. Z9 r9 h8 K5 |, H
visibility:hide;, [9 m" ~1 x* W. z3 D& x1 O% _
visibility:hidden;/ l& i& D( P1 q  B4 T
}% q1 O; q/ u1 C; Z
</style>
- o! N; `5 W/ x, X<script language="JavaScript1.2">
4 A  P  K3 f; ]. \! I- r3 Y<!-- 改变下的字体的大小。颜色-->" d- {. C" @8 U  [2 \
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'- @4 g2 L, g5 J2 Q( f; q6 X
var hidetimer='';6 z: ]$ r  }5 Q* }7 Q2 s
<!-- 改变下的弹跳速度-->. ?  T9 m6 N: y: U! V5 Z" v: d
var BallSpeed = 20;
; N; N. w2 H; h7 fvar contentWidth;/ J4 A  \' N$ ]) J
var contentHeight;% U" n! t, X! q8 Z( m
var maxBallSpeed = 50;1 Z/ Z7 |* B  ^( e5 O4 i1 D0 L4 V) [

0 ]+ m. `9 o2 J
1 _, O( \* E) u. F* |var xMax;
, a8 H  {5 p: e3 a9 [) A. lvar yMax;( D0 p0 E  ?- C2 A
var xPos = 0;
7 D  z( {' a0 v6 a; ~var yPos = 0;) E8 l$ f5 o6 f) e+ p" ]
var xDir = 'right';
( l$ v! r# j- r3 k: Lvar yDir = 'down';
1 p- m: F+ _! ?( L# Fvar superballRunning = true;0 u8 R2 ^* O5 C7 `
var tempBallSpeed;
+ c2 {, h1 C6 ?- Q9 I+ hvar currentBallSrc;( r" g% x4 X) Z9 J8 T2 h
var newXDir;
0 m$ A% }8 v' w; ]; }; r- Rvar newYDir;
# K8 J3 }  F0 k" x9 G. e, T' g& B
, r; N# A$ l( V* m9 kfunction initializeBall() {- x" R: }* z7 i7 ]
   if (document.all) {* ^. Z/ M, _3 c' T; u6 _
      xMax = document.body.clientWidth9 r% y0 H. W5 k, O; i& ]+ n
      yMax = document.body.clientHeight
$ w( z: f. L" [) `      document.all("supertext").style.visibility = "visible";- S" t. I: F; S- f: m0 |. c
      contentWidth=supertext.offsetWidth
$ l5 U. Q" n. C# Q- f      contentHeight=supertext.offsetHeight
$ m6 w  p$ J1 z, H% S* c7 ^2 w- j+ y      }, z5 y6 r2 A2 b; s9 y9 ]
   else if (document.layers) {# Q& P; X; L" |5 b  J
      xMax = window.innerWidth;8 L# ^% \6 {0 T2 W
      yMax = window.innerHeight;
# D- p3 B' J) {9 J4 `      contentWidth=document.supertext.document.width
6 t9 o3 w9 d3 N0 [! |      contentHeight=document.supertext.document.height3 B  n) k; P: M  o
      document.layers["supertext"].visibility = "show";2 U2 ?$ Z# o0 F, J/ y9 S" Y
      }
4 w; [7 m' _, K' [0 n* ], r) V   setTimeout('moveBall()',400);# `# {6 ~6 n0 ^% G
   if (hidetimer!='')4 ?, ^* ?3 e  s& _/ ?0 @
   setTimeout("hidetext()",hidetimer). z9 Z$ ^, N6 S) c4 N
   }
( E3 Z2 K  K8 d: j! o- M
0 y  f- |; }$ Hfunction moveBall() {& r1 Y, W0 Y$ {, }
   if (superballRunning == true) {
+ @# C( ~9 Z! b: _! ^; n' _      calculatePosition();2 b3 h9 a0 ^7 \' g6 [
      if (document.all) {
0 w& X$ t' I# z0 K         document.all("supertext").style.left = xPos + document.body.scrollLeft;
) |) t5 Z' U: u# a         document.all("supertext").style.top = yPos + document.body.scrollTop;2 H( E6 ]# @# `3 C# z3 i
         }
6 Z% v" T& j# g      else if (document.layers) {
: T3 u- f7 @- i: a) A# K+ ^+ d         document.layers["supertext"].left = xPos + pageXOffset;
3 z' y5 P4 @! a. i         document.layers["supertext"].top = yPos + pageYOffset;: b0 M) T* H8 O. P) ]
         }
, C" F. v  R  }, X9 ?' ?6 Z9 ?      animatetext=setTimeout('moveBall()',20);
! m+ }! V& s9 w; j( c0 A% ]      }' e9 x) J2 w: a0 D3 g# n9 @
   }; v' f- b& N! R' C6 F/ y

! q2 u- _1 s2 ~/ Yfunction calculatePosition() {
  R; L: Z! ^7 G9 c   if (xDir == "right") {( ~3 U/ b; g/ g  e. J/ X# B9 Z
      if (xPos > (xMax - contentWidth - BallSpeed)) {
- w' D1 Z0 V2 H* a! a         xDir = "left";
8 e. D4 _; o: M, m7 Q6 D- ]; A/ @         }+ _! ~& \; i- r7 s6 W: V4 {9 d- ]; r) Y
      }* [" G/ ?9 r, I* n
   else if (xDir == "left") {$ ]$ N  x1 ~9 }6 K8 y
      if (xPos < (0 + BallSpeed)) {! C2 E+ K, P. s3 u0 _
         xDir = "right";
" g# h. I3 `; p  }7 e( ]         }
/ x5 V1 {/ P5 j3 j5 I$ h, e      }
! V& r% B9 W( g( c   if (yDir == "down") {( W9 N+ b# k4 D( c/ q8 q1 P- w
      if (yPos > (yMax - contentHeight - BallSpeed)) {
/ p( c9 J3 }& E9 ?& l, w/ ~         yDir = "up";) `8 w! J3 r! ?
         }
. W) {# L2 t( l& I9 J1 G/ S# w      }! o$ G1 E& D4 F8 I) Z: Y; z2 b9 a% F
   else if (yDir == "up") {- Z0 T( g9 q$ K& Y2 Q1 N/ f
      if (yPos < (0 + BallSpeed)) {1 y  X( |; G1 o
         yDir = "down";9 V( J9 ]0 r: D( u7 ~: w3 h
         }
4 V- C' R" r, U0 W( e      }( n" `" b6 A5 F9 W
   if (xDir == "right") {' v4 q8 z" `( m. L) Q2 K1 ?( t7 ~3 y
      xPos = xPos + BallSpeed;% B" h1 V1 t) C5 K+ ~' A; F: P
      }7 A- ~9 u1 k1 W% c  w" z! j
   else if (xDir == "left") {
7 \, v& U8 B1 M3 F. U  z0 t      xPos = xPos - BallSpeed;
' f6 r  \/ |* \% S      }
! ^. Y" L8 [) _$ ?4 Q# J& d   else {- h, `; m+ F% e2 O0 [; U
      xPos = xPos;
; a1 z8 Y9 g- T, q! a/ R      }5 |$ W1 o9 O; w, N
   if (yDir == "down") {
( {( u6 a1 h  [      yPos = yPos + BallSpeed;6 Y4 Y/ y/ N. p$ `6 }1 y
      }
7 D* `2 v- f+ J) O, x. b8 g& S2 }   else if (yDir == "up") {4 o- m$ i, C. u# ^1 M3 w
      yPos = yPos - BallSpeed;) V8 ?; [0 ]: x( ^( W% _# d! x9 I+ d
      }5 @1 `4 n+ D" B8 K1 W) F* x
   else {( Y. W( p( G  n/ |; X
      yPos = yPos;
# Y3 g  |" \1 T, q      }
" V* V/ ^3 q" }" X! @   }' M, q" W/ q! U) m
' I8 B3 ^" V. I7 L6 y4 S) i
function hidetext(){
) s/ Z, q# ?6 F* H- l9 Qif (document.all)+ Z$ Y* ~( Y. F2 H' ?, d
supertext.style.visibility="hidden"
. z4 w) z5 d2 nelse if (document.layers)
4 ~" h' U! g' S8 n0 Odocument.supertext.visibility="hide"; O) h7 b& D/ f
clearTimeout(animatetext)  W! `3 S9 `" M# m
}1 @$ h9 J9 J' L# |  M/ Y
2 |& W; H8 V3 V
if (document.all||document.layers){! D' |& l' Q+ d$ g8 l0 T. m
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')( {8 H# Z4 }* a& m
window.onload = initializeBall;
1 N! P  a9 O2 u, [window.onresize = new Function("window.location.reload()");
9 E8 P5 ]" I& o8 H, g  Y}* L- f4 L. R# e# c& z: ], r

- ~1 @) ~* v: Y# \* W</script>

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