返回列表 发帖

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

<style type="text/css">. m8 ^( E; L2 M( w' m8 J9 A3 o
#supertext {
: n( b2 G, {6 u# S* a! zposition:absolute;
9 O1 g/ C3 w8 w' Tleft:0;
# V2 v2 k; c0 t; rtop:0;$ t) k$ c# f! P! S
visibility:hide;/ [8 H' u: ~' W
visibility:hidden;
4 [) y# c9 k) J/ `) i- W% K}
1 V9 c+ e7 i2 s+ _6 n</style>
$ b2 c& F+ j$ Z7 u$ _7 {/ G<script language="JavaScript1.2">4 x) q5 v6 I+ r! s/ n! k* Z) t( z: C
<!-- 改变下的字体的大小。颜色-->
7 w' ~4 Y2 ^# s9 Mvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 \7 r- x6 Z& Z; _var hidetimer='';# ^9 e9 B# h# M/ i( H* w! m
<!-- 改变下的弹跳速度-->' y$ ^; V( t! L0 h! u; p# f) }% v  j
var BallSpeed = 20;
- _! H: ^- x! Svar contentWidth;
0 x# R* ?& T, t$ ?* G" e" `# p+ \var contentHeight;
  v, V" d9 [8 O8 k/ Ovar maxBallSpeed = 50;7 b/ Z6 |1 H  m! _

$ s0 u& s0 t1 H, D8 n
  Q4 z5 W% {( Jvar xMax;+ O7 h% l5 i* i3 }
var yMax;
: z, Z; Y1 s: h; Xvar xPos = 0;2 k& Z2 T9 I; l9 ]
var yPos = 0;
9 d0 ?, S  h" [. U1 ?var xDir = 'right';" T: }) V: }6 r' d
var yDir = 'down';7 P6 ?. p1 Y" L, C1 X/ a0 d8 o% o2 X. P
var superballRunning = true;: L7 R0 W1 a' u2 \
var tempBallSpeed;% D$ ^2 R8 l+ u- f
var currentBallSrc;
! I6 _" `. }0 Ivar newXDir;& z. ~  A8 ?/ W/ O( V' G: H& h' H
var newYDir;2 M4 @6 e' f7 ]6 e8 h. R' k

7 Y6 o% Q+ Q: J& Jfunction initializeBall() {* j" z% P& v+ u: t) X$ X
   if (document.all) {
- S9 W. n% k1 n6 p. D- w1 A5 T      xMax = document.body.clientWidth
! L9 A+ o) ~3 L% |      yMax = document.body.clientHeight+ f1 u7 c, ]+ o2 z+ t8 ?
      document.all("supertext").style.visibility = "visible";
8 V2 `1 h. S3 K8 _3 p      contentWidth=supertext.offsetWidth% p  D9 k# U0 K+ [8 Z
      contentHeight=supertext.offsetHeight" k* W1 T9 d! |& `
      }
" V- r8 C* g5 [   else if (document.layers) {& |7 Q) f- M. Y6 r
      xMax = window.innerWidth;
$ c. q9 u. a0 `$ m; i      yMax = window.innerHeight;, {$ W0 b: G2 I6 y6 ?+ s3 R6 L
      contentWidth=document.supertext.document.width5 w7 I6 o4 t5 Q. ^2 R: V2 U
      contentHeight=document.supertext.document.height# U2 ~( c! C0 R1 Y
      document.layers["supertext"].visibility = "show";: [9 D  _7 S; t) {8 [7 y  h
      }
  e& y9 ~" D6 v   setTimeout('moveBall()',400);$ T/ [' r1 _( G6 e+ Z3 `* j. U1 v9 e
   if (hidetimer!='')3 l: i* |" F  D6 z' F5 F( H
   setTimeout("hidetext()",hidetimer)% ]7 a( ?5 ?8 _  Y0 ^. s
   }' {6 x, h) j4 c' w

: S+ N2 S8 c  W3 l& h# _7 h1 ]! sfunction moveBall() {8 {4 u/ p6 p% A6 W! h% `) V
   if (superballRunning == true) {
, e2 _" [: R3 ~' p2 B2 o; z% k      calculatePosition();1 r6 _0 O8 |# L
      if (document.all) {7 N. _: [: y% T% o( e3 }
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; D- G, M* Q6 X$ E# f' a         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 u! K6 ]& ?( b; h- ]         }
8 I- p3 p* C# u" k# c! {      else if (document.layers) {
; m# z. n9 x) M& D. z5 O/ O: [         document.layers["supertext"].left = xPos + pageXOffset;/ g5 u  \, b4 [1 G, O9 f$ u/ d' ^
         document.layers["supertext"].top = yPos + pageYOffset;- g* U: d$ A% X' M) A2 Q( ~. A
         }
) R- L; o" P9 i8 @      animatetext=setTimeout('moveBall()',20);
" U4 s7 T4 d' S# E5 p" ^& z& p      }3 n+ \& W* [0 \% x3 A
   }
$ v/ o, D' S3 n# J
# {5 s0 _% r  J' qfunction calculatePosition() {
9 O9 U/ f# x- k  P& q5 w2 v   if (xDir == "right") {" l6 R9 s  `; Z; e  Q% G
      if (xPos > (xMax - contentWidth - BallSpeed)) {1 ^2 F* d7 X8 u# {8 C) D$ y
         xDir = "left";$ J) q; w0 K9 a: E% r5 U5 ^2 t3 W
         }
& k& g9 S/ G/ c; u& p      }
9 e: Q- H% c; {* E% p   else if (xDir == "left") {) h* f2 T( B2 b6 ^( u
      if (xPos < (0 + BallSpeed)) {
" \# F$ u" Q9 @, P" l/ @8 D         xDir = "right";
( _& C9 u1 w# m  f* x) u         }
3 o+ n! b! V) `0 ~: Y      }
  ?/ |8 ^' h2 H& r% O" R3 G8 F   if (yDir == "down") {0 q" c* t6 b" y7 B  L
      if (yPos > (yMax - contentHeight - BallSpeed)) {2 j! Z4 M0 n6 m7 h5 b. d9 o
         yDir = "up";1 l4 E1 u) N; f. X1 p. y
         }
/ n% `8 x5 e1 X/ x      }
9 B# S: V4 t; S$ ]6 n   else if (yDir == "up") {
+ e' J1 d+ v( b( S, h+ T/ n      if (yPos < (0 + BallSpeed)) {4 u6 |! ~: O! }
         yDir = "down";
% o7 _; I$ C) l" V         }
+ d* X& t* J& q; `% S      }
: ?0 V) [' o$ w! V4 C$ ~   if (xDir == "right") {% M( T: U* S  ]* t. T
      xPos = xPos + BallSpeed;
: ?* K1 i1 A6 B      }$ b2 J! N& b  R
   else if (xDir == "left") {+ y! E# L. `3 Y2 d8 D
      xPos = xPos - BallSpeed;0 f0 K9 @) A9 ]
      }) @9 a/ R5 z8 T$ {, I) ]; \; J  ~
   else {( u8 ?$ m) ^- ^, k, V( j* ]; V
      xPos = xPos;& Y7 W9 v; p3 w$ c
      }( Y9 i5 r8 C1 n, N
   if (yDir == "down") {
0 o3 `+ y7 h( q) m/ [% E      yPos = yPos + BallSpeed;
2 e' E: J! T. P6 X6 w% {' n+ B) Q0 Q      }
- J, `8 f+ w2 j/ m( x! D' R   else if (yDir == "up") {
* A) ?' z  U& ~+ b+ \1 d7 O      yPos = yPos - BallSpeed;
4 S7 s6 |1 P! v5 Q/ t      }
5 }) ]1 X5 S+ _, ]) t" r+ a- r   else {
  o& R* f3 w7 \3 j# U& q      yPos = yPos;3 g2 Y7 p, D9 Y% {5 n' v* ^
      }
/ n* h8 Q- |! ^5 h  p  o/ l. r   }
, v9 D0 Y9 e1 I7 G7 k0 V
0 m: ]7 f: r: t: b% z1 Ifunction hidetext(){+ g% K0 v  Z( ]- V
if (document.all)# @, z  U) O6 Q& z
supertext.style.visibility="hidden"
- f6 ^) g/ S7 j1 Aelse if (document.layers)
! p  s! n3 T- _0 }7 j; M9 v1 Bdocument.supertext.visibility="hide"$ s" \" _+ H+ f% V' i
clearTimeout(animatetext)
, [$ k4 a  I2 m# h3 }. m}
7 O  \8 {0 \; k9 O9 b: h$ ~' f% A8 w9 t! ~( s
if (document.all||document.layers){8 Z: \4 v5 K- o! n/ ?
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 v8 p4 b- f0 r8 D# D# d% J& \- F
window.onload = initializeBall;
4 x+ I1 u- @9 H& t# N- jwindow.onresize = new Function("window.location.reload()");/ ^# m6 }! a$ R
}
' D* i' G1 n. v" q7 d7 s: g  D: f; s& f0 F* Q$ [# g
</script>

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