返回列表 发帖

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

<style type="text/css">+ ~' n+ d7 m" s4 b
#supertext {
7 t/ ]3 x* x4 L( S8 |position:absolute;
% O9 T0 r* a! Q- j7 p( `* _left:0;
  y( F9 s$ D& i8 Ctop:0;
2 c" R1 U, n3 [9 i9 k0 rvisibility:hide;9 o! ]  A/ m3 I9 V0 Z3 D
visibility:hidden;) V/ F; C) @6 N' X( P0 L
}4 C& z0 O/ V6 t5 j/ M* v# k* Q
</style>
7 X6 H& I. y+ q$ ^8 k<script language="JavaScript1.2">1 H* W8 k" N% o/ s' ^! q) h
<!-- 改变下的字体的大小。颜色-->
( ]% _5 \9 }4 x' jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( S. G" i: T7 ?. hvar hidetimer='';
, N% n" e0 J* |" a% a# C0 K<!-- 改变下的弹跳速度-->) o( v/ c" H6 r2 @$ Z
var BallSpeed = 20;7 w% n  e2 G. q/ c/ t
var contentWidth;
7 |! K; q2 m; \3 Pvar contentHeight;' G! R7 t; {. F
var maxBallSpeed = 50;
3 B5 k, M: [* E5 h# M$ j* L8 b  ~# d  M) Q) ]
& ?1 J3 A  p/ G) K# B: G& Y' y
var xMax;8 f0 I+ K5 u3 i7 }1 u! u
var yMax;9 d6 l; h: G8 w6 \7 k+ \+ I8 p
var xPos = 0;
1 |  h3 w+ x  j6 C" k6 k' ~+ N0 Kvar yPos = 0;1 ]$ @: t# u1 N- l- O
var xDir = 'right';
/ s( T- A( o. [$ L7 D( {var yDir = 'down';
7 E% }' e. c" [+ w* fvar superballRunning = true;/ P- @  ]  b0 Q  `, q8 ]
var tempBallSpeed;- p& [* d, Q: w0 G
var currentBallSrc;. x7 E# h3 a& U# B$ b* R: j
var newXDir;
: o: W$ E- \- F  q) ]5 P+ ]var newYDir;
7 l4 L4 Z7 H/ F/ I/ U0 i% j* h
$ P( E# X: C4 ~% x, b  g$ Jfunction initializeBall() {4 _7 c2 B* M: s' c2 d' ?
   if (document.all) {: P2 v- e& E; R6 j" p- Z6 i
      xMax = document.body.clientWidth
& v" e" \" X8 |      yMax = document.body.clientHeight! x# V' A3 M9 p1 T* s- a* A
      document.all("supertext").style.visibility = "visible";. k; Q  t# A9 X% ?2 P8 ]$ q, G
      contentWidth=supertext.offsetWidth
0 F' J* |  G2 y6 \8 H      contentHeight=supertext.offsetHeight& v6 e0 U: p/ y- s7 D+ E
      }( Z! `7 o) v2 \1 ?! G: m
   else if (document.layers) {
1 [6 \9 A' Q. K4 J& x: ]      xMax = window.innerWidth;
  W  Y! p# J+ x1 _* P+ @" m" P. q      yMax = window.innerHeight;9 n* t& d) L3 ^8 T1 ?. X
      contentWidth=document.supertext.document.width: I6 o, W5 u/ Q$ I( N5 T9 [. q
      contentHeight=document.supertext.document.height
6 B7 q% ^' ^( \- x. h, q( b      document.layers["supertext"].visibility = "show";
) ]. o& ?( K: `# ^: E      }0 R. I- f4 w- ^; T: c; `
   setTimeout('moveBall()',400);! \2 R$ u3 K8 t4 V3 y! q4 [
   if (hidetimer!='')$ ]9 U- U: ]3 ~8 c  |: a
   setTimeout("hidetext()",hidetimer)
6 q4 ]0 w. G- z4 x' z! w/ v   }$ P- f- c/ ?8 M# }
; ~2 c- V# Z. v8 s8 r0 \; Y0 f+ @
function moveBall() {
+ z6 T: l/ i  K" m+ \& {+ `   if (superballRunning == true) {
+ [; Z4 x) c  z0 @. n      calculatePosition();! Y0 O2 s) ^  m
      if (document.all) {8 V) o1 ]. v4 J# `9 P9 x4 y
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
) B% z6 B% z0 o         document.all("supertext").style.top = yPos + document.body.scrollTop;: H7 ^8 F3 j2 {$ a" Q+ N& w
         }
1 |2 w2 r6 \0 V, h/ b6 g) Q      else if (document.layers) {; [* \3 ]' |2 s& C
         document.layers["supertext"].left = xPos + pageXOffset;4 ~$ ~+ z% u9 F
         document.layers["supertext"].top = yPos + pageYOffset;4 n$ g! e" B2 A. B+ q6 T
         }
4 \: }. A5 C* k0 f$ P1 L! q' U& P      animatetext=setTimeout('moveBall()',20);  n$ ?- u2 L1 m- J
      }  u/ H% m0 N$ b: x
   }9 k: j+ ?# D8 Q# H6 d
6 Y/ o" G. G0 R# a* l( K/ g5 _! U
function calculatePosition() {/ V$ i9 _3 r  D# ~: H
   if (xDir == "right") {
% U/ C" f2 n! T( e& I      if (xPos > (xMax - contentWidth - BallSpeed)) {- K2 x1 N0 W7 u
         xDir = "left";
) c4 \0 o0 n$ @8 ]: D4 n* j         }
* e5 v- i1 G  _. z$ z* k      }
- ^- h3 p7 @- r6 [: s   else if (xDir == "left") {; @! u" }0 a$ F6 H/ M2 _
      if (xPos < (0 + BallSpeed)) {; c5 a9 m5 h5 q3 z- _8 e' @: ^
         xDir = "right";
- z& v; R& R( I         }
2 a, f+ U+ d& h8 S& k$ _5 ?      }9 y. y( |2 G3 ^
   if (yDir == "down") {( Q0 W) N1 f1 x3 M& M7 t
      if (yPos > (yMax - contentHeight - BallSpeed)) {
5 N. J! I0 ?* z. W  A2 T' F& a  h         yDir = "up";
: m8 w+ w# ^$ P+ }         }- n' O  o' G- X% v
      }+ e# h1 V; k& C8 b3 w5 I" A$ @
   else if (yDir == "up") {0 @1 D0 T6 }4 l0 X0 Z4 ^- r
      if (yPos < (0 + BallSpeed)) {( R/ d' ]; \- F2 C" |' D
         yDir = "down";
8 [" S  z' }" I         }' Y/ n! f5 M6 K2 N# p; B  F
      }
( D9 C/ E; w/ Z8 |, ]* }2 M& G   if (xDir == "right") {- E, t; s) }; v, s! \
      xPos = xPos + BallSpeed;
+ D+ ^  m/ d9 ~1 V3 I8 f/ Q( z      }
! K: c% x: Y" f2 A2 }   else if (xDir == "left") {
1 n" J, \; B; Y1 F8 f% R8 U, s      xPos = xPos - BallSpeed;
0 K, W; E8 y5 h, d) T" S      }
( v. y" D$ t! t   else {8 t5 i6 s& O# f2 m% Q
      xPos = xPos;+ l2 F, G+ q2 q- q) k& D
      }
% Z" P  Z" Q% w" ?   if (yDir == "down") {
1 s! o' h1 X' @      yPos = yPos + BallSpeed;
- X+ \. R0 A& n% ^8 y( k/ D, ~      }; a: x& h: z8 a& q1 Q: l' D+ l
   else if (yDir == "up") {6 P% d6 L- H+ J9 M$ G/ `: f
      yPos = yPos - BallSpeed;9 G1 [. O: j! F0 U) ?. ]
      }/ W% z7 e9 f9 a: V4 y, t$ C
   else {1 X& T2 l" e) N9 _0 S
      yPos = yPos;9 |" b! B3 U6 P
      }
) f8 K( E) P. F0 I0 f   }4 n# C4 w. F8 `
5 Q" n4 Y1 }* b# z2 V' w( m
function hidetext(){
; [3 y# h7 i8 sif (document.all)- a3 j0 X4 l4 L" |
supertext.style.visibility="hidden"' M. M' v4 r( n* z6 V5 a! u' k
else if (document.layers)2 I  i7 l' q! T. g
document.supertext.visibility="hide"
" J8 |; p4 B% ~% F0 x5 z$ ?0 VclearTimeout(animatetext)
3 T. J% [3 A( T' R0 T; @}/ b. h, b! Z1 R5 m$ ~
3 U/ a/ Z  N: ^, i/ Q
if (document.all||document.layers){' t) R8 T+ h) E$ I+ O% B
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 a* t+ S+ V- [+ z
window.onload = initializeBall;, r3 N7 ~! X5 g4 p9 b) |
window.onresize = new Function("window.location.reload()");) {- X. _' e" ^
}
. ~4 c% S6 W2 c& T/ ^3 Q
3 ^8 M4 a/ Q% q9 O' U, X7 x4 p</script>

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