返回列表 发帖

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

<style type="text/css">; i; x, L; E+ q$ o7 f1 C/ d3 t- L
#supertext {9 z; y0 y; e2 y* A( T0 W- Y
position:absolute;: T) f3 M6 @9 ]- j8 S; o9 x! O
left:0;
9 L: q: g% r6 [$ t( r3 R# h* atop:0;
7 L% _4 I: y3 jvisibility:hide;
" S$ }5 f0 U. F4 d5 O& r1 G& j) f6 Bvisibility:hidden;
0 R6 O& [3 F- n! |) f}
" h, r9 x, S6 r1 T</style>0 Y$ ^. q% X# |" x& ^8 Y7 _
<script language="JavaScript1.2">
6 q# F4 @5 R2 M4 I8 b# @<!-- 改变下的字体的大小。颜色-->; F2 Z' P; N9 |4 f
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 v% ^9 G7 b/ m# T( _) h1 I/ r
var hidetimer='';9 d4 h, q$ V% n, \1 l& }
<!-- 改变下的弹跳速度-->( C' x7 s0 Z, p& r7 ?& p
var BallSpeed = 20;1 j, r- Q* I- l: h
var contentWidth;" C" N7 Z( A. T, w+ U" f2 U& ?: |
var contentHeight;
! p0 R$ z+ E1 m( j7 ~1 rvar maxBallSpeed = 50;
5 H. x2 A# ]! g) p! a2 M5 D, }. {/ T1 ?0 R. L& X: i; h

  I  a; E1 [3 n6 z4 p! i. Yvar xMax;5 [1 A7 S- m0 @8 Y* t9 U
var yMax;
+ t) I$ b2 [& I+ g, |2 n2 Kvar xPos = 0;7 m0 d) @, M4 G3 G# K0 j. b+ [8 B
var yPos = 0;
# N! v) F+ m' xvar xDir = 'right';
0 F( X$ G- r; @" K" Yvar yDir = 'down';0 ]3 J! M' L8 ?
var superballRunning = true;
, l! Y8 V  N7 G7 fvar tempBallSpeed;
+ R# e: {/ x$ D5 nvar currentBallSrc;; M. l% ^4 g3 [$ u
var newXDir;
2 l' H, t2 y5 k# \var newYDir;
/ L! m9 j! b8 v! D: f/ @! R! r" L+ }! X4 C* w: _
function initializeBall() {
: S5 k$ U$ ]0 }6 X- Q( ]$ L* F+ X   if (document.all) {
* v- @# [: h3 ~( a! P      xMax = document.body.clientWidth
% W5 J3 y! H2 w$ u& A. `7 E      yMax = document.body.clientHeight! C% t1 `! u5 e8 _! P: s
      document.all("supertext").style.visibility = "visible";* @& N* }: k# V. U+ o; `  V
      contentWidth=supertext.offsetWidth/ E- [) Z0 B8 O6 D" K; E
      contentHeight=supertext.offsetHeight4 N- u' C4 p8 D; L5 J' y* U: Z
      }
2 e7 `& U4 C, k' u. \   else if (document.layers) {, z+ `+ \' d2 T  U
      xMax = window.innerWidth;) z' ?' j$ O9 |4 D& j
      yMax = window.innerHeight;4 u1 @5 U( I+ v. \3 @, u3 ^
      contentWidth=document.supertext.document.width
* J- s: [- ]) c, \      contentHeight=document.supertext.document.height
1 Q+ M( J1 H7 G      document.layers["supertext"].visibility = "show";
; S! M  [4 t0 I( {      }
! Q5 m' z* x: n& D7 G9 {* n( ]   setTimeout('moveBall()',400);
1 G' V4 x: F) L   if (hidetimer!='')
1 G; F+ t4 O7 J1 J% P. o: H4 e   setTimeout("hidetext()",hidetimer)
7 E/ S) B# g8 m8 W" b, P   }
2 z2 h# _+ [% r1 N. ~, ]2 P% F7 x& w4 O8 O
function moveBall() {9 J. C! W( g( d# L0 _
   if (superballRunning == true) {
+ S# B6 E. R& ~7 u      calculatePosition();0 d/ \7 Q* g# {' ^5 ?) n, @/ a
      if (document.all) {
  w' K* y  K) u, R( N         document.all("supertext").style.left = xPos + document.body.scrollLeft;2 m, i% u3 x+ w, J' B
         document.all("supertext").style.top = yPos + document.body.scrollTop;
9 |4 v/ V- r( C$ {0 c8 i         }' w0 K* U) D8 X* O
      else if (document.layers) {
7 }, }$ m: ~/ ^8 [/ w5 M( Y: A  o         document.layers["supertext"].left = xPos + pageXOffset;
. a$ F. g: M" a& g" w' c; w         document.layers["supertext"].top = yPos + pageYOffset;8 K0 G* Q+ q3 M% p) ~( `
         }
6 D3 C7 F, _& |9 E      animatetext=setTimeout('moveBall()',20);
- o) t0 h: O, S6 r' {6 m      }
7 B2 G( w1 a, b" F. L   }# J. D' d& {. y$ w

4 G1 o8 s* n4 w& m/ {0 ~function calculatePosition() {
. W3 m% I6 Z4 f# o( r" D1 a- _( L   if (xDir == "right") {( ^( x7 Q% z3 O$ l
      if (xPos > (xMax - contentWidth - BallSpeed)) {
0 {1 k1 e/ C  R. S6 c. q         xDir = "left";
) f3 v! A# F* w% e  O  |         }) ^) |2 O# J% c+ R$ }6 p$ d! [* K
      }$ L# ^) K* m. f' j2 e: W" {
   else if (xDir == "left") {
# l. g. R% t* }* @  W  P+ `      if (xPos < (0 + BallSpeed)) {
( a2 J! s/ L% B8 [         xDir = "right";7 `1 @% S, w% L, k3 {7 D& l2 E9 u
         }
1 _9 l  Q+ ]9 `2 ]      }
7 C$ B: P) k5 j% u8 K# m   if (yDir == "down") {
  @6 y& q- F( D: ~7 f9 V      if (yPos > (yMax - contentHeight - BallSpeed)) {+ W5 k* ^. w4 n2 @
         yDir = "up";9 D1 N. L4 o/ o0 }+ `( V; W9 \
         }
# O! H) g- t2 ?* w5 J7 H# }2 J% L0 t7 ]      }5 E% ^3 a1 q6 q  U) m  K
   else if (yDir == "up") {
' O. h, i- B" l* R) J" a; b8 s      if (yPos < (0 + BallSpeed)) {( t3 s6 P2 [& ]% n6 X9 f: y
         yDir = "down";
. p0 i) i4 X  ?0 N5 i/ ^         }% ^' }3 L5 H7 o# M7 V$ w
      }
; V2 a) A* u% F* j: I+ y8 F  L- s; n6 u   if (xDir == "right") {+ @1 L) u2 K/ R! U# J- y; `) W
      xPos = xPos + BallSpeed;1 `1 [4 }7 ^, B9 A/ o9 ~: E
      }$ V# p" \* f& {8 u$ e" o: k
   else if (xDir == "left") {: d# F. o, s  T7 e9 i) w5 D
      xPos = xPos - BallSpeed;9 J/ x* F7 x; D# M( W2 E
      }. U5 a  N1 w' h+ g. R
   else {
0 r; I( r8 J' O( l( m) m      xPos = xPos;
4 k8 u6 v2 K! j8 V( Y      }' E& b4 @! G: Z( M% n, Z6 h
   if (yDir == "down") {
0 L4 ]. R: s5 l* ?( K- u8 z      yPos = yPos + BallSpeed;: T# `; M8 y. n  p& N: u$ S
      }
" C! g$ G4 J2 d7 Q; m0 c8 W   else if (yDir == "up") {( M, Z, a7 u6 @0 T7 d) S4 K3 b
      yPos = yPos - BallSpeed;1 T& m- p+ J0 H( Y& \( I
      }
. f  t9 j5 d3 }   else {
+ ?! w, P) q5 c2 D1 l, n( a      yPos = yPos;
3 S" R: {- h( M      }
2 v8 R% t3 H- j( m* @4 E; ]5 k5 Z0 S   }
: q0 M( j3 u8 o5 }2 M/ K* T1 x( W- C& ^) e- U, y! m" n
function hidetext(){1 o' J4 ]9 a# z: G, t8 R7 D# Z0 k
if (document.all)9 O; j- T" N; L9 P0 Y* \
supertext.style.visibility="hidden"
+ ?' y- g! j. Q% y' J/ Yelse if (document.layers)
( w1 u8 f# R! d( ^5 z0 xdocument.supertext.visibility="hide"" z2 y4 k5 T3 W
clearTimeout(animatetext)
4 T5 [% h: `8 v) w/ b+ y}
+ `5 N' _; I# I9 a: W+ P) Q& U
if (document.all||document.layers){3 I7 c3 [$ r; \2 q. y1 v# H" W
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'); D$ Q0 j% B8 G/ _
window.onload = initializeBall;
' v6 \5 `( e2 e2 Z9 T, ]window.onresize = new Function("window.location.reload()");
& y' K' ?* n* K/ }2 ~  V}: e' Q3 d- U- W+ R& N$ @  D

4 v6 [- W0 \7 e! r, t0 F  R</script>

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