返回列表 发帖

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

<style type="text/css">
8 J. m3 ^5 V0 U" x( F#supertext {2 G) Z5 P. o9 z, T' V: m  v
position:absolute;
8 ?; Y# K# G& j0 Y7 Bleft:0;
* m/ ]" F9 @& @$ A4 t$ ]2 [0 ntop:0;
  R: I9 r# T, N1 |visibility:hide;
/ D/ C' ~4 c) A* @2 x* \- svisibility:hidden;* F3 B( k) H0 V' w1 ]
}3 V8 Z  w! E0 ?2 l3 R
</style>& B+ @. e5 w  r6 H, a
<script language="JavaScript1.2">
6 _# M. ~2 ?/ [. F" x3 j<!-- 改变下的字体的大小。颜色-->: ^- s5 D# ^' P( L
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 _9 d) M4 P. u, p, @2 [6 k2 o
var hidetimer='';0 F4 d* x+ N3 O+ G$ M# \# [
<!-- 改变下的弹跳速度-->
9 ^# K. u, l9 M  I& gvar BallSpeed = 20;# x* I0 C  v" C4 I( v! ~, f  X
var contentWidth;
$ w% M' Z% V1 d0 W6 }& u1 Wvar contentHeight;
$ L$ y3 {6 A9 M& L  a; Dvar maxBallSpeed = 50;
# _1 q: m% C0 B, i8 e7 |6 h" K, p( ^) T; u; |& w$ k3 o! r7 ]# Z

& n& k3 J0 g* Svar xMax;' V! k, C3 @( i8 f7 E: w
var yMax;: K1 l2 V6 x% H2 @" \
var xPos = 0;2 Y$ X! A2 S, A8 n5 @6 N
var yPos = 0;# A1 e. O1 a/ c: I1 ^! f
var xDir = 'right';3 b( p5 B8 c" q+ K# `
var yDir = 'down';& x& \! L5 y2 U" i
var superballRunning = true;: ?( S8 x% @1 ]' C# G! U4 {
var tempBallSpeed;
& n1 ]8 @7 F( o# d, rvar currentBallSrc;" h3 J, y  ^5 N7 n
var newXDir;1 T/ d7 Y- c; r) p# ~
var newYDir;
; r$ e9 v, u' E; V% c( B
& T' n0 s4 ?# ^$ kfunction initializeBall() {
$ {9 ^# x. ?- v. ^1 K, A; _# J9 X( j   if (document.all) {
; e" D/ ^( Q; J# @% P      xMax = document.body.clientWidth
; |$ R$ V9 T# O- {( ^' u, Y      yMax = document.body.clientHeight
& d: M$ d0 ]% u9 m$ U5 C( G) `      document.all("supertext").style.visibility = "visible";5 K- v5 G" `4 ~* R3 \1 m* `1 N0 A( x
      contentWidth=supertext.offsetWidth7 |. B% Y, g2 P2 e* l4 ^! ]
      contentHeight=supertext.offsetHeight
1 m* y  W% ^9 G$ O      }
7 o' i2 u0 v) _' W" k# x" X9 U8 u: Y   else if (document.layers) {, [6 o2 F- x, v2 K7 G
      xMax = window.innerWidth;
" ], r; o6 I+ H6 ^# y/ A6 s      yMax = window.innerHeight;; X, T" x# e- U% ^  M
      contentWidth=document.supertext.document.width  k' F3 {4 F! Q) a2 r- X
      contentHeight=document.supertext.document.height
; c. }9 h$ r  a) n2 [' v" ?      document.layers["supertext"].visibility = "show";
7 v! o, w# ?5 b0 o      }
# P- y, Z1 S6 ?& Z( |   setTimeout('moveBall()',400);1 K- M5 S6 J( c4 P; ~5 V5 D
   if (hidetimer!='')# j  u' o# e1 A7 j$ ?! h4 Q! G
   setTimeout("hidetext()",hidetimer)" n6 _, m% f& V! p0 ^7 L- a
   }5 x7 {1 S6 |, a! p

) N+ i( r$ z" x. k; Jfunction moveBall() {/ I" C2 P; O+ G$ R/ [4 S; R
   if (superballRunning == true) {. s3 |+ f, F1 Q1 N  i  s+ _9 K
      calculatePosition();  G2 v8 X+ |6 _1 j
      if (document.all) {1 T1 j( f9 |5 c" \- Y3 }# A
         document.all("supertext").style.left = xPos + document.body.scrollLeft;! E7 X- z% P$ D3 A. t8 A9 o: E, Y0 K
         document.all("supertext").style.top = yPos + document.body.scrollTop;) J' N0 ~, q+ [3 e5 b
         }
7 `; R) }0 ~$ G* ~+ u2 x      else if (document.layers) {- }; E0 V+ g6 i* T! f" Z
         document.layers["supertext"].left = xPos + pageXOffset;
# X& ~2 E% V# B         document.layers["supertext"].top = yPos + pageYOffset;
& Q6 g8 }+ [' j9 }! q2 |         }$ u& ~/ q4 m$ P7 @; c: M% T0 T" P4 O
      animatetext=setTimeout('moveBall()',20);
. `$ b5 L5 X( C. z      }
) n3 R: D+ j( J. F, R   }
7 b% C- C$ B* x- O5 c4 @
# \# ?1 ?# }$ j' Q9 Xfunction calculatePosition() {
$ F: g- {5 ^7 N6 @' E2 }3 \& T: n   if (xDir == "right") {9 ]/ x$ @" P& g7 ]( z3 }
      if (xPos > (xMax - contentWidth - BallSpeed)) {% w" p3 D# c& j8 L1 R1 x7 I8 ~
         xDir = "left";
6 K8 @1 V2 t, p4 ?: U         }* j. G* ]+ x' q5 ?6 a$ l5 {( ?
      }+ O0 N7 ?8 d( }; i3 ?8 u
   else if (xDir == "left") {
+ W- K# z! X) P/ s. P: T      if (xPos < (0 + BallSpeed)) {+ |( u' u0 a; q: \# T
         xDir = "right";' p, |, F  \# g# z8 p) U! D
         }
) N" P2 }, X. m- W! C: D8 q      }$ v$ k* K" @" V5 p! V8 H
   if (yDir == "down") {
5 R- j' }6 Z- ?/ N      if (yPos > (yMax - contentHeight - BallSpeed)) {9 d, B0 r  N, U8 K8 z; l; t
         yDir = "up";! T( f( T( a+ X2 K7 _9 c- p
         }1 J4 z* q; V1 r
      }
+ `$ P$ A2 J8 W# }5 F/ I1 _! w   else if (yDir == "up") {
  i+ X; {$ K. L      if (yPos < (0 + BallSpeed)) {
/ b% L( N1 ]4 ~  B$ _# C) V+ Z         yDir = "down";0 U0 T) C% ]- ]; q' h  q; w
         }% m! H6 b* K* K8 P# b
      }
' M6 c+ o! j* Z- i( Y# |, S   if (xDir == "right") {
- P3 B& g2 Q: M5 I3 Z6 k. s- Y0 C      xPos = xPos + BallSpeed;
! b8 r" ~' A* G# C6 u3 N8 J+ r0 e      }+ T# ~7 j) |+ i% S  b" X' T
   else if (xDir == "left") {
/ X! _; w- u7 a& O8 u. ~      xPos = xPos - BallSpeed;* b5 t' Y8 d8 b' D
      }' G+ Q! i0 z' ~* l" u
   else {7 Q+ ^9 D$ k5 F3 _
      xPos = xPos;
( ]* f9 C6 K4 L+ `2 D* o7 j      }
, x# p/ i4 a& _: m3 |   if (yDir == "down") {
9 |% I( [' J: A. W' b$ ]; g& ^) Z- n      yPos = yPos + BallSpeed;& N9 I! I2 |* W$ I- {7 E
      }* H2 ?$ }7 [1 p* A# G
   else if (yDir == "up") {0 p! Y+ W& n- e+ X: k1 }
      yPos = yPos - BallSpeed;" b+ W. p1 x- O  u
      }
0 [, `7 S& q/ H& i& F6 P' F0 D   else {
) Q  V: T. g0 E, e+ G: d. n      yPos = yPos;
* {. p. w0 o- {% ^" R      }/ m% D- M5 C3 p/ r+ i# |( E
   }
/ ^( Y: H- H- h# Q% O7 |) l, f' ^2 S' c% d" L
function hidetext(){6 X( b# i- H, W+ Y( u3 m, Z9 z
if (document.all)
& t. q) J( k9 b, f* ]supertext.style.visibility="hidden"2 @# E$ C2 W6 G' ^6 @( B) ~* O
else if (document.layers): R5 S( Z8 V  u( t3 X8 Z
document.supertext.visibility="hide"
  @! ~' T2 u1 o2 qclearTimeout(animatetext)8 ^: Q8 L# t+ r5 H/ U7 \
}" _! V7 X7 x7 A+ c

1 O1 j* b+ V% g" T$ n+ Wif (document.all||document.layers){
) z& ]# z5 x4 e$ k7 i) ]document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
  k5 t! |9 n8 r! awindow.onload = initializeBall;. I: `% S& u& d7 K& i6 C
window.onresize = new Function("window.location.reload()");& W! k3 }: `5 [
}
6 G3 v5 |) e: ]$ ]* ]% l4 O2 t2 ?; W7 T1 }$ J1 X+ i* V
</script>

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