返回列表 发帖

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

<style type="text/css">
! C; l& j% C8 L% e% ~. h#supertext {# J0 ~  \; ], O& Q3 a9 g
position:absolute;
+ u) t1 j/ f8 \  f& A4 rleft:0;( o+ [0 `, ]9 }
top:0;1 ]) M8 d: ^6 W( r7 O6 f% v
visibility:hide;
. O. _" b& K6 C$ ?9 s' T, U  [visibility:hidden;
& x" b4 k! a* B( u+ C% X* J$ J}4 ~. T* f! ~+ R7 S: b
</style>! u% o/ V: {5 c6 q
<script language="JavaScript1.2">
3 e+ F6 |; f6 o: d- z8 [0 t3 D<!-- 改变下的字体的大小。颜色-->
1 W- J- q5 u4 q! Z% r* evar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
/ |/ V8 Y  Q. _var hidetimer='';
" F. ]; G1 R7 K4 ?& B" k<!-- 改变下的弹跳速度-->) \! o& A$ c* h9 l/ E* d4 b8 ^
var BallSpeed = 20;% g: {" j) m, N7 Y! f3 ]9 ~8 L3 O# V5 j
var contentWidth;; \" ?' o; @3 ?# k# p- i
var contentHeight;& r* ?( V+ z, L, o8 v8 ^9 p1 `
var maxBallSpeed = 50;3 ]" U* N9 x- L  Q

* P1 ~% B) D! \; l. d' b9 h, c/ ]; ~+ M8 }2 t+ }2 H
var xMax;% [$ i6 h4 d4 z3 _8 {$ ]- @: h  B6 d
var yMax;
& n- n- I- y) p7 R1 a3 c& {var xPos = 0;3 D2 u# S: j; v( c5 n
var yPos = 0;3 w% X7 k) t6 s! s
var xDir = 'right';
6 T9 {* p1 n4 A: wvar yDir = 'down';( l  h2 ?& ^( u3 Z
var superballRunning = true;
# u% \' w3 V; y/ i; z! tvar tempBallSpeed;
: x7 H: s0 C8 Z: P7 }# pvar currentBallSrc;# Y, U5 z  f  t7 C2 G. H
var newXDir;
! ?6 r% O: T% x+ G( gvar newYDir;( Y& g8 }% ~2 t& C; f; Y: d

+ L6 y* h* A0 e6 Z% k' yfunction initializeBall() {" L7 r$ s" S( Q
   if (document.all) {
0 }6 i. A$ v6 P# H3 a6 n2 e" h, r) V+ u      xMax = document.body.clientWidth2 I0 I! Y5 G$ Z
      yMax = document.body.clientHeight
1 q, V& a: K+ l" m& S3 T+ b, f0 r      document.all("supertext").style.visibility = "visible";' [8 D" r- o/ q+ A0 q" Y
      contentWidth=supertext.offsetWidth
3 I0 W! g5 R' W. P      contentHeight=supertext.offsetHeight
7 |1 Q0 m) c. K. y+ A, g4 o      }4 p/ }2 s- e7 H2 C
   else if (document.layers) {8 u* O+ I1 @" M# R9 |! W" }! b
      xMax = window.innerWidth;
# X  V' W5 L9 F1 a, p  K8 B" c$ b' i      yMax = window.innerHeight;# M( @$ o) `7 Z: y0 W0 [
      contentWidth=document.supertext.document.width2 ~* s0 X9 N! X2 f% g: P3 x1 Q
      contentHeight=document.supertext.document.height
7 e! h+ [1 a% c: J- O* @" q1 {8 }      document.layers["supertext"].visibility = "show";
5 \9 c! Q' R' U, |% g& H      }+ X5 D% W2 y% i8 q4 d. l
   setTimeout('moveBall()',400);, I7 \' t! \* s
   if (hidetimer!='')/ K$ S* X0 x4 G+ r; @4 _+ b
   setTimeout("hidetext()",hidetimer)' V& k1 m, b( X9 [; a2 O* s3 X
   }
3 Q6 c8 X9 m) ]$ g" X3 N, `) h( _) Y% F; M: \+ i
function moveBall() {
6 D8 b: P  }; I   if (superballRunning == true) {& Q! f. O9 c% L
      calculatePosition();
" m. d# J1 v1 n      if (document.all) {
6 Y% y& l6 s, f. ^* [& B         document.all("supertext").style.left = xPos + document.body.scrollLeft;
) q9 G% j6 d3 F$ S) ~         document.all("supertext").style.top = yPos + document.body.scrollTop;
7 M* ^  e/ ~# N6 M* c8 s3 L* B         }
' B! I  k& m( ?/ w1 U      else if (document.layers) {
0 Y" q, v. w+ I, }$ k; |         document.layers["supertext"].left = xPos + pageXOffset;
3 N' a0 B! H4 L( v- ]" F' q, U3 V& k         document.layers["supertext"].top = yPos + pageYOffset;1 e5 t$ a" w/ X" F# Z4 \" w6 q/ s
         }% Z# ?+ O5 X3 E  y
      animatetext=setTimeout('moveBall()',20);4 v/ |9 w1 i8 I+ p( e
      }
( W2 c6 T" W% [   }2 t4 B( `7 h2 k5 ]2 {

4 `/ }3 C6 M# W$ o& O( C, U; y" r/ `) zfunction calculatePosition() {& n# h8 D# |+ U( E1 g9 j' e
   if (xDir == "right") {
/ O3 n5 k* r+ @% v/ |      if (xPos > (xMax - contentWidth - BallSpeed)) {
& u# H+ d$ g7 [2 M* e& [         xDir = "left";
* P& `- G  c" \+ S  p) S2 B7 e         }4 a2 U9 k) @5 |3 D. v" U/ c
      }2 E, }. A! r8 E( Y
   else if (xDir == "left") {5 ]2 [: [% t7 i) t7 v! U
      if (xPos < (0 + BallSpeed)) {$ N7 m# Z1 t, B) ~
         xDir = "right";
/ g8 T# t( O7 o         }2 t7 _( F5 D8 E
      }1 P- N! r5 J' Q6 u1 ?
   if (yDir == "down") {: }' E( |) ?! \# G( |" ]: z
      if (yPos > (yMax - contentHeight - BallSpeed)) {
. {8 u8 i) F4 T( p3 d         yDir = "up";6 ]( Y5 \8 T) A& Q! C" j7 ]7 V" I, X
         }
$ _+ @- ^1 u" L7 L( t: S      }7 F7 v& D' ]4 y& E
   else if (yDir == "up") {
4 y  K3 c+ r  G3 H. y. @      if (yPos < (0 + BallSpeed)) {
0 M8 B7 b' E" y/ }         yDir = "down";) ]2 b% x( u/ E2 h, ?, a
         }
! p+ H5 |/ N* O, r' ^      }' |9 a. z2 e8 X0 X: f
   if (xDir == "right") {, k5 O8 r6 p& S* l- W: A. `
      xPos = xPos + BallSpeed;
+ E) n4 t4 u% O. a' Q2 W      }
2 G1 z( N0 D; m- ?# `& a   else if (xDir == "left") {8 L' V- g. @. ]' e2 l
      xPos = xPos - BallSpeed;! C7 i6 H/ V$ f6 ]- u. B
      }
4 \' ^* |% p% s8 z   else {% u! x. o0 a# m2 C
      xPos = xPos;
. J7 t; K1 C, y( p1 H      }
# h. `" g3 q1 J, [9 X   if (yDir == "down") {0 K% C4 i7 B( Y" Q3 A! H! M- l% b
      yPos = yPos + BallSpeed;9 y) [) r6 {" \: \% C& ?
      }
9 u. b4 h8 q1 K: W   else if (yDir == "up") {2 T$ m, k( F$ J* N( d
      yPos = yPos - BallSpeed;% p+ i7 h: _9 H1 g. f
      }
! Q& b" j$ V6 v   else {& C9 ?2 ~8 \2 t" a& g/ @! u0 k
      yPos = yPos;
/ F% ^! N4 x- |( A9 p; T      }
  V4 D8 h- g+ V; w, w   }# l+ i3 G( q+ w
7 d0 s  o, e* K4 o8 j6 I0 |
function hidetext(){
$ T7 W  o9 F5 o' W' d8 N- iif (document.all)+ N( R+ j+ T1 }! k1 l" G
supertext.style.visibility="hidden". K; ^$ Z, d6 Y; P/ q+ C% N: }
else if (document.layers)7 E" p* \" M: Z) y, o, r
document.supertext.visibility="hide"! j# w8 a0 g) u' Y: ]) J% @% @
clearTimeout(animatetext)
$ x' J" F9 r' E7 w2 P}7 X' [; `" Z" ~& \1 e( {1 k
- K: V5 A- U  u; |
if (document.all||document.layers){
. P& j' X# d/ `5 P3 I0 f4 c& V. Ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 e3 ?0 t0 f; K0 _+ Y: v* b! g
window.onload = initializeBall;
  p- p8 a" w; E4 a7 r/ k2 |window.onresize = new Function("window.location.reload()");) J! z* N3 ?, J8 B, e
}
* k2 Y. s0 B( p3 l- N" D# b9 V+ z1 w8 d
</script>

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