返回列表 发帖

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

<style type="text/css">( u/ L9 H' C  h4 O" ^$ I/ e6 \
#supertext {
9 M# T% ]5 `; [7 U/ x* [- J; K& fposition:absolute;
8 s1 Q1 ^. n' r' b' Z2 Jleft:0;
" Y% L! [, {0 m9 ~0 ^0 F3 Atop:0;* o# X/ h' ^: ~/ r
visibility:hide;
& N. D6 j' m5 P7 Mvisibility:hidden;
3 J* \; Q' B% `3 W' R* ^0 O}/ F1 w2 F! Z' g2 y( d. T& o
</style>
* y5 ]. ~  [& b* p<script language="JavaScript1.2">
7 v: v8 z, ^( ~* t. M+ x: ^" R" }0 h0 u<!-- 改变下的字体的大小。颜色-->- ?# W+ X% X& @0 Y
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 h$ y- ~3 t& _$ E  d
var hidetimer='';
6 ~( \) n' L4 E6 P0 W<!-- 改变下的弹跳速度-->
2 J2 e* i+ k" M/ U9 Fvar BallSpeed = 20;
! d; o9 [" R/ e' ], Z* _: V% Evar contentWidth;3 s1 z8 j" y" E$ j. ~
var contentHeight;
& j4 e' N7 j, Q. }, k, U4 Vvar maxBallSpeed = 50;8 n- g; r8 D/ A6 G, d- V4 j0 h
' _8 N2 T, N7 [* C( N
- g5 ]# {8 q+ M3 X
var xMax;
9 p: C  U3 S( Svar yMax;
5 U3 D; ?5 ?$ [& e' Z/ cvar xPos = 0;
* ^! f/ R, u5 k& Tvar yPos = 0;
" e9 l% G- T! y" M$ G0 d" Rvar xDir = 'right';
/ Q/ Q; j* x1 h1 H, Z3 o+ {9 pvar yDir = 'down';4 Y" P" l$ b) t" ?2 y  }. n
var superballRunning = true;5 t6 _, n* A# t! A9 t
var tempBallSpeed;
* L6 I  [9 M/ ovar currentBallSrc;
. T7 B( m5 y2 K; ]& P, G+ zvar newXDir;
# b! V! |5 e5 w0 i# p7 b9 E& kvar newYDir;
1 o+ I' K3 g) W: a3 W  q* A( C% {' R$ H' Z
function initializeBall() {
8 n6 Y: N3 V  ^   if (document.all) {' P7 m2 I( I# p
      xMax = document.body.clientWidth
$ g/ J& v  \' j( A% h3 R9 F0 ]$ q7 P      yMax = document.body.clientHeight6 ]' T4 R: h1 P, L, {
      document.all("supertext").style.visibility = "visible";
/ t# T- `8 s9 q3 a      contentWidth=supertext.offsetWidth  f+ \6 K+ ], b7 {6 p( Y0 {% p
      contentHeight=supertext.offsetHeight
4 ~4 T( S; v  G      }$ C; ^0 k) J/ w' T& F
   else if (document.layers) {: G# f& [' w, r% K
      xMax = window.innerWidth;8 M) c0 \2 }: r3 g
      yMax = window.innerHeight;
2 Y. V# Q" N  h; \% b5 q      contentWidth=document.supertext.document.width- T6 P  w$ h+ {( \5 Z
      contentHeight=document.supertext.document.height
6 d5 Z2 X% z: M. |1 g5 d0 G      document.layers["supertext"].visibility = "show";  ]$ R4 |0 k0 ~) T1 R0 g# ^* t2 b
      }
5 p9 x9 S2 X: s3 c$ v8 z% @1 m   setTimeout('moveBall()',400);
, C( b! k1 V# N   if (hidetimer!='')0 X, Q. U: P7 _4 X, V
   setTimeout("hidetext()",hidetimer)
1 D7 r4 y1 G  Z  r   }
; r2 r7 w8 e5 y9 u
% n% k# W& q' u+ [5 b" Nfunction moveBall() {
/ y8 B  J# f1 Y   if (superballRunning == true) {
4 w# P% Q) ~4 X; x      calculatePosition();2 ]  A$ ^+ N5 y! t6 O
      if (document.all) {
" a. ?8 y1 W5 }  J         document.all("supertext").style.left = xPos + document.body.scrollLeft;
* y" @5 ^. ?! i5 }6 M         document.all("supertext").style.top = yPos + document.body.scrollTop;
5 i9 o4 A% K! C, Y% R         }$ v0 l2 Y5 s- S: n: ?9 Q
      else if (document.layers) {  }8 t; Q' Q& l$ a! n
         document.layers["supertext"].left = xPos + pageXOffset;
* W( o: B+ x& c: n2 |. u7 N         document.layers["supertext"].top = yPos + pageYOffset;9 L0 v$ g9 g/ I5 H! \5 e
         }
3 E( H6 Z# K8 q* h      animatetext=setTimeout('moveBall()',20);. T0 O0 R$ t- o& n
      }2 O; L# G  S+ S! p) g( e9 e" \
   }
5 O. M6 z) i" i- z
/ y0 `6 U  w; I3 N+ zfunction calculatePosition() {! S; I; [/ O6 l+ t
   if (xDir == "right") {+ ~. ^3 X5 m+ D: L' N5 t% ~
      if (xPos > (xMax - contentWidth - BallSpeed)) {
5 t  P2 I8 z9 i: T$ O4 y! f         xDir = "left";8 N+ g+ W. x3 M, c
         }# K" T* L4 P7 U0 t7 H! v9 _. k- N
      }
4 v3 k: g3 c' ]) ]& O( _   else if (xDir == "left") {) N% H1 t, w0 |& k+ M" \9 y6 Y
      if (xPos < (0 + BallSpeed)) {
* k4 d7 \' m1 C8 a: a% s         xDir = "right";
# k" o& a9 I; f+ e" A         }
6 H2 F2 t' U% E1 A% z) I3 W6 x9 P      }) H8 g& y, h. h8 p# `
   if (yDir == "down") {" Z; E5 Y6 c! C. }+ c
      if (yPos > (yMax - contentHeight - BallSpeed)) {
7 f. G1 P1 x8 P         yDir = "up";7 ?: Q/ O8 ]8 ]
         }
2 i) J1 U) p5 ~; v& e1 g# Y      }
3 f6 k1 H- N+ j* D1 U) Z6 x   else if (yDir == "up") {" ?; k; h5 [" G7 h: \) y; N- j: m
      if (yPos < (0 + BallSpeed)) {
  n" _' j* x# k7 v5 J( F# S0 G         yDir = "down";
( ?- v. O) x/ N7 }# U+ U7 X9 c         }
# i6 B6 b/ o# ~0 Y! n& I      }, G% W7 [, h7 G/ [1 p4 R
   if (xDir == "right") {3 z0 a" [$ {' A; n5 l% I
      xPos = xPos + BallSpeed;
# n. p- I" F# u3 a5 l4 O+ u      }
& |( k( m- ]* g8 ]' ~, ^   else if (xDir == "left") {' G7 S/ H0 A5 }' e, @+ H) J8 L
      xPos = xPos - BallSpeed;- r8 Z0 D9 m; O
      }% p; p) @/ n9 C
   else {2 u- R& j* A1 P" j
      xPos = xPos;
' v- o+ e/ q2 b/ Z# z" m. L& o      }, X8 L2 M6 M  k0 _: i
   if (yDir == "down") {
) i' ]1 @# T# k, e" x: T      yPos = yPos + BallSpeed;
1 E  M& X& P2 w7 U2 v- U* o4 y      }
, S3 n: P0 j: h; W0 U  b   else if (yDir == "up") {
( [( d. U4 _/ {# z/ ?) b      yPos = yPos - BallSpeed;4 X( t: t2 r8 J; K% E* c
      }. P3 d- w3 R( O! r( K" o8 h1 k
   else {* y2 w) q+ {$ C$ x. N- H6 e% ?
      yPos = yPos;) D# l  O0 C3 ~6 m/ G; [
      }7 Z! m- S5 e" l, B9 ]( X; }$ o
   }
+ H  v8 L% }- Y" l! I# V5 I- U/ o
: f  r$ V' V- J+ P  v  ffunction hidetext(){
- k, m; E5 R; N' O6 `if (document.all)
1 v: `: s  }: f( \4 l# [! Wsupertext.style.visibility="hidden"2 v5 J+ A9 `, Y  e; M) o
else if (document.layers)
0 r: m2 R' O: Y+ Jdocument.supertext.visibility="hide"" A9 q6 f; D) \& b
clearTimeout(animatetext)6 e: @1 e. Q6 k. s6 p
}
( R5 B% b: L8 _3 A: J5 b$ A/ V  }3 m" O1 s- k! ]0 n
if (document.all||document.layers){
7 V0 A0 K7 d' O* |) z6 Hdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ a, `* j# v! @5 X! |
window.onload = initializeBall;* s0 E5 q: E: |3 g2 A+ Y) L6 N
window.onresize = new Function("window.location.reload()");8 o+ ^1 k9 o7 D: |# }# R7 m8 J
}! t) w% \( X9 Y) b0 v0 v' [

+ \1 P- A6 q5 D7 y</script>

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