返回列表 发帖

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

<style type="text/css">
% F1 W: w. a1 t0 ^" c1 S: H; Q! K#supertext {# N' i) f5 s3 a
position:absolute;
, V7 o+ ~5 l! _left:0;+ r7 o6 k1 L2 N; y! B; v# l" k
top:0;+ @6 T4 b  B7 e) ~9 R, c( R; S3 T) J
visibility:hide;
! s! i) Z( M7 C7 _visibility:hidden;
& O8 Z' O' Q) W& c( k( o- A: z: D}! b8 I; r1 K; K1 e( D$ m
</style>' X+ X# h4 k5 q9 E
<script language="JavaScript1.2">2 \+ P4 \' Y- G: I
<!-- 改变下的字体的大小。颜色-->
0 |, Z* P  U! f6 \& [( \& {$ a% |, Yvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 ^# c8 C# M" T" c$ U" H$ [! y% mvar hidetimer='';
6 J% o* _( e) `& g1 t3 K8 ]<!-- 改变下的弹跳速度-->4 k# m+ H# o! ~" Y1 J
var BallSpeed = 20;
# D9 `1 \% k4 p, A* q. W$ Xvar contentWidth;; J1 [: m( p6 w( Y. L: `; N/ F" r4 s
var contentHeight;' P- C/ b( R$ t9 c' t. f+ @
var maxBallSpeed = 50;
& N0 P" F" @, {" X$ ]: z$ y0 r8 H: e) m
" Y3 L8 ~9 a5 N  }) d) o4 N' A
var xMax;
; N* u- o* x% H3 I) Cvar yMax;
( @5 @3 y$ A" Tvar xPos = 0;% Z. s6 ]( v& y  c9 p
var yPos = 0;
- B$ N: {8 d$ S+ lvar xDir = 'right';
9 @2 M1 l9 i" ?- M  a# lvar yDir = 'down';
3 ^$ n9 F4 ]' M' O6 ^+ zvar superballRunning = true;
+ a" d5 _8 \: H1 N7 y9 l* J0 rvar tempBallSpeed;
7 x1 y8 @7 e: j5 ^* ~, Kvar currentBallSrc;7 H' ~5 w* \+ U- z5 [7 ^
var newXDir;
- B9 e9 Q" g; e" v/ xvar newYDir;
3 S5 ]+ G  D0 `* j8 z5 b
, Z" W! o" h" t% ^8 Kfunction initializeBall() {$ P2 Y1 ~# C; Z) T
   if (document.all) {
7 T( u1 Y& O2 X1 p% r  l      xMax = document.body.clientWidth6 a; a8 C, ^. y  r1 I6 a7 W0 r4 }' t0 T
      yMax = document.body.clientHeight
" [3 l7 j, T; y      document.all("supertext").style.visibility = "visible";
8 Z8 q$ h" U3 C- l) W      contentWidth=supertext.offsetWidth) M, i% L* K' ^. z) O
      contentHeight=supertext.offsetHeight0 G5 C. n) d9 [' S, \" A
      }
, v8 @, S; t& `- O5 c" p   else if (document.layers) {: o1 o+ ?; U& I5 X& [
      xMax = window.innerWidth;
5 M3 \5 [! v2 a4 t+ E      yMax = window.innerHeight;. V8 C# R0 F) a! q! [0 ?, ?; s
      contentWidth=document.supertext.document.width
% l% E* G* I) h3 T- z" h0 ^. t      contentHeight=document.supertext.document.height
  N. C( q) U& {* p      document.layers["supertext"].visibility = "show";
+ g& U& F4 q+ J) B3 R* _3 g      }. Y# x8 G9 ^3 P
   setTimeout('moveBall()',400);# B, H) i+ S1 Q: p4 P( U9 b
   if (hidetimer!='')
# c: h& i  U9 V+ Z6 o, N! n9 M   setTimeout("hidetext()",hidetimer)
( }- S5 v2 o4 q: i   }( k4 E  W) I& G' J4 h$ e( O

" ?2 n8 T/ k/ g+ E% ?! Nfunction moveBall() {
  ~9 _0 B* u# \- q1 R! q% ~) |   if (superballRunning == true) {8 e/ ]. ^+ K, @' `* N6 }6 l
      calculatePosition();/ b+ b/ }5 q, l* a9 J& m
      if (document.all) {1 z+ o1 }5 [& c8 ^; ^' u
         document.all("supertext").style.left = xPos + document.body.scrollLeft;( Y" y) |0 p4 R1 E/ N
         document.all("supertext").style.top = yPos + document.body.scrollTop;  o$ @  T- V- Y# Q( {
         }
  O/ n/ N7 y* G: _% e' q      else if (document.layers) {1 t, r3 d+ e) ^& Z8 C4 E
         document.layers["supertext"].left = xPos + pageXOffset;/ z1 }5 m+ [0 S0 K
         document.layers["supertext"].top = yPos + pageYOffset;
' ]2 ~0 M9 d# W8 J# W6 N         }
% \" l- v! u+ D      animatetext=setTimeout('moveBall()',20);, M* N! L) h" H* W+ T$ q. x9 ]
      }- n1 Y& _  s* s: w; @; P0 ~
   }' ~! ]; _6 R, X- ]' F/ X1 ^, F& `

3 ~% J' s$ S' P, ^- Bfunction calculatePosition() {* k! N* P" K6 U- l1 q( b% y3 O( ?
   if (xDir == "right") {' ~9 D# r; G2 E  v1 }' u
      if (xPos > (xMax - contentWidth - BallSpeed)) {- l# T1 L; I; A1 R5 t
         xDir = "left";5 R" k/ q7 P) Q; a* W. x
         }5 x8 m7 g. `& L
      }
0 g& W* F8 V, @# d   else if (xDir == "left") {) _& I2 w$ O  d7 e+ {. Q
      if (xPos < (0 + BallSpeed)) {
* w1 j; G1 R/ K* g         xDir = "right";" ~0 y( c& j; Z0 x- ?& v
         }
1 H2 y  G0 {: t& h& _# B# V      }
& Z0 B1 [' p1 |3 t   if (yDir == "down") {0 w  R8 g$ [1 B
      if (yPos > (yMax - contentHeight - BallSpeed)) {( H2 e' e; k; o9 s* X& e
         yDir = "up";" \2 U' i3 n% u" q$ U( `! \" I
         }
7 T8 H4 M2 R6 T  O      }
) W9 z, y" |& X  f0 B   else if (yDir == "up") {
- m' V" [4 _, n4 f; X! E- U% O      if (yPos < (0 + BallSpeed)) {. W1 ]! k5 c- O' I  A( ^
         yDir = "down";6 l/ u9 d6 N! ]; {
         }
7 g! G' a+ m/ @; S" j3 m5 c/ a* |      }
3 {% O- }  b: \' ^   if (xDir == "right") {% ~) y% T& q- x4 Z1 D
      xPos = xPos + BallSpeed;
1 z* N) W$ y' J' B; d' R5 H      }
& y) j! l% c' a4 Y- m+ C0 W   else if (xDir == "left") {& M2 ]) h; d, Z0 x8 V$ x
      xPos = xPos - BallSpeed;
" N6 H! {6 R/ E+ `5 d9 G( |      }
* O# r, r) p" m# z) _$ ~$ N/ F   else {5 X. `( m: \% x& t! [4 E5 P. _
      xPos = xPos;& u; U4 c0 u( ~: }$ z( B
      }
- o8 X1 H, O0 p, m" D  Q   if (yDir == "down") {
. k' a5 _. [: H+ y! q! z$ U      yPos = yPos + BallSpeed;7 h$ y  B; W0 T" {9 r7 b
      }# D4 m2 U  E* `" j6 u* f  W) w
   else if (yDir == "up") {
& H4 n0 L" w5 y: L8 C- s# l      yPos = yPos - BallSpeed;
: A# Q4 H4 I5 e. _$ r) t5 p      }1 S. I3 F4 Z+ E! j  u# {5 _
   else {* S) S) t+ I- D: d' y
      yPos = yPos;2 v* K% j' u2 M1 V
      }; I# ^. o( Q' u* |5 ~* @
   }
) I) u( {$ j" v9 w' Q1 S3 s; c7 [7 d  e3 d4 J+ C
function hidetext(){
! h" s4 J* `- Eif (document.all): f. T% j& O3 s5 [1 l, J5 x! Q
supertext.style.visibility="hidden"
/ I- u- }8 X# g( D: Y+ g' Oelse if (document.layers)
' g, x( v/ A. u- ~, @document.supertext.visibility="hide"
* ^6 }+ ]( G. `- I- F  A5 @/ IclearTimeout(animatetext)
' P/ F! C  m- N) g}
; T- B5 z1 z! b% [0 Y% M% N7 w0 g$ [. k  L4 S$ u7 u
if (document.all||document.layers){; k, ]" F  g; }4 d, |
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 X2 h8 k7 U/ f  o. S! t7 I, [window.onload = initializeBall;% e  H- o7 i( W" Y& b' r
window.onresize = new Function("window.location.reload()");9 ?2 S* N. W$ K
}
* V! T9 s" N( [. P& w0 A# u
& s2 J' ?4 U4 K: |7 A</script>

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