返回列表 发帖

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

<style type="text/css">
/ f0 j- [6 v7 D2 t#supertext {
+ b; x1 F; j) `7 Iposition:absolute;
: ~$ K2 k# j" ]1 X  g( w/ dleft:0;0 M- m% H, j2 P4 j, B  h
top:0;3 f: U3 ?2 t* Z; H7 x$ S
visibility:hide;4 e1 C' E3 U" f
visibility:hidden;7 z  B8 E7 V+ d  y& O* w
}: k& u: I5 T% g. {& V
</style>
" Y* V! _; x7 O( i<script language="JavaScript1.2">) q7 N0 A: B6 W' e7 X
<!-- 改变下的字体的大小。颜色-->! Q! _- d: f# B
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 D$ \6 m& l! y6 Y) X5 F# ]var hidetimer='';
/ O1 B9 A1 s4 M2 d: U7 p( L2 K/ w<!-- 改变下的弹跳速度-->. s" G& U% w2 L, |- Q( l2 U: _3 L9 `
var BallSpeed = 20;
" R; l0 k( f3 _' Q8 T" u8 u# J8 Qvar contentWidth;& O1 e' K# J1 Y" z
var contentHeight;
) U1 H7 H) D& [var maxBallSpeed = 50;
1 @9 m- }( c7 w' \: X( m; K
: i$ |; y; L( S. D# u  t, k4 \& R4 x( t
var xMax;6 B/ L: ^  x, ]9 L' n% @1 \
var yMax;
# d. E+ N/ H0 }. W& _/ U/ [9 Svar xPos = 0;
8 j/ S% b. b' b+ ^var yPos = 0;
, K$ @1 l9 U0 {0 f3 S& o" m2 ~var xDir = 'right';
. W, h' H4 i0 W" Cvar yDir = 'down';: K* U' q" h2 t, M+ o% _
var superballRunning = true;
! s, E2 b# Y) h( [+ _  S  C3 K1 Zvar tempBallSpeed;
1 U& W3 F0 `+ ?# j$ ^2 L8 |$ fvar currentBallSrc;
  h2 D/ q, g' C* u) {1 E# Avar newXDir;
: U8 i8 P( j; svar newYDir;
4 s. S2 R8 @6 p7 l
& h1 B4 ~9 V( q. T  y  Dfunction initializeBall() {% r& M- Y/ I/ s4 K5 q/ [
   if (document.all) {3 H; F1 R) ?; l$ k0 i
      xMax = document.body.clientWidth$ I4 _" A+ U9 t9 z% p2 l" m, y
      yMax = document.body.clientHeight; D8 G" u1 h* O1 B$ Q- v/ h
      document.all("supertext").style.visibility = "visible";
( }9 j% f9 e7 g6 Z, g8 P3 w      contentWidth=supertext.offsetWidth" ~- n6 f7 e. f6 d" D. f
      contentHeight=supertext.offsetHeight
8 D# y( H0 d; x; n& l      }0 k& m, u+ ?1 V1 E5 L
   else if (document.layers) {+ |$ P' \5 v$ C0 }7 w
      xMax = window.innerWidth;
9 C! N1 Z: ]% ^# t: G      yMax = window.innerHeight;
/ z; f& Y% t7 [( v! a7 X: f2 b" n$ X      contentWidth=document.supertext.document.width
4 a2 g* @' T) e& C8 I% d) [( r      contentHeight=document.supertext.document.height# y, ^8 p" M+ {! Y' D8 B. M( _9 J& _
      document.layers["supertext"].visibility = "show";, v3 Z9 M0 `0 T* x' `! ~# a3 K) M6 x
      }
# c) ?5 r/ u, k& K  s   setTimeout('moveBall()',400);. X8 N; n5 c3 Q# R6 p& e6 f2 a( n
   if (hidetimer!='')8 e$ c4 F4 B5 I$ k5 y4 ^
   setTimeout("hidetext()",hidetimer)  d  O: B8 d6 z
   }
$ M/ k$ P, K3 c, F7 T! A& p& O& J0 K& Y+ J5 K
function moveBall() {
! `" I+ l% ]0 z, z   if (superballRunning == true) {
. Q' Y9 X" F$ D/ a  l, g      calculatePosition();
9 ~4 L; i; D9 v; g' O# q      if (document.all) {
5 M- A9 q3 t4 k5 {; L         document.all("supertext").style.left = xPos + document.body.scrollLeft;$ s  H: Q4 o3 R2 q5 l9 U/ S& s* H
         document.all("supertext").style.top = yPos + document.body.scrollTop;
. O- @5 @! W- z- d4 @$ ?. q         }
) T7 G; @2 d+ U5 ^5 M, V& m* K2 _      else if (document.layers) {
7 F$ k% }% Y& L4 o4 d' b3 P' R9 U         document.layers["supertext"].left = xPos + pageXOffset;7 g8 m9 u4 V9 p" l
         document.layers["supertext"].top = yPos + pageYOffset;
4 u6 U" ]; C: J& [2 n3 W         }
3 ~6 ~7 e# `; K! p      animatetext=setTimeout('moveBall()',20);
/ \- r2 @- q4 n: `' _      }3 }* s! D& h0 v$ c8 Q+ j
   }
) `8 H+ ~; k2 I( }! _& T  L' f3 m( D' ]1 i
function calculatePosition() {+ K  r8 T* S6 m0 @
   if (xDir == "right") {
" ^: G9 k$ J' [. m3 R; T' t      if (xPos > (xMax - contentWidth - BallSpeed)) {8 P6 ^9 ~# ~% v. @1 f& y
         xDir = "left";3 a/ H2 A. G: |0 k7 s
         }
% c: T! J# j. y' W0 [. E      }
, q$ _5 f: p, S; f; d   else if (xDir == "left") {
/ Q0 B7 `; `4 }: t& Z! Q9 c6 y      if (xPos < (0 + BallSpeed)) {  h5 z$ N& ?' \8 c; u* P3 v
         xDir = "right";
/ Q  R* ^! a: ^( H9 \: M7 w         }' G0 ~7 d+ A: p! R" P. w
      }; c; G# c3 g. \
   if (yDir == "down") {! Y8 h! P& V5 v/ ^, @0 b
      if (yPos > (yMax - contentHeight - BallSpeed)) {
4 W% y" s3 }7 v5 h1 v         yDir = "up";! s4 i: O1 ]" e. z9 W/ Z
         }
* q) D& ?  ~6 p! c# A: i      }% B! [  p9 t/ V. {7 k
   else if (yDir == "up") {! n" |2 F8 V* z
      if (yPos < (0 + BallSpeed)) {, a. ?+ V2 c  E* O: A
         yDir = "down";) y( L; V- i) i3 R$ j6 x! o
         }# i, |# z; |( S$ Q0 V
      }
" o" ]! [1 a3 z( N8 ^; e   if (xDir == "right") {
# w/ r' i8 Q# s2 p9 v4 [: a      xPos = xPos + BallSpeed;
  j( g4 w/ X/ K1 T( w5 N5 g      }
0 y! C: Q: U6 }8 p, `   else if (xDir == "left") {
$ w7 s9 C* H$ u9 a3 u* ^4 ?' O      xPos = xPos - BallSpeed;
3 K) j& P) `8 u7 e; G, C      }4 Q6 c- F1 Q% Q6 P2 M( Y
   else {! N/ Z7 F! ]- f. e' T% F% W9 `
      xPos = xPos;5 m; N. P; k+ Z
      }! b* D1 z* o' V- f  X
   if (yDir == "down") {
1 _- R$ D9 u: V; E! G, ^! D      yPos = yPos + BallSpeed;/ K; I- j8 T& s0 C4 X
      }+ X. X! l( P/ r6 [; ~
   else if (yDir == "up") {
+ Z4 L! v2 h" p0 \3 H      yPos = yPos - BallSpeed;6 i; B. e/ m  j  G( b
      }; B0 l( p$ M5 e
   else {' {; b+ H7 y  q' ]  n7 R, q# @* M
      yPos = yPos;# p: I# c* D+ ?9 q
      }1 m% |; ?: @# f1 }* g' p4 |( z- A
   }7 L' ~; y% j+ x; j$ x- ^
0 n! z- g7 n& R+ _6 w* l
function hidetext(){  S* z+ i8 w- v% Y
if (document.all)8 Q5 R2 v9 A- C# \
supertext.style.visibility="hidden") X) {4 s5 }- l& D; V
else if (document.layers)
# |) Y9 V" r% x4 O8 cdocument.supertext.visibility="hide"; w; b5 s, t, B1 F
clearTimeout(animatetext)
5 ?, T% r1 Y% R5 e$ K}0 K/ u: V6 g; Y& Y" t8 n9 Z
8 t" [' m( D' i) [6 S, q' q+ B
if (document.all||document.layers){8 {& M) ^& G; Q6 @! B1 U
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')6 W, ^4 {7 o% V4 B) X+ p
window.onload = initializeBall;
% O0 v4 C8 \! w  hwindow.onresize = new Function("window.location.reload()");8 F0 f/ E0 b$ [4 l  y1 ]# J
}( Q! {1 q( s) f# `, I9 u' e; N
% r! D# _. e, T' s2 F
</script>

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