返回列表 发帖

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

<style type="text/css">- P3 Q$ l/ K& A/ M1 _$ b7 a0 _
#supertext {# X  ?2 u6 n- `
position:absolute;
3 N' |1 R- d: o+ W  |, G; h( A$ yleft:0;
* n$ b4 a' F3 h8 n& L4 u- Qtop:0;
5 G$ m/ n' p: p; Fvisibility:hide;
, N9 C8 W1 z) T" cvisibility:hidden;
* }* h/ N0 k4 t; P}2 r0 M, Q/ _" `
</style>
4 g' e/ R* l& s. c" R; Y<script language="JavaScript1.2">/ r+ A- `( \4 P2 }
<!-- 改变下的字体的大小。颜色-->9 \; j- n1 ^- r6 E( o* S
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. e2 c$ m" M0 y1 svar hidetimer='';7 n/ m3 D4 ^6 X) d3 R3 v
<!-- 改变下的弹跳速度-->( D4 p6 F: `( V0 G
var BallSpeed = 20;# v% m7 v! [4 L8 U* _
var contentWidth;, _: F: p4 L5 I! o; ?
var contentHeight;
7 d" I* m1 x# E* s8 Avar maxBallSpeed = 50;% o, w) I6 D! b( L

7 @, ], d9 r! g# A1 k3 ?0 F
, o( f* D- k- H* _3 ^3 Z. E% bvar xMax;
& i, A% U, h0 C# z% a- i; w# s) f. cvar yMax;
4 O. e1 E3 ~. I& Svar xPos = 0;
5 v2 O+ [. {4 |  r* {: c. fvar yPos = 0;
' P, O- V3 H$ X3 x% [; L) Zvar xDir = 'right';$ M& X- G0 `* `2 x7 m" g
var yDir = 'down';5 r$ z3 Q- U; \' r" n9 r; H/ J
var superballRunning = true;
8 l" w+ S* J7 R0 w3 Ivar tempBallSpeed;
& D, a* \9 ^9 Fvar currentBallSrc;
! O3 `) Q0 w2 f3 C+ \  g. bvar newXDir;
- G: m8 R* y7 C$ G) mvar newYDir;2 V4 o4 P- `: V+ L
6 X6 {+ P5 J8 [5 h& `
function initializeBall() {4 G& C& N- N; Q) T& Z! b- x6 P0 }$ E
   if (document.all) {3 N. w5 T4 ~0 |
      xMax = document.body.clientWidth
6 t  |- ~( R( T' q/ O# j0 w      yMax = document.body.clientHeight
2 f. s, c( a' b7 S) C  X      document.all("supertext").style.visibility = "visible";4 G# E8 p) g2 e+ N" w3 A8 x
      contentWidth=supertext.offsetWidth/ K! v) r% ~* I
      contentHeight=supertext.offsetHeight. d8 g& v% D( k% M: K
      }
! B' ^  F6 x4 L1 d& R8 Y9 j$ q* Q7 _   else if (document.layers) {. o2 L* w9 Q! @! W
      xMax = window.innerWidth;4 G& B9 Y4 x. V* g. l
      yMax = window.innerHeight;, b' D: e6 u& k$ |5 A/ ]
      contentWidth=document.supertext.document.width
/ a& T% ?' A$ j0 }! `% q; `, G      contentHeight=document.supertext.document.height* ^4 ^1 w9 l" A2 f
      document.layers["supertext"].visibility = "show";
# D1 r; b9 u8 z0 A( K      }
5 ]+ p/ i9 b' L, j! l   setTimeout('moveBall()',400);
. H8 Q8 B- {- W- P& l8 I. q   if (hidetimer!='')+ X$ j, {  O0 b' \% Y) }; d  G6 R
   setTimeout("hidetext()",hidetimer)
& A. v; l& f' c/ j. a8 H   }; B; |8 U. R$ d

+ V2 N. h( l* sfunction moveBall() {
5 E1 P9 E/ s7 _   if (superballRunning == true) {
7 b1 B" z; }1 a. x2 Y1 g      calculatePosition();9 g# V( v4 \% h4 K5 E. ?* d6 ~& w1 K
      if (document.all) {8 ]( r# R- k/ u; J* E  T
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. M) c8 K; Y" m  K/ m         document.all("supertext").style.top = yPos + document.body.scrollTop;7 [5 v+ M+ `+ u7 o
         }( c5 I' N) a  s" g' `0 ~
      else if (document.layers) {
8 ?* ?# L0 {; H8 R) t" U         document.layers["supertext"].left = xPos + pageXOffset;$ e5 V' e+ X4 x8 N9 \
         document.layers["supertext"].top = yPos + pageYOffset;
0 X3 M' A1 Z4 |0 D! b         }9 s; l) D- ]$ X2 `2 N
      animatetext=setTimeout('moveBall()',20);  d5 R  d" j* Q6 M
      }
8 ?3 j7 j9 e# G   }1 |5 Y0 p9 ^' N' g

/ b8 V5 ?+ P( o( P2 ~+ p! mfunction calculatePosition() {
4 [1 h* j, a% d3 r8 l   if (xDir == "right") {
; l% g: U& H0 n( _0 G& M! d+ L      if (xPos > (xMax - contentWidth - BallSpeed)) {7 f/ R* h! p2 V
         xDir = "left";' |, u% I# l. I5 ~
         }
! d' w: a, \6 |  C* |1 _) T! Q/ V      }
% |0 {. O0 S( w& u& [' b# k   else if (xDir == "left") {% m6 J8 ]) }; o* |/ [! A, w
      if (xPos < (0 + BallSpeed)) {
7 |: K9 [: N) T2 R+ u9 A         xDir = "right";
0 x6 e0 @/ y3 n. N8 u         }6 J; s7 |: K! X9 K1 f  O3 X
      }
! `; n& N! s2 z; x% Q   if (yDir == "down") {; K0 a$ U% I0 |# q. L6 z
      if (yPos > (yMax - contentHeight - BallSpeed)) {% X8 X+ ^1 J+ V6 c/ j) r4 S/ `: z: M
         yDir = "up";7 G% l6 O* B5 a, p. w* H
         }. V6 g5 O: j2 ?0 a
      }) G; ]; t* ?2 M8 i1 c5 ?, A# Y( a
   else if (yDir == "up") {# \* r0 \% N) J# k
      if (yPos < (0 + BallSpeed)) {
/ I# m4 a: F! u1 z5 S3 k         yDir = "down";
+ a! q4 N5 K; ^: u% E5 y         }* N/ o3 K8 m6 s
      }
' G0 {" P" W; q   if (xDir == "right") {
5 Z5 Y- @( a) t9 @9 m$ w      xPos = xPos + BallSpeed;2 I9 i3 ]: o9 C0 ]$ ~7 `$ k
      }' H4 g3 P( x0 P, V2 T5 K2 w
   else if (xDir == "left") {
% G8 `% e6 s& `( _3 J% x$ M; X      xPos = xPos - BallSpeed;
" I0 ]- t9 E* J      }+ E# O/ M5 B7 f" b
   else {
8 R7 L; b8 i; p# {3 }      xPos = xPos;9 ~, F8 H' @3 T" z. V
      }
7 h0 {/ f5 S5 a" q   if (yDir == "down") {
+ B6 J8 M8 B  V% }* n      yPos = yPos + BallSpeed;, N+ {0 L) N4 d! Q: s) x
      }$ w8 I0 r9 F  }# @; f
   else if (yDir == "up") {2 v" c, b; q9 _, c
      yPos = yPos - BallSpeed;
$ ~# T$ b2 O! H$ B      }
7 Q& d3 g* k/ M0 \8 m; Y   else {0 o: g" ^' x0 _# L' Q
      yPos = yPos;0 c% ~5 v: D$ h, Z: ~3 Y
      }; Q/ Y; o4 R/ K8 M. E: ]
   }
- F% }* u# W" u. @5 P
% G6 \+ M5 O6 o5 A: B* O: Zfunction hidetext(){
6 }9 k7 w) L# h, W0 Y7 R+ Zif (document.all)6 c9 {" O/ ^) `2 ?+ S0 c
supertext.style.visibility="hidden"- E+ r) N5 M5 i8 m/ f# w; M
else if (document.layers)
: K  }; ]; J0 G5 F. fdocument.supertext.visibility="hide"  A$ x& p$ @  O
clearTimeout(animatetext)
0 ^" ~6 u6 N9 }' E}& c3 E# {9 R9 d

6 f  Q) u; X+ _8 i/ S3 P1 T1 Eif (document.all||document.layers){+ Z2 m4 A- p9 V# [
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')% ^$ U' i5 H" R; L! }
window.onload = initializeBall;
* W0 o7 M& n' h9 f2 t4 t/ twindow.onresize = new Function("window.location.reload()");
. X  G6 g5 B, ^  _7 u$ W3 F}
$ H; }4 s/ V; ?! R
9 {0 J0 c, f6 ]& B/ z1 g3 s</script>

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