返回列表 发帖

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

<style type="text/css">
. o8 B5 c9 T2 j#supertext {8 i% g$ N; c& V9 X! _
position:absolute;0 h! W6 G( y6 N5 p( B, }9 K9 J, l8 W
left:0;+ c- j8 j* X) j9 Y& L3 y
top:0;- O8 d5 j$ Q4 B
visibility:hide;
1 d' i; @! Q+ n! d: ivisibility:hidden;. l$ x5 c& Y0 x" ?
}( d) s8 z8 Z3 g* o0 S6 R( y
</style>5 |2 u- W' b' y% H+ `
<script language="JavaScript1.2">! C0 ^4 a3 p4 J& I; |
<!-- 改变下的字体的大小。颜色-->
/ J0 \  E' m7 r" e# z, X% A8 e. Rvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 M& A+ v( O& p5 Dvar hidetimer='';
  H& B4 e* Q; ~8 ], @4 c& z  \! |<!-- 改变下的弹跳速度-->
, I, I3 z% [2 K1 a9 Avar BallSpeed = 20;
9 n3 }9 g/ R$ I4 R# _: U* p3 ]% h8 Svar contentWidth;
( W. [% r+ G" E3 k$ q- l7 a$ O7 yvar contentHeight;
. s$ ], ?) m8 ]7 C/ svar maxBallSpeed = 50;# R5 \1 h" V0 o! E9 O

: Q$ n8 R4 s1 u+ ]3 U* Q6 W; ^9 S- O4 ?0 Y
var xMax;
9 n7 G  x, A. }( u  j; Svar yMax;
. f( A/ K* X( i3 h- ]  I8 Fvar xPos = 0;
( }8 P9 L; U' L% n% r' j, u/ Wvar yPos = 0;0 e) b0 ^4 V: |6 j
var xDir = 'right';
  H) p& l  p  v) v! G5 mvar yDir = 'down';( H6 L- |; c0 x5 P3 O
var superballRunning = true;; n/ R8 m  H7 `- L3 P
var tempBallSpeed;( P- V3 V) d1 a0 h/ {. H
var currentBallSrc;
1 i0 U: \% ~$ C3 o3 Yvar newXDir;
, z* u/ j7 G0 X) n6 ~var newYDir;6 }5 @4 i- j  j+ y

3 T6 Q+ }% ]$ {9 P1 B) ^function initializeBall() {: c& f7 L( }3 A6 P5 Y/ X1 j6 p- Q
   if (document.all) {' A+ |0 D. E! b
      xMax = document.body.clientWidth- F; l0 Y1 w* Q$ z; h
      yMax = document.body.clientHeight  H  S. i0 Y2 {
      document.all("supertext").style.visibility = "visible";
2 ~% t; ~! _( P9 D3 G. o  g      contentWidth=supertext.offsetWidth
. Y7 o' P% }  x( o% p      contentHeight=supertext.offsetHeight
# X: p# ^- t) X+ m      }
# d5 ?/ b' @9 d' W* q2 W   else if (document.layers) {
# a* V/ v9 Y' i# Y& n8 c+ @( {      xMax = window.innerWidth;- |" l# m: h) ?6 s/ c
      yMax = window.innerHeight;& Z2 e& E( x0 q) o5 z# |
      contentWidth=document.supertext.document.width8 i9 v* W- ]. f- I
      contentHeight=document.supertext.document.height" a  F2 y$ Z+ C2 S9 @
      document.layers["supertext"].visibility = "show";  k, \  W- r) t0 f/ }
      }
( B* W6 P2 ^. U& e3 g   setTimeout('moveBall()',400);
, s  J! f, |# h- a# O* ^" Y9 W   if (hidetimer!='')
1 n' A# G# v) Z" h4 F   setTimeout("hidetext()",hidetimer)9 K" @# T' ~' V2 W( F' Z/ n/ k4 b0 q
   }; T* ?1 D4 Y  X' z! D

7 j7 [; j/ K& |3 O# a, |6 u# D7 sfunction moveBall() {1 D+ x: F$ @4 [* A
   if (superballRunning == true) {2 R: g$ w8 g# z. V" b4 \1 `
      calculatePosition();3 Q$ [; O0 C/ t% z) [! O: R/ A0 t
      if (document.all) {
, U  }# q3 m6 _         document.all("supertext").style.left = xPos + document.body.scrollLeft;& O* a% I2 v1 M# Y$ z
         document.all("supertext").style.top = yPos + document.body.scrollTop;
- W5 Z/ T2 f$ i& g" o         }
5 w! T# |% y! t# [  S      else if (document.layers) {% z2 w+ Q8 g+ l7 ^; b% k0 e
         document.layers["supertext"].left = xPos + pageXOffset;1 t6 y: M1 D9 x$ }' ^
         document.layers["supertext"].top = yPos + pageYOffset;
6 y+ C$ k4 |3 `         }
' Z( f8 K* ]: K8 h/ w  `      animatetext=setTimeout('moveBall()',20);2 I: _& j! x8 ^3 H9 l0 u
      }& \4 x+ Y/ W0 g6 |
   }2 k' O/ _# C. a5 n' t

+ a* c7 V$ B4 s7 ffunction calculatePosition() {9 z& f4 `$ F! \  I) x- b' K
   if (xDir == "right") {/ v: p, {4 h- @1 l; w4 o( ^3 e) R# n8 q
      if (xPos > (xMax - contentWidth - BallSpeed)) {
: I( k/ w/ i) x0 ^         xDir = "left";
' Q! a0 Y0 T" x  a+ u2 Q$ J! p% Y         }/ O$ J$ k) W* J4 n$ |
      }* g) a# m. Z" S: r& U9 c' Y  I
   else if (xDir == "left") {
" b. X, H, ]. B      if (xPos < (0 + BallSpeed)) {5 n1 a  K6 @: ?) k, v
         xDir = "right";
1 A8 ~1 X) z2 j0 g/ m' j         }$ X' ^: O/ X7 v3 A7 x- ^
      }# f9 L: a9 n1 p0 W! z4 k# M
   if (yDir == "down") {' L7 d" n" B+ S2 a/ h- |# s, l2 I
      if (yPos > (yMax - contentHeight - BallSpeed)) {6 N, Z# \: [% e+ g
         yDir = "up";
9 @) X9 e9 j4 I9 S+ G         }" q: Q: ?  [0 s7 H
      }' ~. J# \1 `3 j
   else if (yDir == "up") {
% f8 k9 }9 k" P6 r) Q8 l/ p      if (yPos < (0 + BallSpeed)) {/ o$ H+ U" B2 Z" f
         yDir = "down";
1 e' `  W- b' B. m, _) e         }; ^5 _2 M& R" X0 m
      }
; m4 e+ b( b( u% q3 `   if (xDir == "right") {% H6 |1 N  A0 ^
      xPos = xPos + BallSpeed;. D/ J8 Z0 Q) {4 H& p! u
      }
: j+ ]3 Y/ I% }! W0 f   else if (xDir == "left") {( N: l8 Y+ w9 }3 ]; w7 q& r. w; b9 P
      xPos = xPos - BallSpeed;
- H2 d' B8 `0 E; C4 Z- g/ s      }/ i6 S: [1 @- }9 O* G9 U9 ^5 m1 u. ?
   else {9 h9 P4 ?6 ?7 g1 u+ N
      xPos = xPos;
2 O$ W; D  A0 _8 A/ c& y8 X      }. X/ T% x1 X. e" e
   if (yDir == "down") {1 W( v: ^% k3 m$ T5 T2 Z4 y0 X0 x% y
      yPos = yPos + BallSpeed;
4 e$ F: L4 E- y7 I+ E' }3 ~2 z0 b7 t      }
- ~2 D+ `; S! U7 r2 ~5 `   else if (yDir == "up") {# I& _+ ~9 b7 w+ N' s5 n3 {1 n
      yPos = yPos - BallSpeed;) m/ w" F, k' i0 v, s
      }
1 z8 d6 v+ _( G" p   else {9 j+ g5 N& U% B
      yPos = yPos;
2 Q/ `3 k" Q0 `8 w; `      }1 w4 K3 [$ P" r+ C" U
   }# ]3 x4 P0 M+ T' ]/ g' K

1 N. C' [2 z; F( p1 Hfunction hidetext(){
7 N# Q4 l( x! T8 x$ zif (document.all)& Z: O0 [* B! l
supertext.style.visibility="hidden"( a( O. g0 u8 q$ p  U# j) t
else if (document.layers)
; c- I* P+ p1 B( T% udocument.supertext.visibility="hide"% t, B5 O- ~$ R) G8 [/ d1 p  c
clearTimeout(animatetext)# j7 g8 }# ]# @2 M7 |
}# h& x* N1 V# a1 a+ e$ U% X

; @7 @! Y+ o3 J! p" f! T( ~! hif (document.all||document.layers){( {/ M. H. ?5 Z1 Q3 f
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 F1 L" J' J" o  O# x; V$ ^' j( ^
window.onload = initializeBall;" L' N. c+ |5 M# L7 |
window.onresize = new Function("window.location.reload()");
, B( s( N' s  B}, ?9 J: Y" h/ I

/ X# V/ j) R* F/ S& i</script>

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