返回列表 发帖

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

<style type="text/css">
; F& v0 T7 s1 B. x2 g#supertext {
9 D  u3 m& N: [$ Bposition:absolute;7 s  Z5 a0 Z2 y: z. p* z' T, F
left:0;4 l& x4 J" |+ r% X( ?
top:0;
8 Z' l* F! o) ?. |7 Y. D8 l% zvisibility:hide;* s. _7 r6 k) s& W' A4 B
visibility:hidden;6 q2 Z, |/ k% l
}* p) T; E  O+ C7 O
</style>
: {6 s) }* @2 l9 F1 P7 d( E9 e<script language="JavaScript1.2">& m; t6 K# A' ]1 ?
<!-- 改变下的字体的大小。颜色-->
5 L- E0 p, M, _2 F) l' ^/ pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'4 z0 G- u1 Q. |, o' X* r& G
var hidetimer='';5 F9 G: {$ D* c: t2 U) f
<!-- 改变下的弹跳速度-->% g2 N1 j6 M" m3 c( C
var BallSpeed = 20;
9 U$ y  y% Z+ n! r$ R* Cvar contentWidth;, z) N: `" a' ]; A6 m
var contentHeight;# g8 T1 e: r5 N! {1 e* k
var maxBallSpeed = 50;
+ D8 U1 A5 K$ Y: a3 i8 n% a# r8 t) u  c4 @
2 j  A; C" R  U- ^9 c. E6 K
var xMax;
' r& ^( h# p3 n/ `6 b9 g. Avar yMax;
, P' c/ q% Q8 W* K* b; Evar xPos = 0;9 j2 \1 i; W0 T6 n
var yPos = 0;0 z) V$ U# D4 b( t9 c
var xDir = 'right';
! Y  l$ K5 |- zvar yDir = 'down';
& D0 U# G7 j/ w* Pvar superballRunning = true;) _4 H: F4 T: V$ ~, ]
var tempBallSpeed;
& p6 V0 M: {9 T! p+ ?var currentBallSrc;
% W1 P7 r/ m; B/ b5 @, ivar newXDir;4 u0 h; n' F: r% Q+ o
var newYDir;
4 T, m8 N- d9 u9 }5 B$ Y1 n
9 X9 m* Z) ~# I4 vfunction initializeBall() {
: m$ k' I6 x0 ^% L! e: k0 ~   if (document.all) {
. v5 e$ ]" U" I3 t; G      xMax = document.body.clientWidth* f$ z# d+ X7 u- |9 a) [& W1 K- w9 I8 b
      yMax = document.body.clientHeight
2 v' r' I  g$ g+ T) U5 y& r      document.all("supertext").style.visibility = "visible";
5 e. n4 K) Y2 G, Q# J  R# p      contentWidth=supertext.offsetWidth
" c; z% `, b% \3 h% N6 e      contentHeight=supertext.offsetHeight
% T6 N1 C4 `) x4 Y      }
3 f; t7 C2 E7 ?   else if (document.layers) {
3 R1 V( e  A2 C; m: \+ @7 ^8 b      xMax = window.innerWidth;
4 |8 u% V7 K( {: @* p7 y      yMax = window.innerHeight;( i- n  g* N1 y+ z# m6 |- w* X
      contentWidth=document.supertext.document.width
' v* {& o' m6 h- `; l  w      contentHeight=document.supertext.document.height
  B1 g2 g4 g1 M. ~  w) r2 ^+ a      document.layers["supertext"].visibility = "show";
/ N& v% j2 m+ s0 @7 v      }5 p& d1 o- V9 ^5 q- k* }1 n
   setTimeout('moveBall()',400);
& g3 L, b/ i, j3 f   if (hidetimer!='')0 H1 X. I0 {. ?$ G! b' C' n
   setTimeout("hidetext()",hidetimer)
, L# Z, t, B, y' p; M   }* D0 s6 }$ j  u+ q: h
9 J, @, m  z$ j; V( H
function moveBall() {
2 A2 F' s2 C* T3 X- A7 w   if (superballRunning == true) {
" E. {7 f) R) H, q% ?      calculatePosition();3 h# u! y$ R% a. \) v
      if (document.all) {
; a# x) Q0 M. j1 d3 M8 r3 i+ _1 ]         document.all("supertext").style.left = xPos + document.body.scrollLeft;
, S' c! S1 B# _' ~- C/ x$ P         document.all("supertext").style.top = yPos + document.body.scrollTop;
6 ^" w0 X+ g2 k) @! ~         }  i' h6 y, S4 D
      else if (document.layers) {7 S6 P/ b5 V8 d6 S+ P* r, `8 K
         document.layers["supertext"].left = xPos + pageXOffset;
4 [- ?; J% L% [% D( }9 p         document.layers["supertext"].top = yPos + pageYOffset;
( C* Y! d; f! B. [, y: v         }
3 z8 W% v+ g: E" u8 @      animatetext=setTimeout('moveBall()',20);
' n8 m% J; i( s: p" p. e      }
0 p( x4 Z0 |, N; p3 b   }) ]0 s* f7 d" M  Q3 o8 R- Z

4 E  Q7 S0 w3 L) f8 I( [. j( z' @function calculatePosition() {0 S# ~" @, O% W; T, l" \
   if (xDir == "right") {/ f! U& V5 J1 Z( X0 H) G
      if (xPos > (xMax - contentWidth - BallSpeed)) {
/ H. Q$ Y! Y( }         xDir = "left";7 x) i# _% y; `4 O5 O' W8 _/ T
         }' n, d6 e: i2 O1 G8 H$ @. l
      }
2 B  ~! e7 g" |1 L: _5 t4 k   else if (xDir == "left") {
2 @' s3 ~/ t- ?1 s2 E* U. E  y      if (xPos < (0 + BallSpeed)) {
8 S3 d' b$ A- I$ R/ d$ m         xDir = "right";- V) W2 i8 l% O- B, G  C
         }
+ [! \5 Y/ Z: j8 n/ Y      }
- ^. v' o* S8 [2 T2 h   if (yDir == "down") {7 H4 b% ?- W9 H' d9 y$ o: k7 }+ L
      if (yPos > (yMax - contentHeight - BallSpeed)) {
3 h7 m/ X. O* P+ W) Z3 q! E         yDir = "up";: S5 p) q$ x2 ^6 Z0 I! h% `8 |
         }
. z: M- ~! t1 M; a$ N      }
' V( m2 W( E" M$ R9 ~   else if (yDir == "up") {9 t; j0 M; y& c8 V) w+ ~# T7 w" b
      if (yPos < (0 + BallSpeed)) {
7 v( W# M1 i" c7 l  m         yDir = "down";$ D5 \/ [/ m- v" a
         }- X: l$ E, }! ]$ P
      }
# \4 Q6 `2 }3 A6 a' r5 e   if (xDir == "right") {7 ]: p4 x" D4 c( T" F
      xPos = xPos + BallSpeed;* U9 u0 q- U! R, o, v! w
      }8 i9 f: V/ _& u" s
   else if (xDir == "left") {
" @! f) ~9 {0 _      xPos = xPos - BallSpeed;
  h( D6 I2 B0 \# @! R0 a! p      }# E' f3 a& Y0 _9 ~+ f0 A& A' R
   else {
# H4 l/ q& o( M: Y      xPos = xPos;$ s$ g7 N( i4 n2 R- m6 `' a
      }
4 U% {+ N' }; A% w  T1 Z0 W' X   if (yDir == "down") {: ?! K. \5 G# J8 Z6 G$ [& M9 |
      yPos = yPos + BallSpeed;
% e) `- S. ^% w8 N- F, s      }! c9 p. p! k# S% X" Q, S: G1 F
   else if (yDir == "up") {
1 |- {! ?4 t1 u8 J  Y, O) K. r% X      yPos = yPos - BallSpeed;; W+ N, D, @4 j  x! p1 y" |8 z
      }
2 b" [; H& l" H- {3 D  ^# ~/ S9 o   else {
. a5 H, Y& a; L      yPos = yPos;
8 a/ V2 @5 L" S, a$ Y( B      }1 t0 V- z( V3 o* m
   }
5 K6 r+ ?" }. e% j' N
5 R- h+ t& p' Y. R! mfunction hidetext(){* b- \& \5 R  n! a: F! I" B
if (document.all)+ K, H4 S( y4 A  i) O) K
supertext.style.visibility="hidden"% q5 D# W: I1 E2 R9 \
else if (document.layers)
0 @/ E5 N4 p' i& ]2 f' k2 ]+ Y2 R( H" Bdocument.supertext.visibility="hide"
- |! [! C+ ^( }$ \; zclearTimeout(animatetext)
( P3 u3 d7 l- c}
; H0 H; h" V/ i5 D- F* S2 k) z6 j* m
& q4 \( h& R  O! d5 C8 \: pif (document.all||document.layers){
4 N$ X7 y( S" n! b, qdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 M% \* _! c# t
window.onload = initializeBall;. I7 _! g3 I7 ^( L2 c) O+ `# y
window.onresize = new Function("window.location.reload()");
, f- F, i: A9 [' W' u1 r}; S, k& N0 v, T
6 d! b; x( R7 h: [1 L7 }
</script>

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