返回列表 发帖

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

<style type="text/css">6 E9 Q( [( Z9 G: v4 I/ k' S
#supertext {
1 O/ ]" q; N0 t' nposition:absolute;
4 B$ v$ q* G) S! Xleft:0;9 _8 R+ T* t' O/ [1 R; @
top:0;3 t8 k& l; o/ V1 K
visibility:hide;
# y: P% I) }" }3 X+ A3 z5 w% Jvisibility:hidden;7 x* ?3 z( w/ q1 w9 T3 L5 _
}8 Y! a# i9 h1 Y/ D" K6 z6 Q
</style>
7 L7 z; q% B0 t3 Y' v<script language="JavaScript1.2">4 a- _5 E* m  x' g5 [; c
<!-- 改变下的字体的大小。颜色-->
) J7 i* O  U- s2 S  u7 ]var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" D- L4 _6 `+ ]. x" P& t+ ~. gvar hidetimer='';
" o7 C6 w0 M2 @+ d0 I. X<!-- 改变下的弹跳速度-->& N; F9 C4 m9 B8 E
var BallSpeed = 20;1 `; `  w' g8 w. @( e2 J) K
var contentWidth;- r3 X8 j. B% h9 S: A. |
var contentHeight;* t. |0 z+ n* V% V
var maxBallSpeed = 50;0 F! V0 b7 l( j8 G# D
3 N, ~) {8 X+ }( G, n5 ~
2 z' o5 |8 }4 e3 c$ w
var xMax;
4 L: {5 a  q& Wvar yMax;! H/ f- n# [- A5 k4 }& d
var xPos = 0;" f6 x/ \" ?$ ?* W, \5 O" a
var yPos = 0;# D$ [( u  h6 [5 p& e" N
var xDir = 'right';2 s# D9 v. \8 D2 U3 l
var yDir = 'down';
. y. Y( s7 \: L3 C8 E7 m4 wvar superballRunning = true;7 q9 }1 p+ r8 L
var tempBallSpeed;0 {" N$ A0 U. K; s' ]
var currentBallSrc;
- t2 ^8 J, Z4 e/ c$ _var newXDir;
2 e7 |9 t# Z, @+ ]3 O0 ^+ _  R+ [var newYDir;
2 s- ?  p- F8 X, b/ O* h2 T, N) s. V6 F4 D8 G9 T
function initializeBall() {
9 E1 t7 J& b; T' z9 O; j   if (document.all) {# t3 r8 r' m( f& u8 D1 d, l
      xMax = document.body.clientWidth
; n* J  I7 h* a; j6 `0 W      yMax = document.body.clientHeight
/ T6 j2 B' ?( [: z) S* d. }      document.all("supertext").style.visibility = "visible";
/ m$ L3 n4 h/ X/ R4 I      contentWidth=supertext.offsetWidth
- l9 \# I! Z& b3 u- }      contentHeight=supertext.offsetHeight" Z) F3 ?  H  h6 \( a3 S
      }
4 e# _# E3 S' W   else if (document.layers) {
* c: w4 H0 m5 V  \  G; ]      xMax = window.innerWidth;
+ X! ~  X3 H, `& I3 @. Z      yMax = window.innerHeight;
* X& V3 J9 v) @. P$ u9 E/ ?      contentWidth=document.supertext.document.width
' G* U' s% R. D9 w      contentHeight=document.supertext.document.height' [0 R( J7 u$ `1 ?! H
      document.layers["supertext"].visibility = "show";
# ?' T) R/ c5 g3 @      }1 |3 j% g6 b2 ~& p
   setTimeout('moveBall()',400);
+ V) n+ v6 x" ^2 a1 {   if (hidetimer!='')
* l  M- K% W) F0 [$ v6 X; e! X   setTimeout("hidetext()",hidetimer)
5 a) O! j& Z! g+ o3 Q8 U0 l   }
' m. u* p6 v4 g2 V8 }
% Q5 ?# p# R( S* Efunction moveBall() {( M1 y* A+ w( A, }6 E% m" U( V, J
   if (superballRunning == true) {
% ?8 R$ w3 z0 j  N; ?9 X+ \2 g$ r      calculatePosition();
" k  z; k2 t6 V1 K& i6 h1 g      if (document.all) {
2 f2 e  q9 C* Z6 r         document.all("supertext").style.left = xPos + document.body.scrollLeft;
* n* J. d5 |! V7 j* b" v         document.all("supertext").style.top = yPos + document.body.scrollTop;
: ~: s- o7 b( h2 e4 e# K% S( Q         }
1 c) h1 u% Y  C      else if (document.layers) {3 F0 Z; x1 I6 u3 x3 x  t$ w8 ]* ^3 c3 x/ x
         document.layers["supertext"].left = xPos + pageXOffset;) t0 }. {, D# S
         document.layers["supertext"].top = yPos + pageYOffset;2 A: O$ l6 g8 ~) _1 x- e& u* T3 y
         }( @0 N' _7 D; K2 [8 I1 m9 Z, y
      animatetext=setTimeout('moveBall()',20);/ }$ `5 E2 A& m: a6 n
      }; R& m, |. |# F1 }8 Z2 W. ]
   }
' ?8 @! q# H# J! Z; |; C  D3 E5 `2 O- _8 {3 b0 m& s7 j
function calculatePosition() {! ^5 f/ x5 n. m
   if (xDir == "right") {  W/ A; ]3 [7 i# m" h' W
      if (xPos > (xMax - contentWidth - BallSpeed)) {3 W5 i5 b% I1 I) L
         xDir = "left";' T6 z) U) M6 D/ g! U3 @8 L! b/ }2 Q
         }6 W0 v4 n2 j  W) v
      }
" y! a+ z2 M7 O& X, S   else if (xDir == "left") {
1 j$ d) M+ _) ~% ?      if (xPos < (0 + BallSpeed)) {2 Z3 M6 J" e8 H
         xDir = "right";
0 {/ R/ B1 n& O         }9 k1 a( n2 w& p+ e$ @1 `6 d' c+ U0 U$ O
      }: U" Z( @% I" m# F6 ^# X( u
   if (yDir == "down") {' H* [5 Q" ^' G) F* k/ N
      if (yPos > (yMax - contentHeight - BallSpeed)) {
* G, L7 _" a0 o8 f% T; T* L         yDir = "up";" p9 G6 b- b7 M4 D7 ~
         }( t6 _: P5 i3 j! C$ L* T6 g
      }' W0 H. |; B% \/ X( t0 ~# H1 c
   else if (yDir == "up") {  j" H8 d/ r- v. M
      if (yPos < (0 + BallSpeed)) {
+ g7 ?' W8 f, \% i% s/ d; T$ |         yDir = "down";
& c1 P  S+ I; |         }
- b; z  }6 w1 q. c; h& e: u) U# g      }% G1 G% i* Z( v& Z: ~
   if (xDir == "right") {
. y# M" B- A2 f; R      xPos = xPos + BallSpeed;6 L6 q  |, W5 e$ B
      }
9 g% T# W, f) }/ s   else if (xDir == "left") {
$ b+ {9 c; i+ Q# H5 H      xPos = xPos - BallSpeed;
; m. K& v( Z% ~* Y1 y      }% K. G  A" t$ i& T4 j) J) ?6 ]4 ^
   else {5 q! U9 B; v  {6 `6 q. V5 E: H
      xPos = xPos;
" X% d) v- Q4 F8 J3 J! m& A      }
4 f  Q0 z; c8 O: w5 o; V   if (yDir == "down") {. `' i( R6 v8 {' g
      yPos = yPos + BallSpeed;
4 e: t" f/ W' |/ v% T6 b      }' k$ t! G  W5 d* y, a
   else if (yDir == "up") {" a- l+ s1 S1 e! e( J
      yPos = yPos - BallSpeed;# x* Y" v9 Q! a6 y; P% j% r3 N* F
      }
  c  N. @: E2 J6 a# E. e5 K   else {( S# B. w; s2 h5 h4 R/ {
      yPos = yPos;7 A/ N* Z$ B& d* i
      }4 u: g: W5 n) }4 l& n! G% a) i* s( U
   }
9 V2 ^0 v7 [: z; k. t5 I+ J
) V1 |+ o" I. c: sfunction hidetext(){
4 ?8 k7 _7 B  }2 T, ]1 nif (document.all); ?# F& Q( @- J3 B4 H
supertext.style.visibility="hidden"
- z2 u8 i; G3 Y: Xelse if (document.layers)
6 B2 I7 b, b8 Z) q. adocument.supertext.visibility="hide"" _" r; ?! P: e6 t" y# W) Z8 s
clearTimeout(animatetext)
* r3 \" W6 v. E7 }" B8 f. O2 X9 A}
8 }) A: W' K7 t5 S- ]
% Z+ |! N7 S  L8 d7 j# ^! B# T0 sif (document.all||document.layers){! M7 n1 X" v5 b8 Y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 y8 o+ G: O9 s5 @0 A* Cwindow.onload = initializeBall;- @+ m8 t' b( @/ }6 y' H
window.onresize = new Function("window.location.reload()");" U6 F! |& U" _
}4 g5 i6 t  D- H* y: h

& R* H0 J8 ?& s</script>

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