返回列表 发帖

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

<style type="text/css">% D7 p' |. Y& [9 G
#supertext {
: T% x, U. j, a$ N- f! y; g  fposition:absolute;' j8 w5 X3 |/ t& ?
left:0;& ?. @  n# t. h% |+ x" D
top:0;' _$ Q; _; T( o$ c
visibility:hide;6 A1 h- _! S( N
visibility:hidden;
- k$ T( S8 Q  V# x. _, X. [}( E$ D7 E% \8 V* k1 I& f# {
</style>
. o4 e& _& g) J. s0 L<script language="JavaScript1.2">- f$ o# J/ p) e: B7 F# [+ m
<!-- 改变下的字体的大小。颜色-->+ z! o0 S! f, Z& D& V4 r5 Q' Y
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* W, p3 i2 ^6 }3 L, v8 t: zvar hidetimer='';
8 f  z% R% q& y* `% M; ?/ ^) ~<!-- 改变下的弹跳速度-->
" D% X) y/ E) F6 I) k: d) Kvar BallSpeed = 20;
. F/ m& v2 C3 o! u1 }& Uvar contentWidth;1 h! G3 F) \1 ~
var contentHeight;* Q, g) A( r0 E( S4 W
var maxBallSpeed = 50;0 K0 T% n# E6 i- _+ T% f7 s) O" i

% [( T) t4 W3 ~5 C
" S# |% U  k' Q' K8 ]3 Avar xMax;
0 X- [7 d5 {6 K3 X' ~- Tvar yMax;! c4 m/ d4 q- K: j# n- c/ S- g
var xPos = 0;
- C. z" D: ^* p* i# y1 ~var yPos = 0;
/ f' s) a; W# C# d# I9 [5 l' E: Bvar xDir = 'right';1 `. q/ B; D; @( P
var yDir = 'down';2 ~. y/ j, S  V) J
var superballRunning = true;2 A; ~& `. V2 s' M& L7 y
var tempBallSpeed;2 V8 n/ U& T  A2 K" O
var currentBallSrc;5 h0 A" g5 ?. D6 k9 [, A1 I
var newXDir;  x7 H! S6 O% C2 W
var newYDir;
9 \: O4 U% Z9 O
8 [$ q# Y7 t  @7 s! }function initializeBall() {- I$ L  t  P4 |1 {) ~- I$ B) X
   if (document.all) {( \7 P0 j+ f8 b- w+ W
      xMax = document.body.clientWidth. F: h9 b) F# x/ R! i4 H+ q
      yMax = document.body.clientHeight
' p9 D  W2 A. [9 ~! C0 ~; X( t      document.all("supertext").style.visibility = "visible";  a* d  l" W  n1 }% w/ i  M
      contentWidth=supertext.offsetWidth
7 d8 i; Z  ~. i8 y      contentHeight=supertext.offsetHeight; O4 ~( v4 J/ @" n& @2 c
      }
0 p: y1 R  ~0 o$ p   else if (document.layers) {2 U  B7 o$ M: H/ I  }2 `
      xMax = window.innerWidth;$ q. b' J# J. y* ?
      yMax = window.innerHeight;
+ `" X+ `+ a1 A- `8 L: p" F6 W      contentWidth=document.supertext.document.width) Y, O: d- k3 Q7 b5 P+ F- a! q2 W
      contentHeight=document.supertext.document.height
  v6 {9 }) j- [) h- s      document.layers["supertext"].visibility = "show";9 [/ D; N+ D9 }& J- H3 C% \
      }
9 M- E) d! }5 s; @   setTimeout('moveBall()',400);
; ~( L3 u( V  m   if (hidetimer!=''). M8 a4 i1 c& @7 w- ~  z' J
   setTimeout("hidetext()",hidetimer)3 K8 {8 {$ U: @) e8 L9 v
   }
  z8 b% v( o& y: k7 B
& T( o4 c4 e2 Z! M! n/ g/ O( Gfunction moveBall() {0 |" C5 e% }3 N7 y6 S
   if (superballRunning == true) {# |4 ?7 s4 {5 {
      calculatePosition();. D1 N" p, W& n
      if (document.all) {
1 Z" l9 C+ S0 B/ Y( [+ V         document.all("supertext").style.left = xPos + document.body.scrollLeft;. B) C( W0 t3 J% C
         document.all("supertext").style.top = yPos + document.body.scrollTop;
" c' ^% K% N3 X; \3 a: G! N' F         }  R# s8 g# I/ W& z
      else if (document.layers) {
9 d: v( z. \% t) y6 U! N         document.layers["supertext"].left = xPos + pageXOffset;: s" P  f$ I9 Z4 \) G% S7 \
         document.layers["supertext"].top = yPos + pageYOffset;. X* b( q0 Z/ P
         }
  ]2 t6 b7 D- a; A4 E% Q, M      animatetext=setTimeout('moveBall()',20);
5 O& w" V+ y, |6 h      }5 H$ ?  d: q4 z# S3 h! Q
   }% J& Q  r( D1 f

4 C: n; x% K. V$ n& R0 P) R; d& |function calculatePosition() {$ D( X7 n) D! D) }5 G$ p) L  Q
   if (xDir == "right") {
- F+ h( D7 f! `- {3 J6 s4 A& K      if (xPos > (xMax - contentWidth - BallSpeed)) {
4 w$ I- i+ ^, S+ D2 S6 K. ?         xDir = "left";! J* G* h" H: q+ Y% u+ r1 o, `
         }/ F8 I* P6 v% Y: G* E. N  S) g" j4 K, p
      }
+ r/ P$ Z7 c. t5 z- \8 A  H   else if (xDir == "left") {
4 _+ s% |# t5 k% ]7 z  U      if (xPos < (0 + BallSpeed)) {
1 f  G8 ]1 H- }         xDir = "right";0 h6 Y. S+ Q7 T4 C  H
         }1 L) c/ x3 {& l5 k' S# A, ]
      }
6 O. C' t2 a+ C9 g' E9 M+ I. F   if (yDir == "down") {! R2 ?2 ?; D& i0 r
      if (yPos > (yMax - contentHeight - BallSpeed)) {) R+ {9 X' x9 ]* E
         yDir = "up";
' `; E: ~' @$ e) V1 V& D8 U         }
) W9 ?& T! p9 K; x! z      }
& C1 g6 g, ?8 A3 w  \   else if (yDir == "up") {( K) l- ^1 C$ w; e- w
      if (yPos < (0 + BallSpeed)) {6 d# G) m/ @& K9 A: x0 ?& p" K
         yDir = "down";
1 i% R$ X3 r! g# v4 _         }
3 s2 {/ L/ q" ~) o: ~      }
; |6 g% @7 }) z* D   if (xDir == "right") {- I* f3 I# K! ^0 J: T0 R
      xPos = xPos + BallSpeed;
" ^' p) T+ c) k3 [      }
5 O5 b4 S# C% n$ n   else if (xDir == "left") {) E: y/ A, m( k4 E; j  P
      xPos = xPos - BallSpeed;
0 v7 A$ F- M: E- P# C      }' o$ V( j4 P! d8 B( e, a
   else {  s' [9 b4 W$ d* S' E
      xPos = xPos;+ x, Z' |* D  F# f$ E
      }5 C" g9 Y" V1 d, Y6 A: `; y
   if (yDir == "down") {
7 G5 v8 ?8 ]# t) w8 V3 h1 s& n+ V      yPos = yPos + BallSpeed;% @7 K) w- d" v( b$ @
      }
. r  e+ S& \  U. o) I' _, k   else if (yDir == "up") {. \! o8 @, x. k0 z  ]
      yPos = yPos - BallSpeed;
0 O# p  U# K; C$ l2 C0 e      }5 r1 B+ r5 n! b
   else {$ u$ O! w: B- N4 C: E5 R
      yPos = yPos;
9 V5 j  d/ w( l( T( e& h4 L      }9 a* X& ?4 \! y& R: X1 n' `. c9 a
   }
" u, T4 a& R) m% {, F) v
0 g6 N: i. @# C2 Yfunction hidetext(){4 S$ N: r% |  K, @
if (document.all); \. S$ O5 ~2 W4 }1 z+ T& K  r8 C
supertext.style.visibility="hidden"
$ {3 F, n# `& `7 o% p/ [' _else if (document.layers)
: d- A" U- V3 |  w. M2 x3 y7 ~: ^, _document.supertext.visibility="hide"
. ]9 x8 m- i7 U6 s0 AclearTimeout(animatetext)
9 k3 q# V! n$ N( u}
  \$ v& d% P( `# N' ^) v. o
2 x- a$ k" u% z1 s, _if (document.all||document.layers){( x# p3 H. |4 R7 ?' I1 e
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" G5 J" X& f: S2 k1 ewindow.onload = initializeBall;$ p& P6 q: C* ]) s* Z( c4 |
window.onresize = new Function("window.location.reload()");& D  _! r9 E$ e* Q6 B
}0 \0 `/ [8 r0 A$ W- q, v! d
% |) Q# l! H/ l' C* p- Z. p+ H8 M
</script>

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