返回列表 发帖

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

<style type="text/css">2 P6 B% a2 _8 M  C. \: Y! J
#supertext {" j* V, o; l! u" ]
position:absolute;
" s; ^0 s% X. ]! nleft:0;
" j3 n% N- ^  W- }, U0 L- J1 \3 h! xtop:0;2 J2 ~1 L2 C: J* u; `. H) k9 H( z
visibility:hide;8 P; N1 Y: ^8 n( Z
visibility:hidden;
: }2 V! S0 ?; Z* U( Z* U" C}( R/ {8 w2 L  Z$ y
</style>" ?7 a: i0 `1 O2 ~+ @
<script language="JavaScript1.2"># _' ~4 O2 N4 ?) E$ V' j% q
<!-- 改变下的字体的大小。颜色-->
8 I, ^: f, w* e& x% [1 Fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
# k2 d" C' _% O' O2 Y* L; l$ @var hidetimer='';3 c# m; F% r3 K# Q2 p
<!-- 改变下的弹跳速度-->" t8 o% }+ w! i
var BallSpeed = 20;  O2 H8 X- t2 G1 v( B3 h9 s
var contentWidth;
& S0 V7 j+ y& l$ I! a; R6 f8 jvar contentHeight;3 a) S6 N! s7 p6 J2 L
var maxBallSpeed = 50;+ Z' |9 j0 X, J0 t
4 m) ~% h5 c0 }1 v7 h' f
8 E( l' u2 \2 t2 m
var xMax;( f) z2 s/ U, J0 f4 q7 k
var yMax;$ x- E7 P2 \; d9 s( X1 K
var xPos = 0;+ i! ~3 I5 q0 p. n4 U+ D; J9 |
var yPos = 0;. ?: P+ r& f% P) K7 C* |
var xDir = 'right';
' [  N) v2 j6 V3 S  u. c$ |var yDir = 'down';
* E$ Z4 V/ i7 C4 M9 Svar superballRunning = true;
; ], X/ i% d# gvar tempBallSpeed;
  s( H  L1 S9 Y4 C" y4 Nvar currentBallSrc;
$ j3 b( a+ m/ N0 d( d( Mvar newXDir;
5 `7 K  M8 }, E! j6 o* Gvar newYDir;/ s; I4 z( e' r# e; q7 u
* |, ?* q( q2 s8 @/ N! ~, f
function initializeBall() {; v7 [; M: j5 O
   if (document.all) {5 x6 \2 r9 j6 z$ O, \6 N: T
      xMax = document.body.clientWidth' a% I9 r3 I" X0 l$ R
      yMax = document.body.clientHeight" M' J" a) N. N3 S
      document.all("supertext").style.visibility = "visible";
% z/ Y( Z! x! J$ Z% J4 a4 ^      contentWidth=supertext.offsetWidth
1 I- S2 T, ~8 P4 A7 {* r# {4 |      contentHeight=supertext.offsetHeight- t1 N7 S5 g" g; V, I# ^5 v1 k( y! T
      }
; Q$ x; \4 \' w  f  A   else if (document.layers) {1 }: u1 Y9 l( A4 L% O( x$ R
      xMax = window.innerWidth;/ V4 e7 J. F& r! W
      yMax = window.innerHeight;
+ |2 M. f2 a# e- d& ^      contentWidth=document.supertext.document.width
2 [6 `. ]) N! e' k& e# q! }      contentHeight=document.supertext.document.height) C" w1 U7 R- a1 z
      document.layers["supertext"].visibility = "show";
* \1 g( y, S* q( d) g      }
( E! {3 u. m* n- i) \9 U   setTimeout('moveBall()',400);3 b7 t$ A0 u, T" j
   if (hidetimer!='')
+ w* n; B; y/ T& h   setTimeout("hidetext()",hidetimer)
" A5 R$ O+ w# }, z5 J   }" J1 ~# v! B7 ~- h6 m( u; x+ ?; j

) U- m) ~8 Q# |function moveBall() {% F- J6 N0 Y& q' G# l/ M
   if (superballRunning == true) {+ z; z2 A: _  Y1 l' A; [# b3 n
      calculatePosition();
" X6 u9 Z  I7 i( p$ D1 z8 I' {      if (document.all) {4 J2 x- n7 y. L; ?/ l" p- o# G9 \
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
% ]+ V+ z# x1 G5 i. ~         document.all("supertext").style.top = yPos + document.body.scrollTop;
" K+ k! f) C% e4 W6 W( |: n         }( `* P; H- r; |  S2 ]+ C
      else if (document.layers) {
) z3 {2 q8 }$ e$ H7 A( Y5 g         document.layers["supertext"].left = xPos + pageXOffset;" F& h6 a$ |" V5 I9 M
         document.layers["supertext"].top = yPos + pageYOffset;
- b- t8 B- _$ d, @7 ]/ |         }6 K" _4 j' o) A
      animatetext=setTimeout('moveBall()',20);
+ O- o, k' j. x; X% M9 u      }6 `5 O1 i- t* |6 `$ u& H3 E
   }* ]) y# Y' d6 E- B: ~1 N
/ u- M4 E6 Y+ S; W( ]
function calculatePosition() {1 t# J6 N' H' T' `$ F3 i
   if (xDir == "right") {( G  }5 q, A* ^# Z% ~& x- a1 c( A3 R
      if (xPos > (xMax - contentWidth - BallSpeed)) {4 U+ |& J3 P% ]4 f) u
         xDir = "left";
8 a# J+ o' m% p* d5 N+ g% P* C         }
& U6 C$ V& ]  M0 v1 Q- ~6 P      }
7 D6 `4 p/ T6 Y. ?   else if (xDir == "left") {( b( d/ s2 ~; y+ A) _
      if (xPos < (0 + BallSpeed)) {
* d' U% }* H" y; K         xDir = "right";
7 f/ X$ ]; n0 s+ F         }2 _/ G" X4 J+ x9 I) v! Z% A
      }
9 j* Q- m; B3 n   if (yDir == "down") {
7 H- i  W- a- D7 C5 K+ ^      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ g$ }% X  _1 ?* [& P" ]         yDir = "up";7 S; [, k' f- t  t1 c2 c" w0 r8 T  \
         }
: P$ C, I$ X' i, p      }# c- q2 L) @6 g6 Z. i) k- t
   else if (yDir == "up") {5 g/ ?6 d% R. D/ I8 C- m
      if (yPos < (0 + BallSpeed)) {$ R9 X0 Z8 `; d. F6 o
         yDir = "down";8 p5 N$ j1 o; V" ~% j; @' x
         }9 t7 \" G* Z3 o/ g
      }+ ~% E' c3 @( i4 L' R! s/ {
   if (xDir == "right") {% F3 U0 _, a' u. G
      xPos = xPos + BallSpeed;, _  l; p9 a1 R6 G, ]
      }
1 P) i9 q' A3 S5 D% V% C  Q3 p   else if (xDir == "left") {
* E2 i9 n; j/ u$ `! J      xPos = xPos - BallSpeed;6 u3 b( P, Z6 d0 ?  a8 F
      }
, [) T7 t( U; I! s5 }- L2 j6 }   else {0 M3 O5 T9 c( f9 y5 Q2 @, O- q  y
      xPos = xPos;
: [: ~7 b! A, \( H3 m! I0 D9 Y! c8 n      }. j7 M! c$ W; o; G& K
   if (yDir == "down") {
8 x/ k4 w$ d9 N8 h. g, y      yPos = yPos + BallSpeed;
4 d! ]/ ?# e# I5 w! N      }5 }3 ?9 Z, L' E6 v! N) g3 s$ P2 E
   else if (yDir == "up") {
; k5 {% q9 A4 S# J5 d      yPos = yPos - BallSpeed;* l) E. G" ]8 b& w- A) V
      }0 r* H( b* i3 E+ Y0 w& O
   else {
, H3 }5 N: L7 C/ g+ B  V7 Y      yPos = yPos;
$ y* o- f& M1 J+ K4 e. T, a% v      }
0 ]7 ^5 r. l# a9 J# I   }
/ R) |) L0 }/ h2 D! C/ ^9 @5 A# o$ e  `: M# j8 ^- L4 p5 ^
function hidetext(){0 K6 r. K5 ]. o# v# |2 n
if (document.all)
+ }; S  `8 P5 Q3 p* S# U- \supertext.style.visibility="hidden"
/ O5 g8 W9 i' c$ _: m# _else if (document.layers)# w$ P3 o4 M/ C# C
document.supertext.visibility="hide"
$ M/ ^9 W  L/ d; I3 s4 zclearTimeout(animatetext), s7 C; |0 [7 u& ^* ^
}; e4 a& v9 ]) H6 w
5 u( ?6 y( I  G3 e
if (document.all||document.layers){. f; n& d! q9 s) B8 m4 L# P
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; j. a" g% o& dwindow.onload = initializeBall;2 H! K& L- A+ D) V, Q
window.onresize = new Function("window.location.reload()");7 o+ e/ H7 N6 `9 n
}
' ]1 O9 N3 l8 m' ]+ J* @0 i" q9 J5 B
* n2 p. @0 s5 P/ A& J8 E6 U</script>

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