返回列表 发帖

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

<style type="text/css">& G) _; y0 i1 k
#supertext {) g1 ~2 h. S3 s; j+ b0 Q
position:absolute;9 o( N; ]: v- j% P) Y* g
left:0;
1 |3 n+ y9 @6 f' G! ?* Atop:0;5 d3 _. k, r% G" D  Y& z: M
visibility:hide;
" A0 N7 j" b6 T9 hvisibility:hidden;
6 B2 c1 m) G8 P! Y" y}" |2 p: a; s! Z5 x# t# }) a
</style>
' e5 u& ]) Y  }+ \" d& ^<script language="JavaScript1.2">5 I, e( Z" p6 @: j3 D
<!-- 改变下的字体的大小。颜色-->
! [2 _. b, h+ Pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" G( Y/ c" Q! p1 svar hidetimer='';, T& i4 D0 Z8 s3 H& e
<!-- 改变下的弹跳速度-->' B5 U) ?- G, f% j& D+ ^$ J
var BallSpeed = 20;
7 b; e! R: z& g0 Uvar contentWidth;9 f7 w7 ?/ c* o9 \5 \' i0 ?0 g) Q: f2 \
var contentHeight;
5 O7 G9 N& d. ~0 M: d1 K1 Bvar maxBallSpeed = 50;
6 S( h: `  Z- ?( |' F5 H; J/ a) N! p

% t& |( T! q5 _# Nvar xMax;
5 N' L$ K+ N% q2 U1 hvar yMax;" k! P; H! u, w+ a
var xPos = 0;! p) E6 S2 k) j0 U( V
var yPos = 0;2 U) W, `# S- p. C) S4 L
var xDir = 'right';
. z" e5 s& v! B' j* Q1 F+ _var yDir = 'down';3 I. [2 x9 J; u8 ~6 ~. A# U8 l
var superballRunning = true;
: }) d. `: o) s; [3 z% }+ P' Vvar tempBallSpeed;$ J! x& P) L: e8 N
var currentBallSrc;
: m/ Z6 a$ D' D4 |* Dvar newXDir;
# C/ a6 l2 m4 F2 }; u% xvar newYDir;
7 E: X; F" k: ]5 y0 H4 r( o' M
% U9 N3 l/ a7 P' U  L$ tfunction initializeBall() {
& m- }+ a- s0 I6 X5 ~   if (document.all) {
" @( q7 M: L; [+ T, R      xMax = document.body.clientWidth
$ Y( T$ D# \* c% z      yMax = document.body.clientHeight0 _1 {% |( F) P% J
      document.all("supertext").style.visibility = "visible";4 X: I  z9 Q. d# j" x
      contentWidth=supertext.offsetWidth
+ o6 T4 O5 ^+ F/ y2 |: r+ T      contentHeight=supertext.offsetHeight
& j! y- h: F: L2 g5 e3 x      }
# I8 K; q) {+ O+ F   else if (document.layers) {" v" t4 z) o4 X3 P' T5 f
      xMax = window.innerWidth;
# `' C1 }2 m6 ?2 f: f1 S1 H; y* v2 o      yMax = window.innerHeight;
- ~* i: }- ^% N# k% q. D5 y      contentWidth=document.supertext.document.width
6 ^: Q. w. v' I  O1 |  Z" v2 O5 \      contentHeight=document.supertext.document.height
4 W2 _; E5 b/ }# R$ c  R      document.layers["supertext"].visibility = "show";
0 @4 j8 c: q" l) ]% h* _5 P      }$ y6 h: i1 D4 S7 M( a% S5 y
   setTimeout('moveBall()',400);
# ?! V9 L$ D5 \8 m, u8 t3 T   if (hidetimer!='')
9 [1 G. A) j  L+ x0 t( L$ N   setTimeout("hidetext()",hidetimer)
9 z2 n% s0 X6 |( q# z   }
( b2 P0 Q" Y( w0 _9 [- ]8 J
/ G1 a% u2 H, b7 v( Efunction moveBall() {
* y6 o5 ?! F" Z2 k1 n/ P; g1 W: X   if (superballRunning == true) {
& s. k6 O. q2 q2 l      calculatePosition();
" }' T9 g) p; U+ r/ w; Z" R      if (document.all) {
. O; ~8 L  H& h! D         document.all("supertext").style.left = xPos + document.body.scrollLeft;: Z' f+ P7 _1 n5 \$ i
         document.all("supertext").style.top = yPos + document.body.scrollTop;
* X0 k, s- c9 E: L         }2 z" q4 h0 m8 r
      else if (document.layers) {; S, C+ g/ J# d' W$ H
         document.layers["supertext"].left = xPos + pageXOffset;" S- `4 K* N. w' m
         document.layers["supertext"].top = yPos + pageYOffset;
: P" x8 o' {2 o- m. k         }4 _. N- C! K( n1 ]$ T: v6 H7 f
      animatetext=setTimeout('moveBall()',20);' P& l$ q! X; e0 {, U0 h
      }, d$ E! [1 ^1 `, C7 x- G
   }
9 v% e0 X# l% \& q7 h4 z5 ]! h- S: g+ @
function calculatePosition() {
7 V$ Z7 V1 E1 s" q& u1 U5 N   if (xDir == "right") {( _3 K$ ^/ i- W/ `; k1 R
      if (xPos > (xMax - contentWidth - BallSpeed)) {0 e+ C0 S/ i/ U% O) y! t" v5 I/ y
         xDir = "left";
/ R" `  @8 v! o+ z- R* I         }
; m% t. F. R6 p4 L" B      }1 V. Z2 n8 j: n3 T
   else if (xDir == "left") {( Z* N1 G' q9 d' F: l
      if (xPos < (0 + BallSpeed)) {
- d  k0 J# T& G8 A4 l         xDir = "right";* x% I# Z; N- N# E
         }3 ?0 f$ l; f9 y( Q* ?: z4 p
      }. }( Z, |2 U0 T# s5 z/ e
   if (yDir == "down") {9 v) x+ [- a0 n6 U: l1 t
      if (yPos > (yMax - contentHeight - BallSpeed)) {
; I* r, v0 D6 p7 A         yDir = "up";/ X$ p) h" l( l
         }
7 r0 ?( v# \  W1 t1 |7 Z4 N) z      }
8 _- q8 Y: b, D   else if (yDir == "up") {
8 A" H+ j3 X+ i/ x+ `      if (yPos < (0 + BallSpeed)) {
6 I) {- U; V  U         yDir = "down";' w) G. T. b& l9 z7 |
         }
* A) {9 [% x" `" p      }
  E# g- k/ b3 Q7 t   if (xDir == "right") {. l5 A% K( h/ k7 |
      xPos = xPos + BallSpeed;7 w; |2 H+ G1 X5 |* D/ R
      }1 c6 b4 X( N; V0 K
   else if (xDir == "left") {; f8 t  b0 ~( q6 G
      xPos = xPos - BallSpeed;+ u/ n! h/ l2 ?& F
      }/ ^% N# W- e$ |; k. U3 Y6 w
   else {9 n6 Z) [! b; e8 e2 q( u# B+ x( [
      xPos = xPos;
6 z% K, e' G% i1 L  I9 F      }
  i/ |1 F, e/ n2 _   if (yDir == "down") {! w" b+ I3 _$ _
      yPos = yPos + BallSpeed;
3 E; l3 [1 u4 V8 k( k      }9 h6 f. a9 ~. {, @( z
   else if (yDir == "up") {7 D1 `) i4 a0 T1 ]/ T- y8 f
      yPos = yPos - BallSpeed;
" t% B. w. p3 ~. K      }2 ~0 Y& \2 S2 K/ ?* W$ E
   else {* r. N6 @- _7 [
      yPos = yPos;! R. h9 k4 b$ l5 `% E9 h2 h
      }; K# |2 U9 N  h6 o" [7 G1 O$ P  U6 g
   }, O. ~4 |5 ?* v! d3 L
( D7 B0 D  |7 t2 U, F5 Q
function hidetext(){! p. A5 u6 n* _  }$ e$ q! q
if (document.all)' h( [% ^" p9 f  U/ k3 \6 Q
supertext.style.visibility="hidden"! Y+ M+ ]) g# F, v6 c* Y$ T+ F/ g
else if (document.layers)7 |8 K4 S* I; T  l/ B; K7 E; Q
document.supertext.visibility="hide"6 }& C* L( _% t7 n, Q
clearTimeout(animatetext)) t  q# X1 i8 J: U- a9 X
}. ^8 ]! J" g& E# r) K, R
. m6 e: I; i2 X7 G
if (document.all||document.layers){
# E/ ^/ R3 }7 b  G2 \5 H* ?document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% ]' r1 C: q4 K* B+ zwindow.onload = initializeBall;
  c8 E6 T& ^0 K+ V/ ^5 [, {! Y! }9 kwindow.onresize = new Function("window.location.reload()");6 Y  A- v7 j! M  T: j9 G: g
}0 @; t1 X2 \' S+ d6 f
( i6 [$ T! g' ^" G
</script>

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