返回列表 发帖

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

<style type="text/css">
6 g7 H& f( d5 {4 J) ?; ?9 P- f#supertext {" a' e- M$ I# w6 Q7 e
position:absolute;
% c9 j. k/ C* C- q1 cleft:0;
0 g: g9 U2 s' @) @top:0;
7 d8 I4 b( S  t6 f0 |: D6 Y) Evisibility:hide;
! z, d' R! y, v: Q  Q$ xvisibility:hidden;
) v) y' a) i( `8 U3 `4 Z3 ^}4 S: U7 f. A% s3 }7 D
</style>( z5 x7 d( b' R" J/ r3 k, d
<script language="JavaScript1.2">* G$ ], J* [  x6 I$ O& B- h' @: p
<!-- 改变下的字体的大小。颜色-->4 ^; k, _! p1 b7 i+ o
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'! E6 I- A; O- A
var hidetimer='';
( C1 {2 X1 O$ _9 T/ {<!-- 改变下的弹跳速度-->
7 l6 C3 h; |- X5 W# b; jvar BallSpeed = 20;
8 \# ^% D" s( \var contentWidth;
4 h" r2 t- c8 T+ z# Q$ _# b& lvar contentHeight;- o& l- ^& L5 O: {
var maxBallSpeed = 50;
8 I8 h# y7 d5 @4 P3 q+ A5 S4 J, m" b" v4 I$ {" j  h# v

* E% ]  q, P/ O6 l- b. }. o' W5 hvar xMax;8 h1 E# Y- s) V# u+ t: Q4 R
var yMax;6 P4 l& L, n  O+ U1 I( ~% S( Z/ ]
var xPos = 0;2 N2 C! |) R9 n4 K1 \& V
var yPos = 0;
# S8 ?& w5 G* u* h( N: N( hvar xDir = 'right';6 R$ I  p9 \# B9 w
var yDir = 'down';% P7 `+ A" q0 a( z
var superballRunning = true;9 R2 a5 P* y0 L3 c. X" P
var tempBallSpeed;
* m! O+ y/ v4 X, f& Yvar currentBallSrc;
+ G! l- ^" u1 Q# X. h3 u/ Dvar newXDir;
) G# ]& c* R3 ]9 f( M; ?var newYDir;3 h3 v' ~# C: E6 }1 U7 b

7 n- C$ y* u; e  Y5 dfunction initializeBall() {
$ o6 h% J: l+ U. S   if (document.all) {, [( U2 `1 B' |$ c+ `1 R
      xMax = document.body.clientWidth
: O1 f( P3 R! j      yMax = document.body.clientHeight
3 K! n; l6 B- [6 [" d/ z      document.all("supertext").style.visibility = "visible";. N& \5 m; ]1 [8 }! H
      contentWidth=supertext.offsetWidth
4 l3 Z; g0 W. M2 c1 Q6 s$ {# U      contentHeight=supertext.offsetHeight
4 n0 [9 b& F6 w      }
( X0 o7 P/ J  d- y- C8 [   else if (document.layers) {
: ]% ]6 ]* k" ^* Q7 c      xMax = window.innerWidth;
/ l5 Q5 b6 o. I% M      yMax = window.innerHeight;( S7 V4 E7 {& Z. E
      contentWidth=document.supertext.document.width9 S4 S+ d) z; G2 c1 I3 s8 ^/ D# P
      contentHeight=document.supertext.document.height: z) }2 E4 n; e5 |. Q& K2 u* |
      document.layers["supertext"].visibility = "show";
7 R" T6 m' C: \# N2 y$ h) ~3 [7 A      }# W$ W! @7 p6 V  [. `4 x
   setTimeout('moveBall()',400);
7 l: f7 ]6 Y- @# m$ h7 e5 i   if (hidetimer!='')
3 {! y2 s" V5 E, q* J   setTimeout("hidetext()",hidetimer)6 Z2 Z# N4 K7 I
   }: y4 O6 m, ~' |  y- R* Z) {  A$ h

/ v( C! @; }6 p3 l1 r9 mfunction moveBall() {
$ k- Z9 G9 E6 o1 X5 Z   if (superballRunning == true) {
- V; V# c( i  w4 {: F* |+ c      calculatePosition();9 I2 F, d  B3 N$ J! ?
      if (document.all) {
! M7 I8 H0 U- Z" Y5 q- v0 X& u         document.all("supertext").style.left = xPos + document.body.scrollLeft;
) T8 F6 Y7 ?& ?2 u; m6 T$ V& n+ L% R         document.all("supertext").style.top = yPos + document.body.scrollTop;6 z+ K  w3 Q8 X. p2 H7 j
         }: ^, V' c# z% g) m
      else if (document.layers) {) n$ A7 Q5 ]! D% y" b& U8 v# F+ U5 w
         document.layers["supertext"].left = xPos + pageXOffset;
" ?7 C7 e2 W4 D. l# Y         document.layers["supertext"].top = yPos + pageYOffset;8 ^+ z, p9 E7 m+ S8 v' A' k
         }1 @5 i8 j9 T7 Y' y' x2 {
      animatetext=setTimeout('moveBall()',20);% q+ c, R+ Q: \/ z4 s6 k2 K5 L
      }
5 T  f  O; F9 R0 t$ g   }
+ O1 g5 f) n, A4 I4 ?
9 H* M+ M' _9 X: b) k' Efunction calculatePosition() {  m7 H* h1 ], y) `4 R! o
   if (xDir == "right") {
' f6 g2 }( Q4 O9 l$ E' E& k- r6 E      if (xPos > (xMax - contentWidth - BallSpeed)) {% F* U/ \5 r8 W+ N/ `
         xDir = "left";- m1 S5 t5 d5 b9 B
         }
; _6 c* _  V4 D% A+ d$ j      }$ S0 u1 |2 T$ c
   else if (xDir == "left") {
$ p! G! {8 S1 v1 r" z+ v* [      if (xPos < (0 + BallSpeed)) {4 S1 t/ B! {2 N$ ~- Q( O
         xDir = "right";
! ?- j1 c$ H6 A  w% _7 w/ k) E9 B         }8 q; P$ p, @0 P
      }
" _% J* N8 m9 F$ y7 z+ ]( ?   if (yDir == "down") {& R  o8 ~. E. N! V/ ?/ H9 B
      if (yPos > (yMax - contentHeight - BallSpeed)) {
) a/ p1 y7 k' q/ J         yDir = "up";
8 n4 r; h$ T7 k         }
/ G/ u& w1 T6 \9 Y3 L      }
' W3 L% W8 T% V' K   else if (yDir == "up") {, d" [6 S/ X8 V2 X- M* P7 k: ?) I& R
      if (yPos < (0 + BallSpeed)) {2 ?$ d7 m# ]. i1 K
         yDir = "down";
( ^5 W( |4 E* T, [& K: G         }/ z: T- l9 W* f, }- c  N( w! D
      }5 ], r6 @) G" F) }* e' T6 R3 j9 V# e
   if (xDir == "right") {
  e! `* b6 j3 a      xPos = xPos + BallSpeed;$ B8 h: P3 a$ h9 B3 ]' z
      }8 q2 j' A2 y9 Q( W
   else if (xDir == "left") {& Z6 L/ w* t) C! c6 s& T- ?$ w1 B3 G
      xPos = xPos - BallSpeed;
/ \3 Z: [2 I* ?6 i      }1 ~2 r- c- C4 y1 b& ]6 r
   else {
- I) s3 `4 s) W3 F      xPos = xPos;+ |+ n/ Z+ r' K  L. F
      }
0 K$ A. S$ H, b% R/ Q   if (yDir == "down") {2 `/ I4 ]) i+ t# i5 O7 D1 M+ V
      yPos = yPos + BallSpeed;
7 a/ @1 T5 E4 {- g      }
3 |/ E/ r* e/ y, h' d5 a& f   else if (yDir == "up") {) c9 W' U; A5 g. r1 L/ p+ F. H0 B
      yPos = yPos - BallSpeed;: u: _8 g* z9 n% K! C0 p
      }
8 U0 D6 Z- C  S1 K2 T% V: n3 t   else {
, F8 L5 Z& p3 V      yPos = yPos;8 H) _! o& O. j4 R8 I  I
      }0 ^3 n0 Z$ \0 |
   }
( f6 i5 f$ P2 y' w2 @; e
8 y# z/ Y1 N" r! l- G* @function hidetext(){8 \4 {- P0 c4 F
if (document.all)% z, p" e6 c" S& b* p. y7 }* n
supertext.style.visibility="hidden"+ V3 R: ^3 f+ R& Y
else if (document.layers)" D7 ?  m5 |; g2 {. G' l9 M' \) P
document.supertext.visibility="hide"3 k7 N$ I7 b7 V3 C0 L+ d0 O
clearTimeout(animatetext)
/ R3 `9 V. Z1 ^8 G}
. ?" Z+ q; C+ x4 V
& {. x* N, ^  E# Iif (document.all||document.layers){
. p$ y- B) \! B- [, y0 ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'); |' }- W" M7 m! T9 Z
window.onload = initializeBall;* e/ @# z3 k) l0 _; k" _6 Q1 f6 Q! {0 u
window.onresize = new Function("window.location.reload()");
, P& P; `3 t) a# G8 d# V0 Q7 G/ S}
1 y7 e* H- M. C, d2 r- Y2 c3 ^: I* D- v4 G4 T
</script>

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