返回列表 发帖

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

<style type="text/css">
- D# C/ w4 P7 C+ d" w9 O1 O#supertext {
& j# D1 a3 ~- D+ [position:absolute;0 g. G4 y  K3 e/ e, J- `: x
left:0;5 r0 X  ?6 O- F1 t7 y
top:0;
4 g, i% `, z7 [visibility:hide;
2 i3 H3 D1 ~5 avisibility:hidden;/ B% z) H; _6 F6 A7 h& _# A3 h
}3 N) G: _$ D# a# w  ]
</style>) U8 L8 c# |8 k  v, I9 E$ h0 U
<script language="JavaScript1.2">/ Q& o7 n& S; i
<!-- 改变下的字体的大小。颜色-->
1 F# u, ?2 i  E. ]var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'4 ]* J+ g% u1 U
var hidetimer='';: A' z" r, ~7 h5 v7 j. I- ]0 {
<!-- 改变下的弹跳速度-->3 S; [, o' ~  k. Y
var BallSpeed = 20;. d$ `' N  @8 e! g
var contentWidth;
2 q+ _, X2 ^* N& J. v8 U, Cvar contentHeight;) A2 J. Y: M- q
var maxBallSpeed = 50;( `# }% D- Q7 B' ]
) u* H$ O: F) S; Z

0 e9 i" ?( i6 q% Rvar xMax;
/ r& i5 c/ i' u; M- w0 R% D, Rvar yMax;
7 i8 F7 }; ^2 }. g/ Svar xPos = 0;
  ~% {- V' E* Gvar yPos = 0;6 f8 H2 K6 m% k' i( Q/ ^1 V
var xDir = 'right';
  C3 O8 ~7 R0 i/ y" [6 ^; Zvar yDir = 'down';& b' |/ t" W# }  \5 \8 }7 K
var superballRunning = true;. P7 b! a7 M: @* ]$ t7 i  {
var tempBallSpeed;
, s' W0 O- u  Z: C$ Q# ^; v/ Jvar currentBallSrc;
4 u) U/ Q4 I" O  Kvar newXDir;0 \# G/ B& D. Z  u5 }* z
var newYDir;/ i2 t+ H  W7 M" r% x

$ D. I7 e* n0 I7 Rfunction initializeBall() {
1 p* |4 l1 P9 }- r   if (document.all) {
, C& W9 b0 u' @      xMax = document.body.clientWidth
$ `% U2 R( g) N8 U: l" y      yMax = document.body.clientHeight
5 V; W+ ^" u  }7 ]      document.all("supertext").style.visibility = "visible";9 V- G0 G* m0 p: ?" J
      contentWidth=supertext.offsetWidth0 P" b) @" f# z7 z1 Z
      contentHeight=supertext.offsetHeight9 [$ f3 ~! {  m4 y2 X+ v
      }* ~( i0 n' D% F1 e; h+ d
   else if (document.layers) {* z/ r& D3 w7 m: a$ n9 f) s
      xMax = window.innerWidth;
7 B% R! S/ W& F. w# s0 Y      yMax = window.innerHeight;, _+ R- ?) ?, A
      contentWidth=document.supertext.document.width/ {- `6 h: x7 v' l% D, c
      contentHeight=document.supertext.document.height
. ^* L% c. C' X      document.layers["supertext"].visibility = "show";5 p/ o! u! [/ [4 Y$ o
      }
0 ^. x/ ]' H; r; @. X, I   setTimeout('moveBall()',400);
8 N0 ]1 B* @3 W4 T7 ]3 i/ ]   if (hidetimer!='')
6 c8 q9 \2 E% \; ^   setTimeout("hidetext()",hidetimer)' y& T4 N  T$ n$ e% \9 ], R
   }3 n, V  @3 A- x5 I$ C! Q: r
* V: I+ ?% W9 t/ Q& ^: }, `, }
function moveBall() {
7 n6 E! I" J( B* I   if (superballRunning == true) {7 `/ v( [; o, x# Y
      calculatePosition();
0 J& l* a& y  ~& ]! |% y      if (document.all) {
2 [! }% n# F/ P0 c$ `. ]         document.all("supertext").style.left = xPos + document.body.scrollLeft;4 [; A1 h- g& [" }/ L
         document.all("supertext").style.top = yPos + document.body.scrollTop;
# q1 [$ _) z$ P         }4 e; K2 L6 [& C* A' a3 ^' r
      else if (document.layers) {+ U; q, U0 V. }, C
         document.layers["supertext"].left = xPos + pageXOffset;
6 b+ N  S/ _4 Q' i         document.layers["supertext"].top = yPos + pageYOffset;. c0 L, t' |4 j7 i# \7 |
         }
& {1 x) B% k4 Y6 v: }      animatetext=setTimeout('moveBall()',20);; e1 L& a+ Q' o- u* ]* t
      }$ o9 p/ y4 ^4 Z/ K0 F" K0 k4 \
   }
5 ~3 C5 l7 L1 E: C8 }& n- m4 M: v: }" Y/ a% K1 V3 e1 P9 O2 ~
function calculatePosition() {0 `% @* `* k7 A( p# [
   if (xDir == "right") {
, T7 ]5 |  S! L  W0 Q      if (xPos > (xMax - contentWidth - BallSpeed)) {
2 \- A& @+ z- ~% f         xDir = "left";- ~' J, d2 s( V+ `. Y7 U
         }
$ u% j( B! v( g0 k2 J2 ]      }
7 O/ A- \( G, _5 L   else if (xDir == "left") {
& I* }2 X1 f5 a2 N      if (xPos < (0 + BallSpeed)) {- {, H6 x& I1 V+ a( h
         xDir = "right";% C4 ~+ E3 G: D9 f" H
         }
7 |. G: C- D" V( \$ @$ |      }
' a% N4 p7 w3 t5 V0 |) H7 p" e4 B   if (yDir == "down") {' e! n4 y% l2 T  _" E  K* J
      if (yPos > (yMax - contentHeight - BallSpeed)) {
  g4 C. p; P+ W' u         yDir = "up";% z4 |: N, T$ j% [9 j; ?( w/ \$ M( Y
         }
8 ?( E' z8 x- M- `5 K      }7 C5 }" X" \: w- v  h$ b  H
   else if (yDir == "up") {
+ o* U/ y) l. `$ e- U      if (yPos < (0 + BallSpeed)) {  S& y8 D+ z  ~+ q' c" a* p
         yDir = "down";
, P9 j( N6 e# i% @3 p         }0 z$ b. `2 L8 @7 x
      }7 E  h- \9 ^1 J- x) D  e' U
   if (xDir == "right") {
. H. g  k  T4 G6 B  |& s; r& B      xPos = xPos + BallSpeed;
2 M- ~. \" I" ?  X) D      }
- ~2 V) t: w% `# w! c, u) b   else if (xDir == "left") {
2 F- G8 N, z/ u% a      xPos = xPos - BallSpeed;  K: \5 o+ W# D9 g" n7 {. u+ Y& f( ?
      }+ P9 D/ f; H$ G* t% Y1 v& A. n
   else {1 \: U' _. V8 o6 G! f. W
      xPos = xPos;
) L9 y  [7 i! m9 [) K      }- Y1 j$ j1 G0 _- s2 x
   if (yDir == "down") {% {9 E  b. l5 |) U1 o* |
      yPos = yPos + BallSpeed;
8 A/ G9 z9 {' k! x6 c0 s      }- h: h( q* a+ |  z' G
   else if (yDir == "up") {; ~, U- ^  p& F/ k" R0 i3 K
      yPos = yPos - BallSpeed;% s3 ~+ [( a+ r  m0 S5 K/ ?
      }
/ V2 Y# m4 f; @- Z# Q   else {
- u5 z) K9 M! S  I3 x/ U      yPos = yPos;2 P: @! c; d5 U4 a
      }$ e( E/ m0 Q  u
   }( i! ^) h1 S) r4 F: S% D; m  Q

. ~5 A, I! t" G- \function hidetext(){6 v8 A' _7 C" Q4 J
if (document.all)
9 H: v5 a, m2 Csupertext.style.visibility="hidden") y) m: G3 B- h5 @3 Z" `% l
else if (document.layers)
8 F  l4 |# k; X6 W) _: Zdocument.supertext.visibility="hide"
. n" M' u5 [" w0 O3 `clearTimeout(animatetext)/ p# t/ E: D4 T* B/ u
}# Q# W$ e% V$ j- T9 {: n+ I! G

2 r8 L0 q8 N# a4 |/ Wif (document.all||document.layers){2 h, H" t: `& S" g3 Y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
' U5 g7 ~! H7 N: o( a2 O8 Wwindow.onload = initializeBall;! l) e+ }3 L: [9 A2 Z
window.onresize = new Function("window.location.reload()");- s" {) G& W5 h# L
}/ `6 {5 j8 H4 i9 L9 y& x

2 `% w) r& y' e! H</script>

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