返回列表 发帖

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

<style type="text/css">
% `6 ^& z- W- V$ X5 K2 V#supertext {1 a' d, x  k1 a# I! [( ^
position:absolute;0 S  B# {9 q# y6 X! U
left:0;' M3 a! t  c% `% M% R+ j( t7 Y
top:0;
" G, c& k* y% Evisibility:hide;
- [3 `# G! C8 }7 p% _& kvisibility:hidden;' [, B8 Q: b# M* P
}3 c6 N( Q" i/ N' B7 T
</style>
5 c& ^/ S2 @1 p( s. D" ]1 F<script language="JavaScript1.2">
; `( J5 k& L2 S6 l8 h3 I% v<!-- 改变下的字体的大小。颜色-->' u( R% S% ?) K; M. W2 l
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 p2 g0 P: F- yvar hidetimer='';
$ b! j& l/ T! c<!-- 改变下的弹跳速度-->
( u% Q' g4 ~0 y! ivar BallSpeed = 20;2 h( S* [" H$ T- G6 U, Z3 h
var contentWidth;7 R7 @  ?. Q1 T, H  ^7 Z
var contentHeight;
' \8 |- Q7 f3 }0 c' Zvar maxBallSpeed = 50;+ {5 @2 ~; @( C; N
3 S7 ~4 u( C& e5 v
, I7 n. ~7 ^3 A( P/ c$ y
var xMax;9 V7 k# `  j8 H& v" A' s7 H5 e! Q% S8 i
var yMax;
0 I! ?3 B1 r$ D) J, z; wvar xPos = 0;8 t) \. _5 S. R) D
var yPos = 0;  _" A% ^, s: u1 p
var xDir = 'right';
$ A5 C# x( b. r5 Nvar yDir = 'down';
8 W" l" X2 k) N5 Vvar superballRunning = true;
8 [2 y) w2 H+ J0 q/ H1 ?: rvar tempBallSpeed;8 [: d( ~: S' L" Q: |" H
var currentBallSrc;  m8 |0 n7 D- l5 C  N
var newXDir;6 \* P- f4 U* S, U, K. Y
var newYDir;
9 K; G1 v6 ?! t: `. v1 [! C+ |7 E: E
; c1 y, X8 B5 R: ~7 _' Ffunction initializeBall() {
, o4 j; K* i$ D$ y1 @   if (document.all) {/ z, R8 S0 H# r9 [& B+ K0 ]
      xMax = document.body.clientWidth
4 ^- v  X- I/ ^2 I4 [: W# ~      yMax = document.body.clientHeight5 ?2 b1 T; }7 z7 ?9 ]8 V
      document.all("supertext").style.visibility = "visible";! O' b. X+ w; F: ^4 D2 [; n
      contentWidth=supertext.offsetWidth
  I) D7 C9 w& l. P      contentHeight=supertext.offsetHeight2 d3 |  e0 b. m( t% G9 q2 W
      }
# }3 D) ^: i- Q# w7 L   else if (document.layers) {0 L8 V7 k) f2 c, v4 w1 q  p
      xMax = window.innerWidth;& v3 g- |9 I0 `) H
      yMax = window.innerHeight;2 T, \( ^$ h( d3 b& X' b% E  d9 x
      contentWidth=document.supertext.document.width8 u1 Y' m8 a4 Z* z" @
      contentHeight=document.supertext.document.height' U( M$ U* }+ t  B, d$ X
      document.layers["supertext"].visibility = "show";, U! d9 ]% m  [) k% ^
      }
2 m5 R9 a5 b! r' k2 @/ B   setTimeout('moveBall()',400);% v, M1 x. }% m; R8 M9 g; B
   if (hidetimer!=''), b! q5 `- H* g- d# Y
   setTimeout("hidetext()",hidetimer)
. }# `8 ?" Z2 o4 R. _1 S$ Q   }) n' A' }: p- C* ^. x1 e- {' M) n

* j# {' x% t, \function moveBall() {& y& d6 I( I! C- e+ h- X0 V
   if (superballRunning == true) {& @) ^' T3 O) }- f: H0 C7 T6 {- Z
      calculatePosition();4 ~3 g0 }3 q. [2 D' t. C/ @
      if (document.all) {; I9 U6 Z) E# Q9 u
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. _2 a5 `, C$ Q! K' C/ K5 x         document.all("supertext").style.top = yPos + document.body.scrollTop;* v6 R0 H2 B$ x# A* q
         }
6 @6 @0 v. F, c( Y# g- x      else if (document.layers) {
( Z3 m' l+ {1 y6 E& q         document.layers["supertext"].left = xPos + pageXOffset;
# E* y0 y/ U0 P5 a( z         document.layers["supertext"].top = yPos + pageYOffset;
0 g" N, K4 a5 Z" r         }
$ @; F% D: ~' r: }3 r      animatetext=setTimeout('moveBall()',20);
9 Z, S, H! j2 Y! p1 L+ ?      }
! L6 v: m/ e: i- o. k8 d1 y   }6 t$ H' i+ r) N2 M

, p) m/ d. K4 \4 f# d6 hfunction calculatePosition() {! I$ ]( q: a/ M, h4 E% J
   if (xDir == "right") {
# o0 ?. {; Z0 @& z      if (xPos > (xMax - contentWidth - BallSpeed)) {" `) f9 `8 l+ l! k  q7 T
         xDir = "left";
2 P  U7 g/ Q+ y, r7 [         }
" |& I+ G  h2 \8 ]3 b) w: h      }$ f0 {! F2 C+ _$ e
   else if (xDir == "left") {0 s- n+ ~$ {- S1 K% g7 [( Z
      if (xPos < (0 + BallSpeed)) {
# T' Y' ?& a  `( @; y         xDir = "right";
9 D* H, }4 N4 f6 ~6 c+ s8 W         }
9 V+ J0 E6 w( L# u. J! h9 y5 a      }) W3 J; N' O5 `! e' O+ e6 w  x: v
   if (yDir == "down") {
. e. W( {% P, [7 R. O; N      if (yPos > (yMax - contentHeight - BallSpeed)) {! K) N" q8 q) d
         yDir = "up";. a+ D7 a, B, J$ ?( b) C1 I% I
         }
( O; V4 W/ g, \* c      }
8 X, g1 K! j* f9 U6 s9 ]7 s# n   else if (yDir == "up") {
2 q" N: y. S8 H( @$ R  Q0 X      if (yPos < (0 + BallSpeed)) {) c' |, i: {( [/ G
         yDir = "down";7 }% D+ |  u) n+ N; v  V/ t; r
         }$ x" |, {& L; t
      }
% _+ J" D2 g% V   if (xDir == "right") {+ \7 s1 h) {/ J- u2 K6 A8 `
      xPos = xPos + BallSpeed;
$ U1 G9 C: |! N8 i      }0 z8 t# @* j; D, T/ }
   else if (xDir == "left") {
% |2 ^/ H& c' C, ^( q      xPos = xPos - BallSpeed;: B0 R; }* j9 T9 w" h0 k
      }
/ e" `* t: l& U1 ^: m   else {
9 @2 X8 l0 e) o      xPos = xPos;* [1 K, I# w1 ?/ N' j* M
      }( T# w5 }' q% o, {! r- P
   if (yDir == "down") {6 t- G7 r  p" x: D0 \1 s0 u$ @
      yPos = yPos + BallSpeed;
% e% N+ w0 |6 O$ F5 J) Q( f      }
8 j/ V' A; h# I   else if (yDir == "up") {4 K6 ^+ u5 k8 f" q$ x5 P" v0 F
      yPos = yPos - BallSpeed;
0 o  _. W+ o4 M) x$ n9 M      }
( K) R5 H" k1 W7 T, P( e   else {( H4 ~1 R" n$ t7 j* r
      yPos = yPos;
+ {" t1 c4 y3 K      }
( w3 c+ i  R( S" g' T/ r8 e   }! i( f' K) U4 m5 ~: m7 [

3 d+ Y: H9 p" H7 Rfunction hidetext(){5 y+ s- b! s/ i) \
if (document.all)  R5 K1 z- y" o3 T3 Y- ]
supertext.style.visibility="hidden"
( O. h4 i" `( U: R0 Qelse if (document.layers)3 H0 v6 T+ l  n3 m# K4 i
document.supertext.visibility="hide"
; \+ U# e; Q+ h" V, \# k$ M$ T- sclearTimeout(animatetext)
5 C0 h$ \3 h% U- c9 g) ^6 I2 [/ v8 S4 P}
+ p! h) ^- h3 c- R1 p
' ?# \2 R( {1 C9 w; Q0 P1 Rif (document.all||document.layers){. b4 k, o2 s5 A
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ l8 |  C  L2 B) k" d$ ^window.onload = initializeBall;
- b6 G1 ?; Z$ M2 M: ^window.onresize = new Function("window.location.reload()");
" K% c7 ~- I; T% k+ e5 w8 L# y}7 S. O* p9 I7 O: `" r2 G; v% I
8 s* C' C, m8 t0 K; d! T* Z
</script>

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