返回列表 发帖

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

<style type="text/css">
& n# i  Q  S, P) F3 ^% b* v( {8 w4 a#supertext {% l! D. T9 a* n
position:absolute;9 V7 v( \6 J( M' D
left:0;# `& Z" p! G' D3 ]1 }8 t
top:0;: |, H4 k0 E: b7 n6 `
visibility:hide;! W- ~% ?$ [+ h
visibility:hidden;
" P- Y) d- E% W' Q5 K}
+ H9 G: A  w; b</style>
& U7 I/ D- L9 T' N' `. m: `<script language="JavaScript1.2">( p; D* M: q4 X
<!-- 改变下的字体的大小。颜色-->
- f, m3 s( h3 ^7 U1 T( S: Q# G/ avar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'" h1 y6 B! j! V' T- k- A
var hidetimer='';" |5 F! \1 ?9 B! I
<!-- 改变下的弹跳速度-->
& z: v' Q% K" w' }1 ~& w/ gvar BallSpeed = 20;/ l# f0 f  F; f0 |
var contentWidth;
" `3 s$ O$ a  N& qvar contentHeight;; j7 ?* d! f. O) C, z3 P
var maxBallSpeed = 50;
4 S5 b8 C3 s* W4 W4 z& B
7 @& z# L/ ]* s/ @5 R$ G) b
) `9 B5 M# p5 ^- h) l  H* s4 f; bvar xMax;" s. [  Q, g3 O( H# s4 Y
var yMax;
0 h: j  l0 n7 a6 e( Kvar xPos = 0;, C/ |' ]. S+ t2 F3 ]
var yPos = 0;/ c  E8 r  _7 ^, t7 q" O
var xDir = 'right';% y0 r) Y, V- n/ _, H/ D( `3 M! y
var yDir = 'down';6 q' ~' }/ }  K# D
var superballRunning = true;0 X+ P1 ^1 ^# \5 L
var tempBallSpeed;
1 `9 |; c2 F1 r$ P$ s7 n# o- vvar currentBallSrc;+ n% H' P1 i8 U9 P
var newXDir;
8 H5 b* q& M* _1 {  S) D" ?! Jvar newYDir;
* u% z* V3 ]/ {! i  k1 R' K& g6 W; M( R3 K$ n: ~/ o0 g/ _
function initializeBall() {; r3 F; w6 H' n1 A9 W( z
   if (document.all) {1 C/ Z4 i2 P  g% @# n
      xMax = document.body.clientWidth
: d6 b3 Y& ]1 w- @/ |1 J      yMax = document.body.clientHeight
8 x6 v- Z2 d) Y; d9 j" a8 Y      document.all("supertext").style.visibility = "visible";
' ~3 C0 p  P5 w      contentWidth=supertext.offsetWidth& f2 B6 \% v$ @8 ]0 D$ ~$ a
      contentHeight=supertext.offsetHeight+ P  `7 y5 G$ t% X8 ~
      }
% P/ {1 T- I+ H/ n   else if (document.layers) {7 }- g4 J! w  q6 O' i
      xMax = window.innerWidth;- w- c( b$ A: L
      yMax = window.innerHeight;6 S1 t+ _  p7 L5 o, }
      contentWidth=document.supertext.document.width+ c3 ^+ P6 o2 x) q7 Z. \- {
      contentHeight=document.supertext.document.height: O  q: f" n+ m1 ~* |
      document.layers["supertext"].visibility = "show";4 l5 I4 o; U, i: ]
      }
- s+ o" c( E9 P8 i% A" O   setTimeout('moveBall()',400);6 C' W, |( n% D& L
   if (hidetimer!='')
- V( d4 K, D: T5 i$ P   setTimeout("hidetext()",hidetimer)
: N9 y4 [9 U6 ]& s( E   }
  s2 J" G5 j8 s# m- J1 C3 x, T4 b2 ~# c1 x: ?  v5 o7 S
function moveBall() {% P. T2 A' |/ ^# \% f; n
   if (superballRunning == true) {. E4 T+ i0 w7 V3 r# W) r4 j
      calculatePosition();
3 m) x$ l7 K3 I% G6 B3 x# H8 a      if (document.all) {5 t0 _" Y& u# [3 s  T1 `
         document.all("supertext").style.left = xPos + document.body.scrollLeft;+ h$ _& W, b+ a
         document.all("supertext").style.top = yPos + document.body.scrollTop;5 d3 ?; Z/ b2 M
         }) c- F8 i% D8 w' X" R, F$ y
      else if (document.layers) {! U+ B) w+ K- {* u" S
         document.layers["supertext"].left = xPos + pageXOffset;
; n' _$ s- P0 `# O; f         document.layers["supertext"].top = yPos + pageYOffset;
* v) z- o% h; L- T         }9 d$ i4 ]' H9 Z3 C
      animatetext=setTimeout('moveBall()',20);
, D8 m, O9 ~! L; y2 Q      }
) f, |: R' h* y6 H: p   }
+ T! l! y% t. V6 d
) L8 H/ X) q2 ~$ F4 _; V; Rfunction calculatePosition() {' g8 H* t/ W% [7 W
   if (xDir == "right") {
+ x! _1 I5 C- ?3 j2 V6 l# u      if (xPos > (xMax - contentWidth - BallSpeed)) {5 `$ Y9 t! _$ H/ n) \$ }' a* G
         xDir = "left";
& m, s! U/ W+ I+ w. U- ~         }
( V6 H& K6 X" W2 z' L* }* P0 z( ~      }$ J! O7 A$ m  I
   else if (xDir == "left") {
  A" S! ^' C+ }" T& ], a+ M      if (xPos < (0 + BallSpeed)) {5 }- F3 ^; @) P) }/ n' ~1 \
         xDir = "right";( t0 }7 S& `/ N. Y! N0 t* s( a5 x
         }3 {" G9 f7 `/ t9 A& V, s
      }
7 B3 |8 @+ m6 O) b: x6 m' q   if (yDir == "down") {
% r$ {3 b) a9 o; ^. f: ?- Y3 J      if (yPos > (yMax - contentHeight - BallSpeed)) {
8 L6 S3 V9 l8 g         yDir = "up";
2 V7 _" j5 N: K6 U/ |         }  }6 b5 K& o" p% t6 W
      }
2 \( R8 J; v$ G% F) d: D   else if (yDir == "up") {
  A" X# a2 e3 P6 o+ q      if (yPos < (0 + BallSpeed)) {
; t; [3 z# _- [' g         yDir = "down";
) K, z* Z% X+ N+ N, W         }
& ], h9 l3 H2 ^( ]1 P. Q) E) E' [  A      }" ^. b' z9 E* h% c8 A
   if (xDir == "right") {4 a2 W/ t7 r7 J( s% m+ Z! D
      xPos = xPos + BallSpeed;: n* _# J, U. ~2 r
      }! e6 t6 d7 u; }) Y. k% g
   else if (xDir == "left") {& l- o" N8 F" v& D* x1 w* U2 }
      xPos = xPos - BallSpeed;
* P' h' y, s7 o; [1 b+ C6 c6 |      }* n5 z& R8 \' J
   else {6 F6 |1 V+ D  v6 x4 }
      xPos = xPos;
$ r+ B) N, N5 Y2 b, r2 Q* n      }5 w* R, f0 G; Z- d8 W5 H1 P+ A: l
   if (yDir == "down") {
' t4 M  S* H% G) t1 w( u- K      yPos = yPos + BallSpeed;. D* n  x/ e, }. z! m) q
      }- x* b/ r) d& q4 m! ?
   else if (yDir == "up") {
8 ]; T9 @. P7 n9 t# m7 a; Q      yPos = yPos - BallSpeed;/ l( Y' h2 F" a3 O
      }' C9 L9 P* G+ x+ u/ ^5 ?
   else {3 i* N2 q; i4 R$ I
      yPos = yPos;
5 M+ S# j" N; ]9 x" Z      }9 y- M) {. A5 G: G% k, O$ e
   }
' U! ]9 M, p: g/ U, W
0 D0 [5 @  L/ n8 v. `8 Ffunction hidetext(){. D" b; p+ D) y1 t; \
if (document.all)5 O1 L0 [0 J6 K: b
supertext.style.visibility="hidden"9 h4 |+ u9 ]8 m+ \' J# J5 K- _+ U
else if (document.layers)
3 B8 U% i* F' Hdocument.supertext.visibility="hide"; {1 b7 u# k4 a4 w: ]
clearTimeout(animatetext)5 `2 p4 l2 Q4 f" L  b- ~
}' n; I9 }1 w9 T( N2 M- E, C
% a7 j8 f- T! Y# d, M
if (document.all||document.layers){! ^# [" ^4 H$ L/ z9 c
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; h* _2 Y$ u7 \* E* u0 `% c) }/ U2 b; ]2 Wwindow.onload = initializeBall;
2 F; B: ]% B( d. H! jwindow.onresize = new Function("window.location.reload()");$ m9 L6 i* B% |/ I: g
}& y. Q5 U1 X# b) p" }; s

; k: i* Z+ h3 I# U; U4 B</script>

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