返回列表 发帖

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

<style type="text/css">
2 T4 H% |3 h8 |) L#supertext {0 J- V+ ^% p' }: O
position:absolute;
3 M, V) _9 x$ b3 Cleft:0;- V! i- C7 [" F) c  I8 v3 `" B; r. p
top:0;* H. l7 @( J' V$ m
visibility:hide;  M8 ]( Z# b! \
visibility:hidden;
7 G; V4 c$ N) k1 u0 s}6 b  a& h4 H0 ^6 y1 I/ u
</style>- \, I7 B7 }6 t  x
<script language="JavaScript1.2">! [$ G; e" B" F2 z( k2 x5 G
<!-- 改变下的字体的大小。颜色-->
7 M" h7 w0 H& {. P& ]& t% ?4 Bvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'  S. S: J$ t6 E8 L8 Z. \$ K  o
var hidetimer='';
- x$ l( o7 D& U- N; Q$ o% m<!-- 改变下的弹跳速度-->  E8 h4 }  P, C2 |
var BallSpeed = 20;( A; Z, c: m4 T3 z6 F
var contentWidth;
: y5 Y6 T+ ]5 ovar contentHeight;
8 j& c5 W: p' o" O) }7 Fvar maxBallSpeed = 50;- d* X2 Q5 O: K+ v( P0 ?0 U

" F( Y: m: j' n
$ j" X( v8 j* f: Z. n% ^var xMax;- t7 P, K* r% Y2 |4 K/ l
var yMax;
( H' I0 `3 ~5 c+ v3 Y) `var xPos = 0;4 ?" t) Q# ]1 f+ R
var yPos = 0;. n$ n4 ?$ Y, \9 C- {
var xDir = 'right';
" t. G3 e2 L0 O, ^, T# qvar yDir = 'down';
$ x/ P' E6 Y0 I7 R8 f9 Q; lvar superballRunning = true;
; H& U6 U  B7 e! L4 ?" z. Qvar tempBallSpeed;# W$ X4 H' g) ]( ]& A' V' O
var currentBallSrc;( _$ v9 \) X$ h0 [
var newXDir;
# f5 f! V  d& |var newYDir;3 q# Z  Y% w0 I  U2 t; G
. M3 M& P: N; X
function initializeBall() {
+ k$ [8 o0 O. V- p1 ]   if (document.all) {7 @& {) d* F' a' y1 T4 f
      xMax = document.body.clientWidth! ~2 S, k+ Y# v  b' F6 ]6 V7 G
      yMax = document.body.clientHeight
" m5 s% U9 @/ U, u0 e$ Z      document.all("supertext").style.visibility = "visible";
4 u3 X( n, n0 C, W7 H7 i+ a      contentWidth=supertext.offsetWidth" _- l! M+ O( M  J# L
      contentHeight=supertext.offsetHeight
* n1 Z4 `: p' R) r      }
6 z9 j0 X  u9 p( b5 ]) G   else if (document.layers) {
& Z+ V1 u7 B/ Z( E      xMax = window.innerWidth;
1 m, L6 N7 W- G5 v$ L/ W& S: }4 E      yMax = window.innerHeight;+ x1 B4 Z* M& ~% s1 b1 W: W
      contentWidth=document.supertext.document.width- |! q8 k1 y3 e/ h& N0 ~
      contentHeight=document.supertext.document.height% V' K% o2 r  A& @9 _- T
      document.layers["supertext"].visibility = "show";( T" y* h+ p' Q+ w9 a* d0 w3 v
      }
; {" a. p8 v% A0 m. B   setTimeout('moveBall()',400);
' S- d9 R3 W$ k* p$ x   if (hidetimer!=''): P' _; D0 b4 r: R- T$ t
   setTimeout("hidetext()",hidetimer)
0 u1 S& z7 a  E; k# E   }
- R$ S5 V9 i4 A5 V5 I4 h: R) Z  l! [' ~5 M* \8 m' }
function moveBall() {
# A+ Q. s' J0 n/ z   if (superballRunning == true) {
' a' ?. L6 P: [' n' {6 X1 v      calculatePosition();
9 X. Z! c+ Z7 C- N: W0 l* g; g6 x      if (document.all) {& d0 ?$ N" X  e6 z) s! I
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 Z; I' m3 q4 g  M" |         document.all("supertext").style.top = yPos + document.body.scrollTop;
  @5 u: f% g2 q* d         }# K* s/ Y7 s  a+ h' V( [# A
      else if (document.layers) {: {8 i$ N1 J5 C4 M1 M
         document.layers["supertext"].left = xPos + pageXOffset;
* u! g- I! }6 c6 G& y6 X         document.layers["supertext"].top = yPos + pageYOffset;, b: k, z+ G9 E* o' J0 W3 k9 X- g9 R
         }
" ^1 H2 Q+ g9 c! \' N- d; n      animatetext=setTimeout('moveBall()',20);
/ l6 V) Z! J/ ~  V8 M; F8 }      }! H6 J* k6 E) W
   }4 h9 U$ _7 }8 s/ u& t

  \2 v" s- F0 S& s& p9 yfunction calculatePosition() {
0 x: ?5 @; I/ h2 P   if (xDir == "right") {
3 D0 \" p; o# \% d( _  `2 g      if (xPos > (xMax - contentWidth - BallSpeed)) {% B, }) M; B8 n3 M& |
         xDir = "left";8 {2 A" w: ?; C# y  h. S1 ]
         }8 f+ ?: K$ T+ G, b
      }
" Y& H! F' o$ A& y4 k   else if (xDir == "left") {3 |9 G4 D7 R6 R9 P
      if (xPos < (0 + BallSpeed)) {
" R; l/ F2 a! v3 A* u, _         xDir = "right";0 q- f6 I/ }* b( Z- d4 ^+ y
         }% c  a) R2 F0 Y- g# o3 e
      }9 |3 H; {! [: L
   if (yDir == "down") {
( @6 l" K! @2 K9 N3 ]; p      if (yPos > (yMax - contentHeight - BallSpeed)) {
; `+ V! ^& K: O( [, y+ _         yDir = "up";6 E6 u- j/ W" {" D0 @) I, ~+ D4 Y
         }
& V) [1 z. Y+ q7 o7 @2 `      }
; }8 u5 d5 V/ r3 ~/ n   else if (yDir == "up") {
4 j3 V9 t* r. y% ]  l; n      if (yPos < (0 + BallSpeed)) {8 c8 r0 }* m2 z7 _: Q5 B6 u" j
         yDir = "down";
# j! c8 e' y" b% V" ^         }& ]# v/ e/ J: \  W* `$ z
      }
/ O% t0 {9 }8 Q) R- `   if (xDir == "right") {# s# ?# S6 G  H1 I3 o  P) J  t- z
      xPos = xPos + BallSpeed;
: p' o  w+ F3 E, |. G0 S( H      }
) j4 @+ @* z. N0 v' o   else if (xDir == "left") {* A. f# s; G' l# L
      xPos = xPos - BallSpeed;( @9 h) f0 R! R' ]
      }
3 ?2 C1 |# I2 Q2 X# e   else {
9 R$ u: W) S  N0 l' P! r) W- A      xPos = xPos;4 n- M. E  A, A
      }
8 G7 r6 k5 _& N. z8 \! r- {   if (yDir == "down") {
! C/ Y& T7 `/ D      yPos = yPos + BallSpeed;
. M9 w- w7 O' F( e      }
/ G* S6 x4 `/ h$ P   else if (yDir == "up") {
! v/ a$ ?0 N# o      yPos = yPos - BallSpeed;
6 H8 f* Y+ l9 X! M0 E2 i2 t: o      }
2 Y) ~! K( h9 `& ~: y7 s! Y   else {4 x5 @/ L" L8 T8 a$ C
      yPos = yPos;" X* y& U& W- X* ?- d4 h* ~1 i9 O
      }) r) u/ w  V( k( b
   }6 R" t- Z& h' C

' B. e: d+ Z% Xfunction hidetext(){
( Y3 O3 W9 u3 Iif (document.all)# i  m3 N/ W& ?) f2 Y, g# ]5 i
supertext.style.visibility="hidden"
4 ?4 L9 {& V3 {+ velse if (document.layers)5 a+ A% Q" u; x7 x* ]& {5 w
document.supertext.visibility="hide"
" s! S) ?' z) f( C0 SclearTimeout(animatetext)
$ w0 [' V8 [1 `) n) x7 j9 d}$ {: j" N& p+ E+ G' f

! I) @3 S& V5 A- z5 J0 dif (document.all||document.layers){
! a# A" @- o+ r! ~# ndocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* R: h8 ^1 U9 J( ]8 u5 Fwindow.onload = initializeBall;
$ c$ S  s( A. d2 }4 k/ [window.onresize = new Function("window.location.reload()");2 U. i0 L+ M+ E3 ?( y
}* i/ e0 u, N& x) G7 M8 J4 g; E: B

9 h) O+ I( M; q1 k- a; G7 b</script>

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