返回列表 发帖

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

<style type="text/css">
7 C+ W  X3 n" y3 P#supertext {2 g9 a3 v% s8 ]  }& \
position:absolute;
5 t+ ^/ P/ _# o, J, s% [left:0;
: k! G* f( u* k; s( A+ Atop:0;1 k' \* Z2 m: S
visibility:hide;7 y5 [/ }' N. H0 E! ~, b! X( A
visibility:hidden;
! @" V! @* j% }' {* `5 p}
, h5 Z1 y# _6 ?/ j% m6 M</style>
) F1 ]1 J, Q; K6 F8 B% T<script language="JavaScript1.2">
$ V. v4 l( b0 {6 r<!-- 改变下的字体的大小。颜色-->  W( a# T9 d5 I- |
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
3 `! {+ N  u" J( J1 ?; }1 Vvar hidetimer='';4 W7 w. p6 i$ Y' X
<!-- 改变下的弹跳速度-->
5 q) q: z9 U  d. M- R9 pvar BallSpeed = 20;$ c) j: c: q4 Z; W
var contentWidth;# H1 {- U- Z; ?) X
var contentHeight;( x% R/ q) J; ^1 w# F
var maxBallSpeed = 50;
, N8 r' b  }6 v7 N8 v
+ R; \; v% \1 l! {# ~6 L7 s0 N8 s* t
var xMax;" Q. Q  M5 v% F' ^( R" p: j
var yMax;
# T% r, t4 w4 H3 x7 Avar xPos = 0;  R. F4 o7 {# \
var yPos = 0;
# s" [% t6 B( g+ A* g  u7 p; F9 pvar xDir = 'right';- n3 r6 _$ w3 D4 I& ]
var yDir = 'down';& G6 d5 U8 [5 z
var superballRunning = true;
0 E1 {1 N' t5 O0 F; \4 C. cvar tempBallSpeed;
$ S. W  |2 @, A1 g, s9 xvar currentBallSrc;* ], t! N' O& `& I
var newXDir;4 ^9 g) w( B; N+ E5 m# P" f9 H
var newYDir;0 s$ {2 i: `6 x# W

" a/ R, J% y$ \6 L* w7 w4 A/ Mfunction initializeBall() {& \3 a. k! c" P8 ?
   if (document.all) {
2 j5 K/ k$ m. F% [" l8 U) p      xMax = document.body.clientWidth" n  M/ k: k6 f/ V( o
      yMax = document.body.clientHeight) G1 |3 P9 B! C! [5 _$ t
      document.all("supertext").style.visibility = "visible";% C8 b) f) y, D3 v: F
      contentWidth=supertext.offsetWidth
: C5 P- r9 ?/ f7 l+ E1 G      contentHeight=supertext.offsetHeight
5 b! _! X8 }8 W! a      }
, f& P! z: S- H   else if (document.layers) {
* H4 _3 M& h, ^/ a! Q' {* j8 D8 z5 m      xMax = window.innerWidth;
4 F" ?! O4 b% w8 `; g      yMax = window.innerHeight;  P4 `2 x3 @% P, |% ^3 U2 x) j
      contentWidth=document.supertext.document.width
5 B& w! ]4 r6 l      contentHeight=document.supertext.document.height
) _5 j# c  S. \( s5 t      document.layers["supertext"].visibility = "show";
# z) V& Y8 ^4 V2 ]& [" c" i$ a      }
+ w8 L& N/ f% f+ S* S   setTimeout('moveBall()',400);
- ]1 v% s2 H0 C, ^   if (hidetimer!='')
5 J- }+ _$ _$ I  `8 ^( y$ E9 x   setTimeout("hidetext()",hidetimer)
/ T- O2 Q  D( n   }' V1 |" C9 F( A8 |$ n  Z1 [
: ~- E, {" c1 n2 X
function moveBall() {
+ I( q/ \1 N- U3 F   if (superballRunning == true) {# ?" Y, @& ?7 H1 [: O; D
      calculatePosition();
! z# P5 j& }) @  y9 F      if (document.all) {
' P2 Q; {$ M  H, e* o6 u9 E         document.all("supertext").style.left = xPos + document.body.scrollLeft;
- g% X5 H2 T8 z- H6 c1 z) R) k2 F8 E         document.all("supertext").style.top = yPos + document.body.scrollTop;
3 G3 y/ L4 _. r* M% f8 h+ n2 L& R         }+ t( @/ N1 d: N3 g: \/ C
      else if (document.layers) {
  g3 S: K6 s% [  S; P5 l         document.layers["supertext"].left = xPos + pageXOffset;
6 I7 m2 g6 G! h% v% a& ~         document.layers["supertext"].top = yPos + pageYOffset;. @8 I2 U% \2 n2 ^5 P- g0 o, C$ h
         }
: @; b- g3 l5 [      animatetext=setTimeout('moveBall()',20);
3 t( _8 {9 ~% j      }7 q* |/ y5 p8 M& x5 X
   }0 M# B( L' z) B% D9 j& X" |8 T

/ H3 D. {$ `0 ?( e9 T; o+ r+ ~function calculatePosition() {
: S+ h) `9 {4 `+ R- M1 Q   if (xDir == "right") {
4 @8 b& Y4 u) v  ^% C8 {1 y" a$ E      if (xPos > (xMax - contentWidth - BallSpeed)) {
. T3 k# V7 h  y+ L         xDir = "left";2 |$ j! g# j; W) p% c' k. ~, t( [
         }! T' _0 \: b6 T7 T5 Q
      }" |! |. [% \0 n; y6 b) }7 V
   else if (xDir == "left") {8 |- Y8 X2 L6 v7 \! j7 o2 x! F
      if (xPos < (0 + BallSpeed)) {
; r. |) m* y  j         xDir = "right";6 `/ X6 f! J6 ^2 P
         }
1 a* ]4 e! k1 W' A3 h      }5 i' }1 C1 w: L
   if (yDir == "down") {/ ^6 l1 b7 ~# E$ h% b6 D' n
      if (yPos > (yMax - contentHeight - BallSpeed)) {' |+ C/ J) o9 M& V/ P- }/ c
         yDir = "up";
( {0 Q& u" V; ~4 Q5 g; A         }5 B8 r. w4 N+ T
      }- D+ |6 r) K( R1 d, W9 R
   else if (yDir == "up") {
9 x# `5 r8 v- {. n' j2 h' s% y      if (yPos < (0 + BallSpeed)) {0 {6 |4 t2 X; f% K
         yDir = "down";
9 x. j) U& W5 v9 G! C         }! r- \$ _" S) e( [: _7 x1 U/ k
      }
5 `3 H- h6 |+ p; A* F2 L   if (xDir == "right") {
. z( z, L2 P  f+ M- N      xPos = xPos + BallSpeed;( y# w/ ^  ~  X2 b! N4 X
      }  h* \% {! c% c) R  E6 |) q' |6 m
   else if (xDir == "left") {
" L' o# {  V" {5 R      xPos = xPos - BallSpeed;
* _' w3 M: u" v: x( z% S      }5 F: R' v; E' q& d0 q! j7 b& N
   else {0 q, W# {; Y5 Y; c
      xPos = xPos;9 E9 L7 b! O- Z( r! ]0 v$ x3 y
      }
3 |/ X' ~6 Q' Z2 l( P7 L   if (yDir == "down") {9 i9 u5 c; n8 A
      yPos = yPos + BallSpeed;
+ }) ?. Y% Z2 ?3 R( G8 r& p9 _      }- u  H5 E2 V* L
   else if (yDir == "up") {2 S8 u. X  J& `( Z" h0 J
      yPos = yPos - BallSpeed;
8 M: R8 e  Z( \& P  _- j+ i. p' n      }
3 k9 C9 o  N, E: r% v   else {
8 H  L2 f; i0 v      yPos = yPos;
2 J9 J" K5 \5 W1 F9 i' C      }
2 A% y) F$ e( l2 Z% t' ~" p   }8 f. A3 G+ E) j$ k9 P+ q
, _( k1 z  g2 J  E% h, N: u
function hidetext(){; t% e1 Y4 }/ m8 }* _
if (document.all)8 C0 b( O9 n, v* k0 ?
supertext.style.visibility="hidden", V, r) C" E, R) e& [) Z& I! |( k  b( ^
else if (document.layers)6 ?8 |+ ?% h# A4 p0 G8 p! T3 k) i& S4 f
document.supertext.visibility="hide"' d9 _, H0 F* s" H. _
clearTimeout(animatetext)
- _5 U; u  c$ ?; x9 t  v- u$ w}
& {1 ^# k9 w& _; Q, R; b. W: o7 [6 t. G
if (document.all||document.layers){
" q4 G" U+ X& B" e" D" |document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')6 e! Y  v+ ?( g- f) V( g+ I
window.onload = initializeBall;5 g4 n& i  Y0 O( T0 h" ~$ @3 L" r" B
window.onresize = new Function("window.location.reload()");9 c- n8 A1 a  d# Z6 B4 k
}
& I+ D4 I1 u& K; y) v1 b2 h/ k. S( f$ D
</script>

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