返回列表 发帖

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

<style type="text/css">4 A8 s8 c4 m# T/ K
#supertext {7 U! ?6 @8 w4 a2 J. Y7 C8 r5 O
position:absolute;8 `& M; X! x; H$ q% h
left:0;
8 }- u1 R5 C+ x1 |9 ktop:0;1 T1 a: z( ?# ?. i- ]% J: L1 T1 _
visibility:hide;4 ?1 A+ R! u1 {
visibility:hidden;
0 w1 T& Y: @7 j2 h}
* @2 X% V4 \5 \& h( _6 |& D' ]</style>
! X6 K% [2 I% `9 X: d<script language="JavaScript1.2">0 e4 o( k3 r& F. v! c
<!-- 改变下的字体的大小。颜色-->
4 U% g# _& Z8 c$ A, d+ tvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 w0 I' G2 g; L% `2 w
var hidetimer='';
4 C- C7 ^3 U/ R1 v9 s- D* e<!-- 改变下的弹跳速度-->1 p% q: A+ x2 [. j/ k, J
var BallSpeed = 20;* j( i7 l, T( ?& R5 Y3 B( ]
var contentWidth;
, T+ m: W' I2 J5 q) n* f, fvar contentHeight;8 @  |( q) Y2 q
var maxBallSpeed = 50;
; W4 M- i$ L1 Y- l
4 p  |$ O7 z8 M/ Y- I
' z. E, ]- Z3 X+ o) e/ `var xMax;  g8 z% M2 p5 ]! V8 \
var yMax;! S- K  P& t3 ~$ M# {
var xPos = 0;
! ~# D3 _7 D! a4 A# cvar yPos = 0;8 J: l% s% x( G
var xDir = 'right';
/ M0 E# Y1 J) w, p$ ?1 V7 v3 U4 Uvar yDir = 'down';
4 @4 j: C. d* w  [/ U% Kvar superballRunning = true;
3 ^( y$ |& y; ]- t0 S0 B1 _var tempBallSpeed;9 P+ d1 g! V  m. R6 c0 R
var currentBallSrc;
* Q0 a# X4 Z. s7 b3 v9 Qvar newXDir;
7 w- b, z9 t6 C6 `4 Kvar newYDir;) u- i. z  y/ j/ V; O2 E/ p

8 a) T( F+ h8 `( Mfunction initializeBall() {
8 r7 r2 z% _' w1 ^7 U/ o! M   if (document.all) {& a, p5 a) S% V. `4 }2 Z) F
      xMax = document.body.clientWidth
& R0 _; c& O; ]9 Z9 U( [3 j0 A4 P      yMax = document.body.clientHeight, Z4 b- y$ D" W" p0 X/ h+ ~
      document.all("supertext").style.visibility = "visible";7 u. {0 [- ~5 e2 w
      contentWidth=supertext.offsetWidth
/ J; C* o' I3 l" P+ l, @. D      contentHeight=supertext.offsetHeight" [0 {; n; V+ g
      }
4 u" a3 @# |8 n   else if (document.layers) {
3 S. X' i+ w% b      xMax = window.innerWidth;- V1 _5 ]# h& g5 G/ c
      yMax = window.innerHeight;
  @5 r' u# A6 q6 ^. [. s      contentWidth=document.supertext.document.width
) J7 P- w% N7 d: S0 T4 `  H      contentHeight=document.supertext.document.height
  n7 Z2 |0 R4 H3 d" y      document.layers["supertext"].visibility = "show";9 p' U( h( O* U0 o1 Y
      }# {  B* W4 q+ e2 f" y! k$ Y$ O6 A
   setTimeout('moveBall()',400);- h# A3 w! D' u! N0 H/ t( @
   if (hidetimer!='')$ A4 e4 {' c  [# f3 b# {8 `
   setTimeout("hidetext()",hidetimer); ?) [. ]4 k1 k) Y5 h- Y6 o
   }
3 ~' Z' q) I) [; g. W' D& C" ~0 C! ~+ C  h4 o, q
function moveBall() {
% c: a  V5 F. m8 W: {+ S   if (superballRunning == true) {& W9 w% ?8 b" \9 s
      calculatePosition();
& r/ d& ?) k& Q- z      if (document.all) {
0 A7 A+ N7 \+ [         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; ]2 a% v9 ~3 `4 P         document.all("supertext").style.top = yPos + document.body.scrollTop;
2 H' O" e- r& ^+ \2 a         }
2 r6 }2 G5 W+ y) A. _      else if (document.layers) {4 p9 A" Y/ p4 @
         document.layers["supertext"].left = xPos + pageXOffset;6 x& D5 ~" U% A( v  d. k# ^
         document.layers["supertext"].top = yPos + pageYOffset;
6 m6 W; e* S; ]         }
/ \+ q% t; Y! G! j      animatetext=setTimeout('moveBall()',20);+ P6 p, Z5 g, z5 K( c( m
      }$ \/ d1 B! n( f. |
   }# p+ Z% P3 A- X" Q! D) R
3 C7 g, G* L8 P, s& |
function calculatePosition() {: U& R, B5 t4 n2 S5 k. J
   if (xDir == "right") {+ T$ c7 m: X7 J0 @4 o0 R1 ]
      if (xPos > (xMax - contentWidth - BallSpeed)) {- i, P/ M: W# A7 v& h0 t
         xDir = "left";8 Y$ h' i  n; S# c; i7 j8 B4 l0 `
         }
- ]1 E- t3 @6 R. z' \9 b5 e5 `      }
0 f* X/ ?/ r3 e! ~4 S! b   else if (xDir == "left") {
2 I. P/ N' ~* ~, h* v      if (xPos < (0 + BallSpeed)) {$ m! D1 S7 y$ S! i
         xDir = "right";
5 b; X! K; K" T  ]         }
2 ?2 b& h) U* P9 u8 q- x      }
( w2 j3 ]- |% Z& W2 D   if (yDir == "down") {. c$ ], Y9 ^& m/ o% |/ f
      if (yPos > (yMax - contentHeight - BallSpeed)) {
/ u5 I0 n/ n  n2 {2 H  v         yDir = "up";2 ^1 P, t7 a8 H$ l5 L/ @: ^, v
         }# Y6 k+ D, C6 K9 @! S7 {
      }
+ n. S0 P# M/ u$ V6 x6 z5 l   else if (yDir == "up") {$ A% @: g' Z' j! L5 t
      if (yPos < (0 + BallSpeed)) {" f5 {2 @* D. `' u" j
         yDir = "down";: w/ K  H( n6 T( ^
         }3 \2 U3 B9 M5 r0 c: h) d
      }
' s6 W2 a2 ]9 }6 S* b! X% w. o   if (xDir == "right") {0 E  U6 @9 l4 R" P: d4 L1 z
      xPos = xPos + BallSpeed;& @7 Q3 ]* O( ]5 \  j% v
      }- B3 I4 _" M1 f! {5 B8 p( N" A% ~: z
   else if (xDir == "left") {1 d' [: l0 f  c; W; V7 `7 }' @
      xPos = xPos - BallSpeed;
) j' p3 V2 p5 h& l      }: f! H! H2 f7 D& k% n. x/ I
   else {1 n1 g) e2 P% Y% m. _& @
      xPos = xPos;% `# M& o/ p8 _8 K7 ?9 P, c- d
      }) w( j- P! E: t
   if (yDir == "down") {8 @, y4 w/ J3 {
      yPos = yPos + BallSpeed;( h, ^+ ?9 s# x6 X
      }/ ?9 q5 t7 |  G( m8 u1 `  c1 a
   else if (yDir == "up") {! J. ]8 @! A" h4 X- i0 L6 k$ h
      yPos = yPos - BallSpeed;5 T# s8 X& {: O: ~5 j9 c+ B! `
      }3 ]0 z8 q) w$ j
   else {6 q8 Q; q; p8 W7 N; D# Y+ Q
      yPos = yPos;
/ I* @" O) n# S      }0 ~; r8 M! [$ B3 O0 D9 i% q2 b
   }
, W5 g) R7 {/ ~# {% U1 {, o' z; [/ ]6 ^9 V6 ?1 f) n
function hidetext(){! k2 I9 l( R/ d, l& T" l& J
if (document.all)
7 j  J; Y& Q; E9 @* v* wsupertext.style.visibility="hidden"
, J4 I2 w) P$ h( S9 X6 Selse if (document.layers)# P9 m1 y3 j. y+ E
document.supertext.visibility="hide"& H1 Z9 h- E  P0 k' d1 L
clearTimeout(animatetext)
9 X3 T. `9 U0 A  u: @}4 Y( v# u2 I2 C' J4 q. H

7 T/ n/ u0 X2 _* P# b- A2 Iif (document.all||document.layers){0 |3 O  ]* J0 I6 Z7 O' g
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')# `0 ^, N: @2 J
window.onload = initializeBall;
4 a5 B% y8 T7 |window.onresize = new Function("window.location.reload()");5 R) q6 G9 j; P. p; }
}
* e4 N- Z& N7 h. @) |- n" }' K: V' @
1 r. q! b0 g; J</script>

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