返回列表 发帖

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

<style type="text/css">
5 ~" `4 y8 ]- o$ O#supertext {
" A' Y9 J# [7 M6 \% s* E& l: sposition:absolute;) u& B& H9 h- A) ~$ u' u
left:0;7 X& ^1 F) V( `1 @5 C2 i
top:0;
. u9 ]5 b( ~5 l( q  Bvisibility:hide;
2 T3 d0 E6 I1 k8 J, X# Y( Ivisibility:hidden;
) K) l# f7 F/ |4 g( w}0 e/ V* r' c0 L: w9 T' x$ F
</style>
+ J) B4 r5 {: l$ N: f3 x<script language="JavaScript1.2">, s- `) M0 O8 }  G( D
<!-- 改变下的字体的大小。颜色-->
# C4 e8 K0 D2 W$ b8 f8 x/ yvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 I$ S0 p  y" z. q
var hidetimer='';  f0 |) {* ?1 ]% W0 b2 g2 Q
<!-- 改变下的弹跳速度--># y" r9 z* |- B5 S
var BallSpeed = 20;
: ~6 h3 N! L4 h! z0 Nvar contentWidth;  {9 U$ K. z; p& t5 b( j' ~
var contentHeight;
7 d& Y* ]$ a: Hvar maxBallSpeed = 50;
5 |0 x& _0 u9 H! t3 D
9 O6 v% a3 M: q  I% M5 k$ g
2 X  c. a% X; W. V3 [3 M, Tvar xMax;6 o& o, K: J3 D( B" M' y" p4 v# Q
var yMax;
+ _, y3 w8 S6 p" ~+ b- Mvar xPos = 0;' a& D$ S$ g% V% e* v( P: d
var yPos = 0;
7 o% d8 k- @9 K5 p5 l# Nvar xDir = 'right';
$ c! e& _; y% j8 ]var yDir = 'down';
/ o& y# L7 u  nvar superballRunning = true;' J7 h/ ?5 J8 w; C
var tempBallSpeed;2 V( M+ Z$ V6 O6 D& |' d6 y" n
var currentBallSrc;
; c7 i6 P0 V6 y! i' E  O; u" fvar newXDir;- M6 \0 g& V6 j+ p- T! E8 e9 ?
var newYDir;( ^& M1 C) F3 {& s! D/ [9 L! K
6 Y/ z# O4 R% c
function initializeBall() {& l7 @5 R9 Y, T( S( S0 }" y5 }
   if (document.all) {4 l: g' G( Z- J# @
      xMax = document.body.clientWidth
5 S+ L4 V# t' _9 z$ L& ]4 W) ^/ E      yMax = document.body.clientHeight
& o8 o* N$ p2 F      document.all("supertext").style.visibility = "visible";$ q) O! s. a; }# {& a
      contentWidth=supertext.offsetWidth* q" ^6 e7 i" p$ I1 E; k
      contentHeight=supertext.offsetHeight
1 i" k3 X3 G* W* M0 M' q- \6 K      }
" q! K8 R, P( N2 P# x! t( x7 {" M   else if (document.layers) {
' \3 ^3 P: ?  r8 c, h      xMax = window.innerWidth;0 a$ H0 P% M0 w* |: x
      yMax = window.innerHeight;
' O3 c4 B, b+ z1 p- S0 }      contentWidth=document.supertext.document.width, n- X9 ^4 M6 H. l! J& ~
      contentHeight=document.supertext.document.height
4 X0 W- j3 J" |: L- |, Z      document.layers["supertext"].visibility = "show";
& @4 `* z( M$ X, k' @! ^      }
& l4 H8 w5 ?  G2 b. y/ g   setTimeout('moveBall()',400);6 c2 H# ?$ Y1 T2 m9 [- r# c
   if (hidetimer!='')7 |1 U/ p# z) y9 e2 k0 w
   setTimeout("hidetext()",hidetimer)* z* c$ E$ @0 \, g- H' E( T
   }$ O1 B" g) e; }  w; E& T: g7 ]/ m7 {" q3 Y

: G7 h, S0 C" W7 R, Xfunction moveBall() {- y2 N6 ~' f" a- ?, H# V
   if (superballRunning == true) {4 h% s# \, k( F% K' g& N
      calculatePosition();
4 c1 i  L! G( I8 Z2 e$ A) L      if (document.all) {
) }' j! k: }) \2 c5 C5 F! n         document.all("supertext").style.left = xPos + document.body.scrollLeft;. u4 t9 j2 a7 t: [) m# Y
         document.all("supertext").style.top = yPos + document.body.scrollTop;
7 w1 W( a) p% O1 T: P( O, c% ]         }% [1 f1 Y/ M5 c; {# o0 j
      else if (document.layers) {
, O5 w& d" M) J# @( K9 [! b         document.layers["supertext"].left = xPos + pageXOffset;# [/ U0 i5 L6 `5 B4 m; C" d7 Q
         document.layers["supertext"].top = yPos + pageYOffset;3 s; e: i1 c: L) i! b
         }0 H- k' d; b% ?/ o: g1 v' g- m
      animatetext=setTimeout('moveBall()',20);: Q. v( V8 x2 ]' ~
      }% X; i. w' w' B* K! g( |
   }
' K7 ^" ]) J. Y
: _" W: ~8 [, M- qfunction calculatePosition() {
# Z# X" O+ e2 Q0 `   if (xDir == "right") {
2 W/ [! V" p! ~      if (xPos > (xMax - contentWidth - BallSpeed)) {
& v1 c( t- w" A. N         xDir = "left";( k5 N$ _7 a7 w" Z
         }+ P, O. b6 g1 G7 j5 J6 M. v
      }, n, Y& Q: o1 R9 J+ y: ~3 u$ k
   else if (xDir == "left") {3 E# ^9 ?8 n9 l7 W$ O
      if (xPos < (0 + BallSpeed)) {
( O& t9 F# t, f; s5 F8 o$ d         xDir = "right";
% t# T3 X: n, T         }
6 C" {8 L5 w# X      }) B9 H0 I9 g( N$ |5 c8 Z& e7 w
   if (yDir == "down") {  z$ q; L' t  o8 J$ c( c
      if (yPos > (yMax - contentHeight - BallSpeed)) {$ G  A. L7 |9 K# n# u3 P# t; t8 w
         yDir = "up";0 }% A% {: b9 a6 R; @/ C: ]
         }: {/ e; E' _) H  |1 _6 W
      }
9 T1 ^' N; X9 D& U( U) D   else if (yDir == "up") {  B: l9 O% l* r  z
      if (yPos < (0 + BallSpeed)) {3 m4 ~0 y. h. r
         yDir = "down";
1 O4 a) L3 A- W  |- v4 u         }$ ?# i( u+ B7 p1 C
      }
5 u) h: X. O2 B. a" b; l   if (xDir == "right") {+ w( v) S$ L: H% F0 B
      xPos = xPos + BallSpeed;
$ }+ |( \3 |4 }1 r      }2 X. }# m# z7 V) w) v* z
   else if (xDir == "left") {
; b0 f+ W0 z3 A+ |: ~; K      xPos = xPos - BallSpeed;
/ o/ w. H" ~! e5 E      }
- k5 t8 v3 Q& {9 h6 U0 V% f9 O+ F   else {7 O; c: r# ]3 @0 z$ b
      xPos = xPos;& i. ~! P  R4 M, P
      }
! R9 Y# E9 w) Z   if (yDir == "down") {
+ R8 L6 p9 n7 o! M: o+ ^6 ^' G" i      yPos = yPos + BallSpeed;, v% n% W) J! Z, a6 u" v4 [
      }
) K; n0 M% n; x& U7 k4 G( J1 r  e3 }. V7 H   else if (yDir == "up") {" \- [3 k6 }9 Y. E
      yPos = yPos - BallSpeed;& w  C( _5 ]6 G' s% H
      }
7 S) M; b# H- R   else {
) q' G+ r, D' y2 ]* M+ ~      yPos = yPos;) h- ^8 t; q3 B
      }
4 a2 h7 C  O# m+ m& d: I( O3 D5 r; Z   }
3 `5 S( |2 @( j/ ^6 B- s+ ?, m8 @4 A* B6 ~+ y
function hidetext(){
4 o; P% {# s9 A6 ~7 ?+ x1 S& Zif (document.all)
7 f) D( I( A& s  z; J' G$ s6 dsupertext.style.visibility="hidden"2 M1 b7 E) w8 p' Y( G5 f5 @$ J
else if (document.layers)
/ y* q+ c& B( ]9 P0 F6 Ydocument.supertext.visibility="hide"2 B4 r. h6 C# ^1 N) ?
clearTimeout(animatetext)4 M5 h1 x3 h" N6 {- R
}) X6 {* S. O0 x! C+ |& H; O

8 u4 j" F* @7 u( b+ {if (document.all||document.layers){
7 v$ Z1 f( `: i, `( Fdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 ]: r4 X) g: q# T/ j; U8 a
window.onload = initializeBall;+ Y/ s( B* }% V$ G( h
window.onresize = new Function("window.location.reload()");- I3 q+ `# d) O2 z% [0 O
}
6 \. Y. s( X) S" @
4 z; `0 l" t' ]. [5 M! f</script>

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