返回列表 发帖

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

<style type="text/css">
! |0 @) E. Z1 f1 x. o* J- L) Z#supertext {
+ v; ~1 a$ u$ h! t( K4 S+ ?3 Sposition:absolute;2 t( k0 p1 \5 I2 B  G- ?0 q. ]
left:0;
2 W. j6 }) u/ L( V+ gtop:0;8 h, B: q) Z) T( C
visibility:hide;9 [! U! N# y8 }5 |  s7 ]
visibility:hidden;0 ^$ U' M$ w4 d4 Q/ X
}
8 {& H2 O; u0 L  M/ r</style>* X1 F  C# u6 |3 ?
<script language="JavaScript1.2">3 |6 i; P5 B1 x4 D" d& A  V3 k4 |
<!-- 改变下的字体的大小。颜色-->
: d5 v9 t  Q. i/ O6 q: fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 Z3 d* r: |% W% X& j0 m4 |var hidetimer='';: V7 n4 C, [4 [
<!-- 改变下的弹跳速度-->
2 a9 M0 q3 X. f& ~5 ~* s6 avar BallSpeed = 20;8 Y8 p* D5 B9 t% e6 I8 \# Z/ ?7 u
var contentWidth;
# w& m+ T' g1 w7 p8 G9 \, _. b" ]var contentHeight;
! H" g1 b% l  d' A3 t: ?var maxBallSpeed = 50;
6 t2 W$ k7 C. v# }6 h
2 l/ d+ ]8 L, D9 O+ A, f6 b- ~0 ^; v8 v! Z) P3 j" A! p3 S; h, z. s  _
var xMax;
/ q7 ]$ C% }* Avar yMax;
- Q3 M6 s0 n/ S3 l1 o7 Ivar xPos = 0;
7 D2 x# L/ m2 i- `' ?% N7 Cvar yPos = 0;
4 w  l/ |9 I  A7 j" v; b% dvar xDir = 'right';
2 ^2 z4 t7 o9 s3 S8 o: Zvar yDir = 'down';! q/ k- J" j4 |6 n' _
var superballRunning = true;" c1 @# e- B. {: T% |/ W  D' N
var tempBallSpeed;
8 s; \1 N& ?4 i, x6 M& P* [var currentBallSrc;, D3 r" w' d5 w. d) E8 o
var newXDir;
& i+ G8 r/ K- C* ovar newYDir;" O; i0 Y6 ~% l& K2 g6 V

+ ^" S  R2 ~% [/ l' D7 A9 z$ nfunction initializeBall() {
3 K/ f$ C* T; N0 u   if (document.all) {
; D" `) W/ W( S0 |      xMax = document.body.clientWidth2 K% p. \0 T0 r5 I: B4 @
      yMax = document.body.clientHeight& Z5 n; ]/ @2 w: x' W
      document.all("supertext").style.visibility = "visible";5 p# {/ i9 J6 K$ u" Z
      contentWidth=supertext.offsetWidth
9 g6 L+ ?6 a- j      contentHeight=supertext.offsetHeight# g- x! L; H* i+ ^+ v& H6 q
      }
& j" j: K+ X$ ]3 R5 u7 B- B   else if (document.layers) {
& t. ^; n1 a& Y% a      xMax = window.innerWidth;
0 |" w1 I  R3 D6 W3 ]+ O8 K0 {      yMax = window.innerHeight;' x* G' B4 `+ d; S) c1 A: R
      contentWidth=document.supertext.document.width) t/ V: G0 }5 r) Y# w& x
      contentHeight=document.supertext.document.height) k1 c9 Y7 v0 S
      document.layers["supertext"].visibility = "show";
: j; Z: h2 H+ g: B, P      }; q4 l7 e7 C! D% z. a9 E( ~
   setTimeout('moveBall()',400);1 P7 I3 J& e3 ~6 n1 N
   if (hidetimer!='')7 K; R& s, g2 Q. K$ b
   setTimeout("hidetext()",hidetimer): I1 g$ S8 ]7 B. M$ r
   }
. R* m; j8 n6 b6 V: X& n% ~# t0 N2 J2 {$ D5 {* |- u# v. n) ~
function moveBall() {1 G4 N, f  R6 f0 {" {
   if (superballRunning == true) {
1 Z' z  L$ U5 k1 Y. p      calculatePosition();
9 F2 Z$ U* i7 a      if (document.all) {+ J6 X: `# z6 r. |0 c. j3 \
         document.all("supertext").style.left = xPos + document.body.scrollLeft;. h) h7 H7 D% I" Y7 P! }
         document.all("supertext").style.top = yPos + document.body.scrollTop;
: k3 e( E+ m  b5 ^5 y         }
8 D* ~6 z. k( B. y. q( T2 U      else if (document.layers) {
) p5 L$ _& f" {1 l& ]         document.layers["supertext"].left = xPos + pageXOffset;! o! Q/ @/ B9 B2 W
         document.layers["supertext"].top = yPos + pageYOffset;! K: Q: u' @9 K
         }4 _& O- F+ D# U
      animatetext=setTimeout('moveBall()',20);
5 H6 n6 E- x+ U8 A6 P  _, V3 J      }
" z! S+ _9 v5 L  F+ w   }
3 M7 b0 D' c7 t" J$ f7 p) |9 i! B' x
) J- f0 }8 w* g3 `0 `+ y4 T) s$ Hfunction calculatePosition() {
+ e: Y- R" x! R* Y" y" x( ?   if (xDir == "right") {4 t6 H6 H: A; V3 Q, [0 o
      if (xPos > (xMax - contentWidth - BallSpeed)) {! m4 g$ \6 z+ x; M; k
         xDir = "left";) N  _3 E; D" H4 c
         }
: Q9 _: s- v6 s      }
, A1 E- E- W: D2 T. W# s   else if (xDir == "left") {& n7 u* U' w4 d& O* ~
      if (xPos < (0 + BallSpeed)) {+ _1 N' i# E7 p+ C  A6 [- J7 g" y6 u
         xDir = "right";& o1 M' `  W( c0 R( {9 W! G9 A
         }0 |* L/ e4 M% l! k% P
      }
- G* a2 ~# B/ A2 V   if (yDir == "down") {
+ ?4 J/ ^8 f0 h# [      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ J, l/ x# P" i+ |3 X: z; H         yDir = "up";: A4 u% q% P/ O
         }/ l/ s( H' \; J+ H/ W
      }8 W7 r8 g: _& ^
   else if (yDir == "up") {
  b8 K. Y: w5 @1 m. u      if (yPos < (0 + BallSpeed)) {% @1 m+ @. Z0 @& R0 {2 `5 v
         yDir = "down";
$ ^6 G2 D* K: p4 |3 q0 q% Z, l# n         }4 B# {; L6 M$ l6 K% _* J. F2 {5 p
      }
5 s$ E0 a. Y' t% }1 d6 V" u   if (xDir == "right") {
8 L( H* ]+ H" e- X* f      xPos = xPos + BallSpeed;
) o$ i$ I/ g: N! ?      }' p  `% h1 ?) m. [- l9 f
   else if (xDir == "left") {. W/ |* n  z$ O
      xPos = xPos - BallSpeed;
# n2 z1 n1 g! k; z7 J" Q      }8 V7 d! f8 |8 F5 h; b  B& G1 f; {
   else {' M* h0 ?5 J% _, Q; _
      xPos = xPos;: [: y. l$ d8 n; p1 \3 L
      }
% t( H7 z& Q6 q% v4 L9 T& Z   if (yDir == "down") {! }4 }: R8 ~6 H6 k; `9 w
      yPos = yPos + BallSpeed;0 v/ M/ j- Z" Z
      }
' I7 e  S% D& j   else if (yDir == "up") {
/ Q& I1 w! L2 I# c  Z      yPos = yPos - BallSpeed;
/ i% K% M- y7 S5 G) I- B      }
( w& }1 f# k/ K; }7 D   else {
. [: H+ [. C0 ?! r% V* e4 g      yPos = yPos;
5 [! F  J4 f9 G      }
5 e  _% Z* |' d5 J# `) l4 ~. t   }+ V$ s( O  a* k/ H" A% O! R
4 |2 @0 m! s; L( p( d5 S
function hidetext(){. p# A2 [% G2 y$ m; Q0 c  v5 b. G" w
if (document.all)
/ D6 \7 b" v, Z9 r* l& ysupertext.style.visibility="hidden"0 ^. H7 z! c4 m. I- g3 U
else if (document.layers)
0 V2 ~* S6 Q6 W% Kdocument.supertext.visibility="hide"$ _- o0 N+ v3 y  e0 J, u
clearTimeout(animatetext)
' E9 e3 t+ `+ B/ G3 f2 z- E; C}
" S: `# v' b# G# J0 P' C5 R( d) y
if (document.all||document.layers){* i- d8 F3 E0 e: f' [+ ?% m
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
1 e0 a; v' [. ], iwindow.onload = initializeBall;& X1 B& I4 y! u  s* t: h2 c% E: U% d
window.onresize = new Function("window.location.reload()");
5 `5 O& s* H6 e}, s/ ]: l. L, E' W7 z; b
' R; D4 [! U7 j
</script>

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