返回列表 发帖

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

<style type="text/css">$ O$ W( a$ }( k( U1 C! b
#supertext {) z$ D4 j* B5 s2 E4 W( q. U
position:absolute;
) X- |  B# g/ _# s0 G5 g" pleft:0;% {( E( D. E: `. }! \
top:0;
# e, f, K7 n9 S4 d; r3 L; Tvisibility:hide;6 ~6 O: u! F: F9 V5 _
visibility:hidden;
& j# G1 e+ ^1 w$ r3 @3 D}3 K7 I: u# R- `
</style>2 _2 r5 i/ y& A  y
<script language="JavaScript1.2">" d2 ~4 @- N; s# F
<!-- 改变下的字体的大小。颜色-->& O9 c" d9 ?) p0 S/ g
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) E( e2 @' V: Q$ [4 o. q/ dvar hidetimer='';
, A7 b/ h1 h0 K! V<!-- 改变下的弹跳速度-->
1 T9 r: R* E- ^- Q& lvar BallSpeed = 20;
1 X0 T8 S- a' h4 |" R# n4 N" Zvar contentWidth;+ H8 v0 w' Y# e+ c7 o  \/ o
var contentHeight;
0 L: g% D! ~: Tvar maxBallSpeed = 50;
) s$ _3 F& v% D$ T
$ U" J" w: p& p" h! R$ f  k1 v, [% e
var xMax;$ k5 r/ i% e' K. a* n* e. V5 i
var yMax;
7 h$ `* V6 G  ^( Y" rvar xPos = 0;
) q8 Z5 A# \" Mvar yPos = 0;
8 v! q* c& L! O& [2 Zvar xDir = 'right';! D- c( @6 I0 \$ g) M
var yDir = 'down';* S. E  _3 o, p7 n
var superballRunning = true;- {8 h# c# |  V- m; {4 d
var tempBallSpeed;
0 t& G% ]: W. {3 gvar currentBallSrc;
- W8 @; @. o/ r& H& M1 Pvar newXDir;
/ `5 {% t. _' X' J$ C0 mvar newYDir;
, k5 y- f- T7 |. Z
3 n% J/ q- b' J" C9 `, Q" V0 ~% mfunction initializeBall() {
4 R" B# ?, [' N: G: q0 V. f   if (document.all) {9 K% a; M4 X' b) l& z7 n1 Z# C
      xMax = document.body.clientWidth
+ l$ a8 A. Q6 @      yMax = document.body.clientHeight( M$ m% k0 t# T' Y8 I/ P7 P* X# P6 @4 G. h
      document.all("supertext").style.visibility = "visible";$ L" t8 L( p: M/ L* w2 `
      contentWidth=supertext.offsetWidth
1 b% q" x( Q# E. t# P/ s6 t( l+ o      contentHeight=supertext.offsetHeight! Z8 L6 C  H7 x, g8 @: Q- Z
      }
  z) x1 {. n9 |0 R0 J: \, P; A   else if (document.layers) {" i, z; x3 i# C9 B$ E" Q1 ~
      xMax = window.innerWidth;
3 B$ p' N5 |/ m      yMax = window.innerHeight;' K" t2 A3 @: k6 Z8 Z& M9 C
      contentWidth=document.supertext.document.width
  N( K9 G1 @! F6 g! a6 @3 r      contentHeight=document.supertext.document.height
* {. V# T0 M) K) k5 _1 K      document.layers["supertext"].visibility = "show";
# z. `' v9 h0 o6 {2 M" H      }
8 h3 N3 d- U' r5 r   setTimeout('moveBall()',400);* K) N# X6 j) h3 P
   if (hidetimer!='')
  R! i3 \* N# L# j; k# g/ G) \   setTimeout("hidetext()",hidetimer)5 G* n7 f$ H( \) Y
   }* F8 a: [2 s* B2 Z

1 |0 l5 n  M5 Efunction moveBall() {( k) p1 Q# J: C, F$ z' J
   if (superballRunning == true) {6 q* j9 |, l( p2 `  |2 v
      calculatePosition();
. w: m& _" H6 v, g      if (document.all) {" [' T( @8 v, H5 w' y9 V. L
         document.all("supertext").style.left = xPos + document.body.scrollLeft;& p, `9 z5 k, @: d& p9 q
         document.all("supertext").style.top = yPos + document.body.scrollTop;: M3 Z5 Q6 k" ?2 Q6 E
         }
* F1 P* x2 Y: F" T/ c      else if (document.layers) {: H0 ?' b, P; v* E7 u( R' [
         document.layers["supertext"].left = xPos + pageXOffset;% b5 x* a* X* l. {
         document.layers["supertext"].top = yPos + pageYOffset;
0 `( k9 a+ B9 }; Z  E# l         }
& ^6 D* E1 @% I' z      animatetext=setTimeout('moveBall()',20);
/ ~3 @- d  T, l' c( G) F3 d* \      }" o/ K+ {( Q0 \- q1 X& N
   }7 K; b( @7 A% h/ ?% [# f7 E! b, w

$ E1 s! j# u& q  U8 t- [$ c& Ufunction calculatePosition() {) M: P* T( ^7 }" L2 ?
   if (xDir == "right") {
; Z+ t4 }. @# n) Q& J      if (xPos > (xMax - contentWidth - BallSpeed)) {
$ q3 b! X! R7 k! \4 S. h         xDir = "left";
! S, S0 |) P8 e' r         }1 _, E& Z/ e( l* Y! P  O. @
      }
4 F) p! X" ^1 C2 {5 O' b! m   else if (xDir == "left") {2 ?# r5 V$ \( }( c3 K/ k" q, R; J% D
      if (xPos < (0 + BallSpeed)) {( P1 |- F( e  ?( L
         xDir = "right";
6 r3 J# l7 F% z4 K. [         }) E! E' M# E+ ~) T
      }
8 z1 P/ C6 ]' h# o9 r. }   if (yDir == "down") {
. t1 `! M/ U2 t/ p8 b      if (yPos > (yMax - contentHeight - BallSpeed)) {  z$ ]* @; q! _0 p4 `
         yDir = "up";3 w  L# E: S& y/ g4 Z0 ^
         }4 i. q& c- K$ Z2 O. ]1 T1 G
      }
. g9 [! L6 K* e/ o   else if (yDir == "up") {
4 G  V. U1 G9 }, ]& [( X. W0 d& }! E      if (yPos < (0 + BallSpeed)) {: n8 N5 m2 D2 i" \
         yDir = "down";7 m6 m% F. D6 m+ K& e
         }
; S* |& i+ B2 W4 b      }7 b4 N% R0 Q3 A5 i1 t* c
   if (xDir == "right") {; C7 D1 F; ^+ L7 h
      xPos = xPos + BallSpeed;, f/ w! ?* M0 B7 C4 ]
      }8 x  z! ]0 `! t: N" ^
   else if (xDir == "left") {
6 d  M* }9 z  P- Z$ U) n( ?- ?      xPos = xPos - BallSpeed;
( b& Z0 z# A  h' O0 y      }
0 {' m0 m! l0 p/ d) w   else {6 V5 T4 R* p% }$ N5 O
      xPos = xPos;! N' I1 F( V2 Q5 E3 b9 R' z. w
      }
. s7 y6 T/ X' W" i& u( y8 ]5 i* J   if (yDir == "down") {0 a+ M  d$ }5 E' b4 o0 [
      yPos = yPos + BallSpeed;% h+ M! ?0 F/ t+ r
      }
6 j- \) u; A$ z   else if (yDir == "up") {
4 l6 i+ e0 h2 \      yPos = yPos - BallSpeed;
" ]6 w- h* [, S' B      }
' |0 G7 V  f3 x7 x! A   else {3 d2 m( i) B( o1 e3 x/ \+ Z
      yPos = yPos;
0 S$ x& f" P" C0 d; H7 L      }
% K; G/ ]9 \( d9 c8 L   }" q) c0 \5 `$ t' B: |8 P

& U3 Y) Y- e6 qfunction hidetext(){6 c, Y+ w  f, p2 F2 y
if (document.all)
# U9 z7 P& _, h5 Tsupertext.style.visibility="hidden"
$ t0 {: s) j! J3 |+ xelse if (document.layers)
, I9 `6 o9 y+ f7 Ydocument.supertext.visibility="hide"
5 o) ~3 k* d  o1 c3 `% w* x# NclearTimeout(animatetext)
. S* v& h$ x7 c; ]% B' t}: y6 l2 g0 d4 m5 d! E$ E; j
8 H/ b/ z; f7 @# X) S! N
if (document.all||document.layers){. }; d$ |1 b6 r  b" ?- y' y5 k; _7 U
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
, [; B3 x( ~: _5 E. _& twindow.onload = initializeBall;7 z) y' G* P  S) k, ?
window.onresize = new Function("window.location.reload()");
  W% _1 ~% D+ j  c- K}
: K: f- ]2 |4 l' `, m. Z* M2 p5 y) x: q
</script>

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