返回列表 发帖

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

<style type="text/css">
5 b% g; ?& k, b/ y2 r; z2 E! \% F3 w#supertext {
& |, p( M+ }. ?2 fposition:absolute;
% c0 V0 I* w) m4 y' D! vleft:0;+ m5 x9 N+ X' s8 O) F0 w
top:0;
% c8 T; R, R6 p9 Jvisibility:hide;
: t5 B; |6 n2 ?& j4 ~$ mvisibility:hidden;
0 K5 O& C2 k) s* Y}
4 N1 U; a2 |0 p# ]/ D( Q+ q! Q</style>, n3 f& S  M. T* U4 |/ L
<script language="JavaScript1.2">
4 g* \6 ?$ a+ G- }, h( y<!-- 改变下的字体的大小。颜色--># h1 l( |% }0 c) [6 `$ V
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'( Z$ A: b- n! T; j$ i
var hidetimer='';& t6 T- W' W2 i7 A7 ?8 E7 C
<!-- 改变下的弹跳速度-->+ e9 p' M$ O( f" q; E
var BallSpeed = 20;
; Q9 m( W3 q; ?% j. A3 J# wvar contentWidth;/ y$ j4 V" l% [5 z; E
var contentHeight;6 h0 V4 z/ r) K
var maxBallSpeed = 50;
: l: c1 g% Q* e3 N# G1 F$ a( {& X# L" d2 p1 d, {" u
1 t: I& o& q8 W' w
var xMax;
- S& R2 \9 H" M3 `6 h" F2 t' y; \var yMax;
2 w- I- g) e2 G* Zvar xPos = 0;7 X, K6 l; j7 Q/ c
var yPos = 0;) Q( X( ^( N+ u1 S- d) e
var xDir = 'right';
) ~1 b/ j% q! m- Z. E' l; V, i# fvar yDir = 'down';: r7 G2 }0 ?# O/ \! q. f$ k
var superballRunning = true;: w# ?& G8 h: |3 W! ~
var tempBallSpeed;
- V% t9 v4 R- Mvar currentBallSrc;
* s8 Y8 g" o8 Q$ [9 @var newXDir;7 k" }# T, \6 d
var newYDir;: F- H7 s) k. E

6 i  p' ?  y0 A. r4 lfunction initializeBall() {* A/ Y! t5 v, ~
   if (document.all) {
! S% W* D. I0 m6 W      xMax = document.body.clientWidth3 H. B) d5 ~  Z+ H
      yMax = document.body.clientHeight
/ ?+ [, t' K& H7 Y& R      document.all("supertext").style.visibility = "visible";
9 Q4 A0 U  r4 K( L. \, ^      contentWidth=supertext.offsetWidth
% F9 h" t/ |5 e* a* `      contentHeight=supertext.offsetHeight
* Y8 j1 A6 W( V: I      }+ Q3 [6 j+ j4 @+ C4 |9 C
   else if (document.layers) {
& s, f) C$ |$ E! [! f4 g, p# A      xMax = window.innerWidth;
9 v) b* |" k# M: V& u; N8 j. o9 t      yMax = window.innerHeight;( U' F! i0 u9 g+ r
      contentWidth=document.supertext.document.width$ G5 R+ q2 F* x2 `% o
      contentHeight=document.supertext.document.height
5 a. D. f. a. R. E; W" ?" X      document.layers["supertext"].visibility = "show";
( h4 |5 N3 C7 t- v! l      }5 b' u( R3 @7 F# Y- u
   setTimeout('moveBall()',400);; @5 N0 u& I6 B5 n. }4 o
   if (hidetimer!='')
! z( u. A+ V2 U2 l   setTimeout("hidetext()",hidetimer)' K, W) r+ I- a3 w6 E
   }6 L( }" b: p8 Q% i+ D

5 r3 Y. r  j( i7 Gfunction moveBall() {
& f: R. D2 U0 n5 R9 v$ J* z   if (superballRunning == true) {
9 P* k& g1 }/ l0 ]8 F! Z6 c/ c      calculatePosition();2 M. P* P/ ^( w, D; a6 f/ K
      if (document.all) {
1 T% l7 q% I; D2 K! l         document.all("supertext").style.left = xPos + document.body.scrollLeft;- ]2 b2 N4 r. V  j0 q; @
         document.all("supertext").style.top = yPos + document.body.scrollTop;
- O7 ?9 x1 D9 W         }0 T+ k" p5 ~5 F5 [) V5 A" ?
      else if (document.layers) {+ W3 [3 a, `1 n. ~, z9 b1 C6 z0 J4 X
         document.layers["supertext"].left = xPos + pageXOffset;
* j; I$ `* o2 L8 a/ O3 j; k* B         document.layers["supertext"].top = yPos + pageYOffset;
1 B6 x) l$ {* w! I& c9 d& o         }0 A4 |7 f* S# b2 X( B  E& d
      animatetext=setTimeout('moveBall()',20);5 `/ y1 f4 R; ^  I# X" y$ _! S
      }
9 a9 ~! }% }- p/ O* _   }
  k: ]4 M- ]6 k
; o8 ]; v8 J; d' f: rfunction calculatePosition() {
% S. @  _3 {/ j8 ?# O# R   if (xDir == "right") {' g. ?0 @! [- d; |
      if (xPos > (xMax - contentWidth - BallSpeed)) {$ [3 _8 m/ g! t! M
         xDir = "left";; C4 k4 J. r! I- ?9 y
         }
" Z4 a$ v. n0 M3 y) y8 E1 U' @5 n      }) a" q( q* x' X, A
   else if (xDir == "left") {
) x6 V3 @% o5 O  A      if (xPos < (0 + BallSpeed)) {6 j1 }3 _* R6 u( ?1 e$ H% D4 o
         xDir = "right";& m9 P9 c, Q) X0 @' J' K5 I
         }5 U+ M( ~6 _! {+ K6 T7 S: n
      }
6 ?; \3 E1 Z. |9 U# B   if (yDir == "down") {; _, |* B. k0 a: K+ p3 s
      if (yPos > (yMax - contentHeight - BallSpeed)) {' _: |7 B- r+ ^7 @& Z
         yDir = "up";  q6 ^2 u  D3 }+ V( g' x9 K+ b7 _
         }. e! e, p1 H% U4 q1 X% g/ Z' j
      }0 v% T0 `; A& m& k7 r3 Z
   else if (yDir == "up") {
4 R" m/ b3 ?9 n% E, ?  P6 W0 p      if (yPos < (0 + BallSpeed)) {
7 f* I& \, o$ o4 y+ h8 K1 p  e4 z: w         yDir = "down";; R. x& h5 O- u' y' a: Q
         }2 g! u3 q8 j0 v  z+ y/ S
      }
* _& E/ _. `) P   if (xDir == "right") {9 ^6 u+ j: S# U
      xPos = xPos + BallSpeed;
! \2 f3 g1 ~2 Y5 z" B2 H& z) L      }, s0 ]! Y. @/ a& S% T+ ~  J; @
   else if (xDir == "left") {6 b" x+ L! h  |, I4 m0 M
      xPos = xPos - BallSpeed;  Z( i! R$ W" Z0 q" D7 t- @3 m
      }
: M8 W& P. b7 Y; Z! x0 z   else {" ]' s! C& \$ M9 Q0 @
      xPos = xPos;
! i6 Z0 s6 i/ _% X- J+ @      }& q  n: ?" x3 i
   if (yDir == "down") {
4 O4 x% v* x8 y$ s" E9 d' q      yPos = yPos + BallSpeed;
+ z6 X1 `8 b1 p8 d" S      }
/ C4 F3 C% i. ?9 ^& d7 {   else if (yDir == "up") {- U) o4 y0 U6 M  J" v. ]# W/ c
      yPos = yPos - BallSpeed;9 W1 g: H* K( D9 E
      }7 d' o' E) y. L; a! E5 g
   else {" r2 W) G. ]( `0 N  W
      yPos = yPos;
& L2 t  I( `# e" t      }4 h" o; S& _3 W! _- A' W+ o
   }
7 U! u( {  g6 V. U$ F. }3 R, n( B
function hidetext(){- z- L, d  L& @- a
if (document.all)
+ U1 g2 v) I, B4 ^9 }supertext.style.visibility="hidden"
( R6 F6 b& Q3 k' [! Y  Y  Lelse if (document.layers)
9 t2 O, c" J8 R7 idocument.supertext.visibility="hide"$ a$ l1 X8 e+ e6 C, L, y
clearTimeout(animatetext)
' k& K- {; e' v6 B+ p}
: W3 D$ u% G$ A. s6 \: j
, [3 l9 h& R. o6 ~if (document.all||document.layers){
: Q* W( g6 J: N. R3 U' odocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 S8 i8 I3 e/ C, j% b
window.onload = initializeBall;
- T6 L; w9 }6 @3 Swindow.onresize = new Function("window.location.reload()");
# N  V4 Q  N7 J9 c5 j}
; \3 h2 n  W  P( a: H5 S1 g  v3 o- t9 k3 T! g) {
</script>

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