获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">
& J& A1 o; e( o#supertext {, a( V1 j# ~9 q  M- J
position:absolute;' X$ T1 e- L; @; D& ?( O
left:0;
) n7 ^1 D. x  c) otop:0;  M% @# F2 J) U- S* z- S5 H4 _1 t
visibility:hide;
; l- k" ]: \+ D# ^& `0 Yvisibility:hidden;
8 ^1 y. T' \/ P$ s% `9 e) j}4 `7 H) W- F3 g: b
</style>. p* |3 ]5 Q0 f# ~$ F$ c& w2 H2 ^
<script language="JavaScript1.2">& J3 j( G$ O2 p4 Z! ?
<!-- 改变下的字体的大小。颜色-->9 G2 z1 n5 ]2 X$ G, E
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'' h2 g7 {5 p& K  {2 {% m+ n% O
var hidetimer='';
. H( `5 M, Z2 N, N3 S. C<!-- 改变下的弹跳速度-->- n1 O8 F  D* M8 g. M3 G$ l
var BallSpeed = 20;% x" j' O3 A& T% C
var contentWidth;
7 Y8 `* Y/ Q2 b+ {/ ~var contentHeight;
% @3 D+ ]/ d8 zvar maxBallSpeed = 50;
  L3 b) C4 |7 ~( Y; c% Z$ A. P/ D* S% g8 l( x
1 x- @" j) |% N* K/ a0 t7 B
var xMax;0 @/ y3 `& p& ]( B, K. C
var yMax;
+ L0 A' D8 [8 D, evar xPos = 0;
" I: h- z7 v" X( h( h, m5 S  fvar yPos = 0;
) |. ^. Z; f# W5 svar xDir = 'right';
0 p& j  [* p& E& k9 ^7 U0 |2 yvar yDir = 'down';
, e% w* Q; s  N$ i- z3 }var superballRunning = true;# z' t) `6 Z( ^
var tempBallSpeed;
' V; ^: p6 _( T4 avar currentBallSrc;
: f5 M2 [7 i! d) v3 [  B" Qvar newXDir;
4 ]5 O' H% M/ h$ P- K. T. {var newYDir;3 a( L; s3 k6 q' O. a5 H) Q

/ U* u9 o& y! l6 }6 [' D5 v2 Rfunction initializeBall() {
, o3 s0 H" H1 w: D5 m% G# \   if (document.all) {
' ~$ r' t+ g0 d" z+ U+ d" s      xMax = document.body.clientWidth
2 @/ {  v/ b9 c+ A) L' A2 T      yMax = document.body.clientHeight
! b1 e( i7 @5 d. e) `% g# D: W      document.all("supertext").style.visibility = "visible";
1 l! m3 _7 v5 P9 e      contentWidth=supertext.offsetWidth
. z# |* B  n7 w; M! q7 o      contentHeight=supertext.offsetHeight' j8 S5 K  |" x, Z4 t
      }3 Q" [, o0 [& y% D; Z
   else if (document.layers) {
) g5 r9 g" Z" d" [; T% n      xMax = window.innerWidth;: J; u6 b% X2 s/ o+ Z
      yMax = window.innerHeight;
8 h6 ]5 h. v7 J" ^/ _" ]. H/ z- J      contentWidth=document.supertext.document.width2 Y$ q" I/ ?! p7 L
      contentHeight=document.supertext.document.height3 p( Z& [7 [3 Q  K5 A* L
      document.layers["supertext"].visibility = "show";; h5 z' E7 K1 A2 P
      }
) ?: i/ A6 R3 y1 W" n$ @( m   setTimeout('moveBall()',400);( r- x6 i9 b* K. h* i
   if (hidetimer!='')) |* o, o% y6 I( r6 ?
   setTimeout("hidetext()",hidetimer)
* n* A: o6 X$ q/ h+ G2 U% Y* Z   }2 W) t: D4 A9 H

1 T' H7 m  q0 {$ ufunction moveBall() {
/ r# @, O! a6 F/ n" E   if (superballRunning == true) {
0 G* c( Y; W5 ~& }: d4 O% x      calculatePosition();
+ W1 i& c, f; L      if (document.all) {: L3 P$ P6 Z# ^$ Z
         document.all("supertext").style.left = xPos + document.body.scrollLeft;: X3 `1 t1 A8 z1 g7 K+ G4 g9 {( d
         document.all("supertext").style.top = yPos + document.body.scrollTop;
8 G% }, l9 C- W( w         }
5 R/ |# g4 q" P9 e      else if (document.layers) {; [7 k) m* {* ?0 X3 d
         document.layers["supertext"].left = xPos + pageXOffset;
3 b# H, O4 B# ^9 {# G         document.layers["supertext"].top = yPos + pageYOffset;! i% `5 l0 k. ?9 Y# h7 }' s
         }" L3 ^# e  S+ l7 F2 W' e7 \3 N
      animatetext=setTimeout('moveBall()',20);
# o! t2 V7 f) ?) E      }( v  u3 J9 y& q- l8 M) w2 t! D; Y
   }
( F& }9 q. x3 e# D, t
" |. y. A/ D* t' Dfunction calculatePosition() {$ [, [5 r) e* {9 r
   if (xDir == "right") {
. {. _+ y; B3 Y: z      if (xPos > (xMax - contentWidth - BallSpeed)) {
0 R3 |3 ]3 F9 u$ \) ]7 E         xDir = "left";; Q2 F* o6 M/ I7 v: e
         }7 g( a8 T3 `; ]2 ^; V% B5 i
      }6 M& G  T3 X  P  s8 E
   else if (xDir == "left") {
# x$ t; O* k* e) T3 E0 z# v      if (xPos < (0 + BallSpeed)) {2 E* ]5 m& e; U
         xDir = "right";
; F* M3 t% |! @# Y1 Y         }* V) K: n1 U0 O  D+ s
      }
0 V+ a% T9 u7 e1 C+ B8 D) F   if (yDir == "down") {& u  x/ `6 m( ^9 T1 z: o5 y
      if (yPos > (yMax - contentHeight - BallSpeed)) {# T8 s* c2 N7 {* D! H1 M
         yDir = "up";
: e7 V1 D2 E) b; t  G, _) F         }( w+ a* M  z) O. M
      }/ z* F* H* c3 \
   else if (yDir == "up") {
3 r# F8 u* ^5 O! i, P+ b) C; Z      if (yPos < (0 + BallSpeed)) {
4 W: \, F3 }0 R1 [3 T8 p         yDir = "down";
# O. p2 G; t( ~* o& W         }1 i/ B( }: M+ Q% {" @
      }
" h; X1 [/ e, i% }" s   if (xDir == "right") {
4 D0 h" l( |3 u9 d  l# h* U      xPos = xPos + BallSpeed;
2 ^1 A9 f0 u5 r/ M      }' p- B" b% \5 t, m  o' n. J' X
   else if (xDir == "left") {! e0 c9 U! }* b
      xPos = xPos - BallSpeed;
( w1 B  A5 u* f' _+ Z* f: a! F      }
, ^9 K' o) W: y+ M6 A' q9 t& I   else {
3 X) t1 T* i# b      xPos = xPos;
& G  F; Y4 w$ t/ L( F      }. @: ~9 d; I: O8 S
   if (yDir == "down") {
2 ]! {7 Q8 t2 D0 X9 t, I      yPos = yPos + BallSpeed;& R1 A+ w( ~( x2 J& s6 Z
      }8 |1 ~4 a6 r4 G  c# }: `
   else if (yDir == "up") {
2 D1 i, [' V4 K; @- s      yPos = yPos - BallSpeed;" i0 S$ S: f. w( b  d' b
      }
# ?3 ^# Y+ j! n   else {
5 P- M8 Z8 Y7 I: w      yPos = yPos;& I, D; {7 V! [# q: n% h; O5 s0 m
      }0 \" b, C, S. X
   }5 o4 |; F6 W' [. d. X/ l$ o
+ j  Q: J: A; s
function hidetext(){' [* G6 R' Y9 H; q4 v
if (document.all)
, v, Z# e& H" h; f4 ]" `supertext.style.visibility="hidden"
& _- J8 d: K- W+ h0 ^$ q9 |' pelse if (document.layers)
$ I7 c3 Z# F$ }: Fdocument.supertext.visibility="hide"
* \  ^6 y: I5 l. ?) B  |/ t8 x9 VclearTimeout(animatetext)- U) o$ l  H9 C
}
# z3 @& ]" {6 D: b5 t: ?
4 F3 M4 }: M9 O, ^if (document.all||document.layers){  `. x6 e. H0 s7 E4 Q
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# k# B4 k2 k, q$ T/ R$ z: v3 mwindow.onload = initializeBall;
4 M: _8 J) w5 f4 A2 lwindow.onresize = new Function("window.location.reload()");+ d! v; u0 U: ~9 K; ~0 V4 Y
}
. J- c5 G* \  s( T  ^: N9 ?) E4 G! A: o: b
</script>

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