返回列表 发帖

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

<style type="text/css">) r: O1 M* L1 d# W
#supertext {
, \6 N! Z  R; p' Oposition:absolute;
! |# L5 {7 C: `: Jleft:0;: h: B- N7 e: w" j- v
top:0;" S! c& z2 B9 K3 U" z
visibility:hide;
) t& ]" a) f8 [5 r, t$ C% s: qvisibility:hidden;0 B  Z! Y$ v2 ^+ _! @- `
}  s# H- N! S: }$ A" M( W
</style>
/ D/ Z8 W+ Y( x% ?<script language="JavaScript1.2">4 n1 ~- p3 a- r! j/ r0 d/ m
<!-- 改变下的字体的大小。颜色-->
" q  B5 \7 T- Q- L$ l# f1 i4 a+ zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( N( L% P0 d( N9 Xvar hidetimer='';/ ~8 [0 m4 [) i2 s
<!-- 改变下的弹跳速度-->
- _1 I9 m. S3 w. g; E( Yvar BallSpeed = 20;
8 O) T) w' t$ Y5 _) pvar contentWidth;
: u5 h3 V: L& i- t% {! Wvar contentHeight;1 F; j2 Y, z- \( Y; e' G0 v
var maxBallSpeed = 50;5 `* M: x9 ]% S9 I$ p. p
6 i& Q6 [/ B% }, A1 j

2 G# J' F2 b# e7 Y, O( L, A& @var xMax;
, t: g. B1 @- S  evar yMax;% {  A; [& a0 ]" n  X5 U
var xPos = 0;2 d5 R6 @1 g4 `4 m, k5 @$ P
var yPos = 0;
& q- d  T% x2 l/ b( dvar xDir = 'right';
2 I. c2 M. P7 |0 l* Rvar yDir = 'down';( O& P$ Q9 J" N. M
var superballRunning = true;
* y- m( Q" N' h4 Rvar tempBallSpeed;6 O& f; X+ [1 W# J+ W& y; p
var currentBallSrc;
# P5 K* v  t6 N% pvar newXDir;5 F3 d( W  f8 E
var newYDir;9 j; G5 p9 a- d# _, Z! P

* ?/ [$ w8 F( X1 E+ Q5 G$ ^9 G3 c) D2 Ifunction initializeBall() {# d& L# r( @4 t& o
   if (document.all) {
- T$ t% o4 J0 U      xMax = document.body.clientWidth
5 ]" y7 C8 M) C) g6 K, {      yMax = document.body.clientHeight
. d4 v* a9 ?2 X      document.all("supertext").style.visibility = "visible";; A5 G- ?9 ?2 [
      contentWidth=supertext.offsetWidth, n8 [8 K$ C! J& a6 h
      contentHeight=supertext.offsetHeight4 D1 X6 H% s$ H, J8 V
      }
8 H  i2 D3 o2 ]   else if (document.layers) {! A& D5 ]* E0 n1 B
      xMax = window.innerWidth;
8 L) }6 j% ~6 H% q3 K5 g+ d* r      yMax = window.innerHeight;3 W1 Q4 ?' p/ }2 O( `
      contentWidth=document.supertext.document.width
2 q: b, A- U0 z- P- S      contentHeight=document.supertext.document.height
/ ~' r* H: B* Q5 o      document.layers["supertext"].visibility = "show";
" Q2 B9 T# F, ^& e& ]1 [      }/ Q7 H7 l, R" U' c/ n2 b
   setTimeout('moveBall()',400);: f0 R' Q' i4 I
   if (hidetimer!='')
$ {" h, B8 Q8 ^% ~8 W# H   setTimeout("hidetext()",hidetimer)/ v+ c! n% e. b
   }9 `: c4 F1 o2 M) I

8 b- Q! @8 A, S, M) b: yfunction moveBall() {1 Y- H$ @9 z3 J7 c* y0 N2 h
   if (superballRunning == true) {
/ L6 H- o4 a# s" g/ O" f      calculatePosition();
0 i. W) ^- F# X      if (document.all) {
6 Y6 Z# ?  Z% D# t0 w* W         document.all("supertext").style.left = xPos + document.body.scrollLeft;
  T( l: ^* P; h! R# A4 D2 g/ l& s         document.all("supertext").style.top = yPos + document.body.scrollTop;
# b! Y) f! K2 s3 V1 l$ \         }+ Q+ C; w! [" x' ~9 `0 L) I/ L6 e
      else if (document.layers) {
4 W# Q. X* f8 B) m         document.layers["supertext"].left = xPos + pageXOffset;
& Z6 o( _5 V; I5 z         document.layers["supertext"].top = yPos + pageYOffset;
/ m& M9 O( M# g0 z3 {0 q+ U' C         }
- Y0 y/ H( }) Y4 ~      animatetext=setTimeout('moveBall()',20);2 Y, S8 r) |' q  f# N
      }7 h; m. G2 M4 a$ y( _2 e
   }
3 d4 r  E. P7 F1 h' @' L0 F6 [' j7 s# P2 A' h9 z2 t' \2 V* w( u
function calculatePosition() {
4 a  b# a* N1 `) y$ w2 O0 q   if (xDir == "right") {; r6 {& V  k* @" j& Z2 h; t
      if (xPos > (xMax - contentWidth - BallSpeed)) {: Z0 B9 e+ h6 L+ Q& Z
         xDir = "left";
7 m- c" X$ }& ^         }! s% _: ]6 R3 W' S8 A! p
      }2 I+ ?; ~# A& t/ }6 ^& l
   else if (xDir == "left") {
# Q1 E4 s  ^* k$ b: Y      if (xPos < (0 + BallSpeed)) {* Q7 M, X. G. O% T
         xDir = "right";( X: V( V, p# f2 w: j
         }
# |/ l# _; g, W      }6 A) q( f* {) S; ?
   if (yDir == "down") {/ m# r: O% }/ L. g( q
      if (yPos > (yMax - contentHeight - BallSpeed)) {
9 t( }5 k( M* J* H         yDir = "up";
/ l$ r6 `# ]- H; u         }
/ K$ r  c( X7 L. }% X; ]9 R2 _/ P( _& @      }) ^3 n* q) A( Y# n# ^: K3 a. j
   else if (yDir == "up") {
' j0 j  n  _  G- a6 ~% Z0 P4 I; h      if (yPos < (0 + BallSpeed)) {( n! I0 F! e2 |# q) y% O
         yDir = "down";
9 f1 O  ^$ S* Q# e, A9 D% q% Q         }
9 C* d) A# r3 E' j      }3 c% I1 z5 |- Y: V3 k$ S/ d
   if (xDir == "right") {; D. j. u$ t% F
      xPos = xPos + BallSpeed;- B* l3 W, Y- e( ]
      }
% R* m4 {; X- }4 K5 D" ]0 w   else if (xDir == "left") {
4 l5 i2 |; s0 V# v; m+ Q3 c      xPos = xPos - BallSpeed;
( b. J% u4 I4 ]; u. Q      }; U# N7 w5 y# m+ t1 U4 R( @0 g- |. K
   else {7 P. s- Q. g1 h; H+ H! d
      xPos = xPos;* p, R; ]# J1 u4 ^) ^2 v7 C
      }+ M5 S/ t; [$ f# q
   if (yDir == "down") {
7 @# ]0 P' o: H) v2 L, o      yPos = yPos + BallSpeed;6 ^1 f, H( _8 u  b5 X: s5 R
      }" |+ x) V; k3 e: r  p( Z9 h
   else if (yDir == "up") {1 H4 k0 M3 Z' ]$ l0 i5 A% e/ j
      yPos = yPos - BallSpeed;- G) b2 ~( q& [' i
      }' |( ~8 D3 d; q' m6 s- O
   else {
- G. J& ]. V0 O  Z: }% l( B, C% }      yPos = yPos;
( v3 g1 R0 H- r$ i9 J. z7 n      }
1 c* a# L) i- z- _0 U   }
; g/ ]% A8 f2 d/ s. ^, v2 i
2 R; p4 `. w  v' T/ o' |  ]( s- z. tfunction hidetext(){
, V! w. F, s6 Q6 J  `if (document.all); A/ `+ w: w: X+ |0 G2 k9 g2 ^
supertext.style.visibility="hidden"
, e, T" i, N, U7 h! d( U) |& v$ Eelse if (document.layers). y4 @) V' E! ]( `7 M7 B
document.supertext.visibility="hide"
0 r7 f) ?+ [0 f9 bclearTimeout(animatetext)
+ u, U; H- w1 E" m. u: X}
! J; \2 v, ]; p1 n0 i: F' {
" o& w& c( z$ ?  M! Dif (document.all||document.layers){
2 G6 ?: a2 A  H4 z3 {7 d0 f$ jdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
- Q: a- l+ y4 h% ?- [6 Gwindow.onload = initializeBall;
) I9 m3 z, K, J( U+ w1 c! dwindow.onresize = new Function("window.location.reload()");
/ W2 C8 ^; `+ C* \+ _9 V6 e4 ]}
: U! J! ]5 s+ p0 @% c* G' h, a  v9 ?; Y4 u* P
</script>

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