发新话题
打印

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


朋友别哭,要坚定自己的信心,我们一路陪伴您!!!

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

<style type="text/css">) L" ~9 b1 M+ R( J4 u/ F) z
#supertext {# v1 `/ r# F/ A  _
position:absolute;
( R+ U+ K( T- a4 ^& p. D+ T2 aleft:0;* l4 J4 j% F) c2 F( L/ y+ q4 B! U
top:0;2 v) J0 T  |( B0 T$ D
visibility:hide;1 A: F# z8 C+ S# D
visibility:hidden;% F8 }+ N: v) K" R* t; X6 @
}
/ e( H5 l, d  p. e</style>
- |4 k5 a  D$ S. u<script language="JavaScript1.2">
1 w4 X3 i7 j5 S0 Y3 F<!-- 改变下的字体的大小。颜色-->, \3 X& }. c0 o) e: `& f$ p: ~
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ T9 \# e. C; T' [
var hidetimer='';& x1 ~! `$ X) X* p$ b8 {* d
<!-- 改变下的弹跳速度-->
. R6 s! I0 E* Ovar BallSpeed = 20;" z8 u; E0 N& o: |
var contentWidth;
/ h4 p; b( X& }var contentHeight;
6 a, [& F. d! h9 ?. G0 ~1 ivar maxBallSpeed = 50;
5 A4 m8 k: d0 M+ K' b2 q. w
& M# c, e3 |) c4 a9 n% y& R9 D
) \) |+ t# g% I; p" f* K2 T2 vvar xMax;7 |1 s1 I; n% I7 O  \0 M7 f
var yMax;
. \1 N" ]$ @7 V" d- Q! [5 b" N9 Gvar xPos = 0;* ]' {) ]/ x1 G0 r+ a& T- Y
var yPos = 0;/ V' I6 e: i4 [3 v$ R6 o
var xDir = 'right';
9 B' t- M8 I1 R! X; ?- \% t- ~var yDir = 'down';
1 Y, g8 T+ g3 l* @* E( J. o/ Mvar superballRunning = true;# o4 ?# {  J' \* h& y% n0 R
var tempBallSpeed;$ y* h0 Z4 R7 s4 F* Z
var currentBallSrc;
. S" T6 E6 g. ]5 P4 T& pvar newXDir;2 x; f# `/ m. {) M4 P
var newYDir;
* {# X! i" t+ H( e4 M! R% V4 H9 B! Q; J3 T) e1 I% }
function initializeBall() {
, g  a  o$ i" t' P- }! ?4 Q) C   if (document.all) {4 k+ E5 K$ {* \
      xMax = document.body.clientWidth; l- p5 s% i$ A
      yMax = document.body.clientHeight
8 u, k5 d# S9 E; G7 w  S      document.all("supertext").style.visibility = "visible";+ c( m" P5 q, c, i& [) Y8 _- c
      contentWidth=supertext.offsetWidth. d5 b; h8 [* U% ]. m1 H. z- h
      contentHeight=supertext.offsetHeight
/ `" C& k7 h& s' d0 L      }
& Q5 Y* N  f2 ^  ?. I9 }! A4 A' P   else if (document.layers) {
4 N( F; A8 P  Z6 ], ]! S      xMax = window.innerWidth;9 D- [+ `& C6 ^! @$ {1 d
      yMax = window.innerHeight;
5 n3 k* v( D: g" c; q+ e      contentWidth=document.supertext.document.width3 J0 \0 D# H; }9 _) z' ^
      contentHeight=document.supertext.document.height
0 Y  U. f0 b. Y5 M9 ^% `1 d4 o      document.layers["supertext"].visibility = "show";% x) J3 a( z2 P( F# g
      }
/ H, T3 B: L  u2 {9 P* |   setTimeout('moveBall()',400);
. h- m5 z% R2 Y; \+ t   if (hidetimer!='')
/ d4 d+ b7 u7 {; k0 [  Y# N   setTimeout("hidetext()",hidetimer), Q$ W5 U  L  t) v7 v
   }, H" k/ n5 ^: E4 B" }1 L- L
! {: C- W! v; R& Y# D4 r
function moveBall() {6 Y1 O! o  ~. P9 l) C+ F( w0 a! u, L
   if (superballRunning == true) {
8 V# w" m2 Z# \; ?* K. ~      calculatePosition();) P/ l; q' W, w$ b. `8 I3 a" X
      if (document.all) {
* K2 I' i, z% u: z         document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ L$ M. A8 i6 [7 g! z         document.all("supertext").style.top = yPos + document.body.scrollTop;5 M: ]' q. P+ D! `9 B8 D8 `! Y7 Y
         }% c3 \' y3 m5 A0 _* `) u& h
      else if (document.layers) {
- ~2 S  S/ m) L( C+ s- f7 [5 n         document.layers["supertext"].left = xPos + pageXOffset;- ?; F) X" b  E- @
         document.layers["supertext"].top = yPos + pageYOffset;% t$ z2 A* U2 d- D) j7 K
         }
0 V! V: Q! N+ P3 B2 e      animatetext=setTimeout('moveBall()',20);1 A1 b/ h2 W  v
      }
. A' y' i' `6 G. U' J   }
/ h: Y* M, d- {4 K2 F* G) D
4 ?/ E3 \1 J9 w9 t5 Ofunction calculatePosition() {
" f% W9 r. M1 ?2 k   if (xDir == "right") {
) |' ?/ ]% F+ M      if (xPos > (xMax - contentWidth - BallSpeed)) {5 ?$ H3 ]6 l5 h; y4 d5 L2 V# }
         xDir = "left";
$ e+ t# G, R: ~7 ~, c" r         }3 ]- @9 k& l) Q) o  \9 H& V6 q
      }
  _) w& \2 x# b- i. G   else if (xDir == "left") {, q: F, @0 i' r% N9 s, e
      if (xPos < (0 + BallSpeed)) {
7 D. s( ]" k' w         xDir = "right";
- G: E7 P4 f5 G+ A1 d, N) J! ?         }8 X  H! ]/ R' Y" x+ D/ Q
      }
% z" j; H4 o4 x6 m' j" C   if (yDir == "down") {
0 D& G- @; m& v+ Y      if (yPos > (yMax - contentHeight - BallSpeed)) {
% y: ]- ^$ W# U  c         yDir = "up";. p/ v/ [$ p. [" B2 d
         }
) K) }9 ^7 U1 R% z) q+ T% B* a      }$ x  c4 i/ ]$ a
   else if (yDir == "up") {1 d' e* X3 |9 W% u
      if (yPos < (0 + BallSpeed)) {- J1 \0 P+ i* Y, h1 u9 g7 Y! i
         yDir = "down";
2 p4 g- e" y* J         }# p- }& z8 p9 `' D; y# P
      }  k* k4 Z" F9 k
   if (xDir == "right") {
' l0 t' e8 @+ n' f      xPos = xPos + BallSpeed;
7 W; z& G4 D0 z! t      }
5 {) s/ U+ s( e3 \8 ?/ {1 v( V   else if (xDir == "left") {
) ?! h5 t  F# ~& R0 e: B      xPos = xPos - BallSpeed;0 [; W# P* p" m$ Z
      }$ f7 `3 E. {4 l5 ]' k. f6 Z8 L
   else {
  o4 N  z9 F: h3 f# f      xPos = xPos;
- l) @8 A7 e6 U; M! c* u' s/ v      }2 ?$ d- {8 _; u4 Q: n: `
   if (yDir == "down") {
4 b/ p* Z& L+ i8 J: u      yPos = yPos + BallSpeed;
8 L1 K/ c& m1 h( c6 |      }/ x. g+ Q: e7 b% e
   else if (yDir == "up") {: a: Y( t3 V1 l+ N
      yPos = yPos - BallSpeed;- c- O8 C& j% `3 L# c5 _! \6 C+ o
      }% g% J. y  r, e5 h
   else {, H3 N& G; w7 ]+ Z/ ?7 u
      yPos = yPos;
- y5 Z5 G6 ]% ^% r5 }) s      }# k) t8 L# T) ]2 R
   }, k* B9 f4 [2 y  A" a4 A
2 S+ V6 r( A1 s: ]
function hidetext(){+ z. R1 M5 X9 e; J2 y0 b* M
if (document.all)
8 X$ \# U9 W' G, Wsupertext.style.visibility="hidden"0 x( V, p, ~" y: L% Z
else if (document.layers)
" \# s& t6 v2 [* H% \document.supertext.visibility="hide"; W4 v  c8 N3 X& a7 A. x
clearTimeout(animatetext)
1 \+ \( m* o: C* v, A}- K" b, p0 i* ?$ p

/ w1 A, e. S, r6 _if (document.all||document.layers){1 L! S( @" v& M" W2 G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'). f1 c2 D" K$ A' F. @0 G! c0 y
window.onload = initializeBall;% x& [' `' L" d! Z; y6 h7 y3 _9 J
window.onresize = new Function("window.location.reload()");
% W+ e: f4 M: R$ l}# \/ q! F. j* w  u* C' Y

2 J4 s5 w2 I0 d& ]% C</script>

TOP

发新话题