返回列表 发帖

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

<style type="text/css">
. S" Q. Y! C% d+ b#supertext {7 F1 v: T- a; w( J
position:absolute;
) }3 h' W0 e7 }2 b0 N/ m# \3 vleft:0;3 d, B* O1 n5 E5 S$ C
top:0;
" B5 N9 \( R/ r, }visibility:hide;
  O; h, h0 z% f5 t/ d8 |visibility:hidden;
( W1 t% M$ S' P* a! K6 }}
! J; z. Y$ A  g</style>
5 D+ b, p7 ^  C0 W+ m* A( Z! l<script language="JavaScript1.2">
7 P  M/ e+ }, [: v" d9 J<!-- 改变下的字体的大小。颜色-->
0 [9 S+ g' _+ M+ W( I+ ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', D0 J# G. ?3 J- j: y. u
var hidetimer='';* o5 k2 i. e9 _8 w5 P
<!-- 改变下的弹跳速度-->' g( I( C# M: Y: J, C
var BallSpeed = 20;
9 L6 q6 I7 ~: s( I, Y  ^; I* p7 Xvar contentWidth;
! L$ M  S# d) s6 f2 V# evar contentHeight;. I9 v" w$ {/ E* J/ X
var maxBallSpeed = 50;
! F$ ^  U4 Y, m6 H" r
! ^% Y+ n' ]" R: P* Z9 G  E
  w# ?" b" C1 g; w0 x" n- ]5 @var xMax;! k# Q) _* W" g) _9 V8 ~
var yMax;
- D3 m& S* U, G2 _2 vvar xPos = 0;# Q1 e; ^+ O. |0 F" G0 @1 N
var yPos = 0;: r" p0 a4 ~' S2 J
var xDir = 'right';
$ z! ^( X" f3 ]% @/ ?9 Vvar yDir = 'down';
/ p5 Y: l" B% ?& }var superballRunning = true;
$ L7 Q$ A$ J5 P" u- G3 j" lvar tempBallSpeed;! G, q9 \) P% V' e. l
var currentBallSrc;# ~% e3 o3 K! b$ d
var newXDir;
0 [  d( e0 f0 @var newYDir;
! j0 z' r/ v% ^1 i% K2 K* P# }* t4 ~2 r) ~3 q/ b
function initializeBall() {: O$ d% b# v/ i: W0 A* `: p
   if (document.all) {
( o- ~, z8 A- `: V. G% M      xMax = document.body.clientWidth1 O/ I* V, E  {, u8 ?
      yMax = document.body.clientHeight6 S6 n9 [; w2 V0 O" `8 s  d2 f. a( D
      document.all("supertext").style.visibility = "visible";2 z6 ~$ _0 g- \  y. O: e0 P
      contentWidth=supertext.offsetWidth2 F" }" x& I% _( s9 l$ |
      contentHeight=supertext.offsetHeight
( ?' s) |: S  n( S) z0 O  K4 `      }
0 i/ u$ W' B  E/ g$ A1 L   else if (document.layers) {) W% j; \8 u: [
      xMax = window.innerWidth;8 ]( K8 Z, t# C0 O6 C& {! E5 a
      yMax = window.innerHeight;
% e( Z3 Z% x/ S' K) l8 n  {% Q. g      contentWidth=document.supertext.document.width$ y" ~" U0 l, m! e) r2 Q
      contentHeight=document.supertext.document.height2 l. {7 m$ `3 F, I
      document.layers["supertext"].visibility = "show";+ F# i- u* i* a
      }' Q, _0 P8 y# ]4 u* X3 a
   setTimeout('moveBall()',400);# B3 _4 w, x  e  m
   if (hidetimer!='')
0 H# L% v- Y; N* c! q7 `) M   setTimeout("hidetext()",hidetimer)
1 T  k4 U+ k% F   }8 o( P2 v! O+ ?* Y8 c
) J+ e8 c- e1 z: K; W: a1 \
function moveBall() {
6 a' M5 a3 j/ E2 j. l% G   if (superballRunning == true) {# Q) @+ _$ B# |
      calculatePosition();! W# s" z( L8 A+ P
      if (document.all) {
! ?" r. G! S$ P: `         document.all("supertext").style.left = xPos + document.body.scrollLeft;8 T1 j9 Z6 ?7 w0 `% x8 O' f) S+ l
         document.all("supertext").style.top = yPos + document.body.scrollTop;1 f$ Y; F, z, ^( q- B+ t$ d
         }
/ Q  [/ W) C1 Z( {( Y4 Q      else if (document.layers) {
2 x6 L  Y; K2 m5 t+ M$ Y# g+ Y0 p         document.layers["supertext"].left = xPos + pageXOffset;
" c: i  _0 ?  Z+ J" }         document.layers["supertext"].top = yPos + pageYOffset;9 n. z, c( B1 d1 p
         }
, k3 @5 d/ W9 L      animatetext=setTimeout('moveBall()',20);  ~: C8 p3 g' c. \
      }
+ V- s& v9 C& p! O0 X5 L   }
+ `8 t/ @7 X& s! i
2 O' v+ Y3 n, xfunction calculatePosition() {( V5 Q4 K: I$ {3 F1 `" @
   if (xDir == "right") {9 N8 p) X3 H8 M" G  f, g) h
      if (xPos > (xMax - contentWidth - BallSpeed)) {: e4 C7 w2 I& @# z- p5 o: z, a
         xDir = "left";
4 \7 \; b: ~- r/ H3 F' m9 `         }, w3 }; h' s; D4 {  g! |, Y6 ]& {
      }! g3 @4 ~/ ]  r% U; G
   else if (xDir == "left") {# _: z% h( M. n& q! f
      if (xPos < (0 + BallSpeed)) {" ?: |) K" {; p$ e7 X- Q5 J( t
         xDir = "right";
7 |) H  b  \' m  X- N4 s         }
7 G4 I  V* P- W5 w) X: k  |      }
- h! x+ ]' g, {) G' H- ?   if (yDir == "down") {" ]* h- J2 ?. E- ^, v! ]7 J) _
      if (yPos > (yMax - contentHeight - BallSpeed)) {2 W: ]& K. q1 F4 z! _6 e' O# t
         yDir = "up";
, P6 V8 P6 Z! W/ v, n! J         }% n; h; K: a4 `3 x1 E
      }; X- g- Q& r+ `" Z
   else if (yDir == "up") {
0 ?% g% }8 u% @" w& ^, x      if (yPos < (0 + BallSpeed)) {
. R! r, n  ^% M0 W         yDir = "down";
3 I( }$ U( j6 L$ \: a& l         }
& K  }& I8 e5 |/ q4 K  W      }
& y9 ?0 w8 M- z6 @4 ~$ {& D   if (xDir == "right") {: x) u) }8 J0 J8 S  T# Q7 u
      xPos = xPos + BallSpeed;: [1 s* Y2 Z0 _; m! r; B$ W/ L
      }
/ z# [5 C2 k/ @0 E   else if (xDir == "left") {
$ p4 j% q1 J' W* [* Z      xPos = xPos - BallSpeed;  U2 Z9 |, v* p) t8 X3 u! T3 ]
      }; E. T- a) @* E3 @) |
   else {7 I/ s9 x3 G. t6 W7 ^
      xPos = xPos;4 }% U5 D/ E: f  I/ u3 Q1 o. p* ^
      }/ g5 O/ B' y* M. p2 F5 x0 ?
   if (yDir == "down") {9 V( [7 L) u# F1 P) `- F/ G+ r
      yPos = yPos + BallSpeed;
1 p) h' E4 R2 |' k5 ?      }
* H3 {4 p- L& C1 a% n0 s( t   else if (yDir == "up") {
/ X. j7 G; {3 O8 B: n, F; ^      yPos = yPos - BallSpeed;# {4 \) x2 ~* _: l
      }5 |8 N1 Q6 H* I% z; B: y$ b" L( g0 E
   else {" \  L( M0 Q# Y* z7 O1 ]
      yPos = yPos;
  H% b" x# D) k4 ]      }
7 a0 f; n7 e  c% t$ Q* o   }
, @+ x7 r- F( j" M: p% q( E3 J% J. u* M1 w- E6 X
function hidetext(){2 b! Y: M3 c. I* L
if (document.all)+ z" Y1 t6 H6 J' m+ ~- E0 W( w
supertext.style.visibility="hidden"% T$ \0 H  Z( Y( o' B. Y
else if (document.layers)
5 B# ~; |  Q7 t. H% Adocument.supertext.visibility="hide"
* c9 V0 f. p( a# iclearTimeout(animatetext)  T- O( O% t4 n. t( u9 A
}/ T  v8 }' d5 {  r
* c) ^4 J, `% m" i" K2 R
if (document.all||document.layers){
* S5 K' v' I, g' h6 rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')! ]8 e3 ]2 J( e5 ]
window.onload = initializeBall;1 j1 V8 B: F$ `' Z
window.onresize = new Function("window.location.reload()");6 Y: o6 O8 J* M3 \
}
/ t: @3 R+ ^. I+ l1 N' s( A& h1 i0 K
+ Z- w+ t1 u" u</script>

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