返回列表 发帖

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

<style type="text/css">% @' t1 F1 A% x7 n  k4 \  T( F
#supertext {
5 s5 j& c+ Z0 Pposition:absolute;2 M+ }. K, G% j+ d0 B' K
left:0;
' G6 B' a( p; a) O2 ^2 Rtop:0;
( n+ l1 }+ d  \visibility:hide;
8 M, q! [% U6 T& j2 H7 ~visibility:hidden;3 L& _9 s! y/ z
}
( W3 V% y) l/ J7 F& j</style>. k! p# \  J' P  G! A9 H
<script language="JavaScript1.2">
9 h" d7 r; t/ P! V, r8 E( g3 F: G<!-- 改变下的字体的大小。颜色-->
$ k( N9 i4 }2 m! i# h+ dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. q; T" j3 l0 z- Y/ A- Z! F
var hidetimer='';
9 f; U( G( Q3 c, G" g<!-- 改变下的弹跳速度-->
9 I2 Y( V$ y4 L. ?3 c) {  Svar BallSpeed = 20;
/ A' d; j( N6 D& g1 P  x' Q& bvar contentWidth;
4 ]( P) B6 a) V7 L2 @var contentHeight;
+ h; i  N% l3 X. ?var maxBallSpeed = 50;& {  I7 {2 U0 H3 ^& x

; x% m' _- V% c: p, R4 K* z& @3 n- W
var xMax;
' e0 Q$ b3 w! w" L& V( S% T0 ~var yMax;
+ r% m% C: Y, c% v1 ?var xPos = 0;
4 `& Q0 q% Q. _& _5 m. ~var yPos = 0;! j2 V" O  b; r/ P8 U; }( L( n
var xDir = 'right';, w- K+ \7 e8 Y* @4 n% L
var yDir = 'down';
0 \9 u3 j, Z& S7 hvar superballRunning = true;5 ?( N# x# Y' ?+ q3 G7 w
var tempBallSpeed;
# y7 a! L" V% ]% |% i% u7 [: [var currentBallSrc;
+ R, F5 q* Z, c- Pvar newXDir;
: c( N6 D. B7 Svar newYDir;
& X) z. j( x3 i7 h$ v
5 k- w$ K8 r& w% E% Nfunction initializeBall() {& |3 Q3 g8 e3 t
   if (document.all) {
% M" L! u% B$ f8 T      xMax = document.body.clientWidth  h0 q$ t9 m+ ?0 Y( |' \( j
      yMax = document.body.clientHeight
- a0 W5 ]- N7 d      document.all("supertext").style.visibility = "visible";
" M; x9 d* [+ X  q8 t( [      contentWidth=supertext.offsetWidth
/ w5 t. r$ K. Q* s; a1 m; z      contentHeight=supertext.offsetHeight& A" O& H9 F& ~, K, f
      }9 G/ ^0 D; U2 \6 k+ x! r
   else if (document.layers) {
5 {: r; Y% o# ^# Z      xMax = window.innerWidth;, n  Z3 y" E  }( U( |! K; ~
      yMax = window.innerHeight;
% |! C$ x6 d5 X# d' _/ L      contentWidth=document.supertext.document.width7 v/ F# p0 r" X
      contentHeight=document.supertext.document.height
% p1 l# b# v) V      document.layers["supertext"].visibility = "show";
* J! j- e0 z  i9 O0 H/ I      }4 ?1 M: }" w0 r& V5 F) O* e; `3 R
   setTimeout('moveBall()',400);$ F) ]1 l% ~& k& |+ X
   if (hidetimer!='')
- y$ _5 W+ G( K   setTimeout("hidetext()",hidetimer)
9 G/ Q+ {/ l: s2 q$ ?   }
. F. v3 `* ^' Q+ b. w* E# a! ~1 X. S8 ^/ B+ o: s3 h
function moveBall() {  @6 V) f8 B3 P9 u4 g
   if (superballRunning == true) {
2 d( y" t3 N3 J7 o( B0 B% O4 n( M6 I      calculatePosition();
; T- ]5 [& _  `' E) T- |      if (document.all) {
9 h% E% j, W2 ?6 k; |         document.all("supertext").style.left = xPos + document.body.scrollLeft;4 K# y& E. F9 }* A7 l/ u$ U+ e
         document.all("supertext").style.top = yPos + document.body.scrollTop;1 u" v% X+ v% f" U
         }- t0 b# b7 s  f; F' b, _
      else if (document.layers) {) H2 |  V5 t5 c, F
         document.layers["supertext"].left = xPos + pageXOffset;
+ e8 K  E& l& A" i+ |4 H6 A3 s         document.layers["supertext"].top = yPos + pageYOffset;/ D+ R& M, }; @! D
         }
/ G1 [1 w+ ^6 ], l      animatetext=setTimeout('moveBall()',20);
* ^0 v+ ^" r5 n0 i7 A% F      }' E/ N2 C- V4 x: }
   }: s' f0 e' c2 I; X+ W

7 H9 C$ B& P6 |function calculatePosition() {6 B  V5 O" g/ z- |: N, L0 v# F! q
   if (xDir == "right") {
+ D$ x. S- a! ?9 v4 v' E      if (xPos > (xMax - contentWidth - BallSpeed)) {. I# ~6 y5 ^$ }& {
         xDir = "left";
. \3 U( x  P  ^" s1 m         }9 F  Z& X" Q- Q; Q" Y
      }
+ u3 r) j9 D# T. `7 m   else if (xDir == "left") {6 P6 d* M; u; ^$ x% `
      if (xPos < (0 + BallSpeed)) {
+ e% K+ T$ r+ q/ P9 q% @         xDir = "right";
6 M$ u( N7 N! i         }% \/ g( C- W, e) I& J
      }7 h9 N" r" w8 p6 ~' I# t" J  v
   if (yDir == "down") {
% g) I# [: f) K/ Y4 V/ Y  b" ^      if (yPos > (yMax - contentHeight - BallSpeed)) {" y0 n+ h0 G7 ~7 W( r2 E# q- n
         yDir = "up";
" j. O! W/ x2 P) d- ~" L0 H$ O         }0 m8 T- A3 m3 S9 c4 _6 Z
      }
2 L: c$ d  _& M% _, H; W   else if (yDir == "up") {
! w2 _1 E" W' ]0 @& }4 q      if (yPos < (0 + BallSpeed)) {
8 J; _3 ~# j2 x         yDir = "down";& W( g1 K/ p& U- h
         }
+ W$ Y6 S" i+ |9 P8 J& V9 d      }
, \# `2 [' q. ?: S   if (xDir == "right") {
8 Q1 G- S5 W# t" Y' Q      xPos = xPos + BallSpeed;
+ Y* F6 B: E9 O! r; f      }$ y; g2 i% n6 ?+ K, N
   else if (xDir == "left") {2 l: s; B* p' o8 A5 z
      xPos = xPos - BallSpeed;% J7 u" D) t# w) s; i# x+ _
      }
5 R1 n8 G- N6 d# s   else {
1 Z* U' M( K7 b- J) ~      xPos = xPos;
5 _" g. F1 x5 o; n% ]* `$ s$ V      }
3 Q' z- a- i. _' H( ~8 U   if (yDir == "down") {$ t* E$ }( @% }$ C) }. z: Y
      yPos = yPos + BallSpeed;
: b1 [. ^( a# m7 [% X$ j6 k      }" i- v% q# H6 `
   else if (yDir == "up") {; M9 `2 T6 d# A# i/ [' y& c
      yPos = yPos - BallSpeed;
0 p. `' Y5 i2 R6 @) ]      }
4 J& v  B2 N% |0 j  k2 A5 T# ~   else {' P' e! Z" J  b  \2 c) K
      yPos = yPos;/ A" L( g8 v( L
      }! H$ m- Z7 R3 V0 o( Z5 V5 c: h
   }
" i$ p, J3 j0 u* q- U6 T, u6 ~5 [1 o4 ^$ _( j& p
function hidetext(){
  q/ e% [7 T: p" S7 s7 qif (document.all)
6 W+ A6 x9 e6 t% C3 S& P! W! o- B- dsupertext.style.visibility="hidden"
( ~8 V) f! g0 t# }0 welse if (document.layers)
' a5 @! o9 Y9 \2 _  d, Xdocument.supertext.visibility="hide") r/ ?+ x$ h0 {: V
clearTimeout(animatetext), Z1 R, z! ]6 k0 ^0 H% r( K0 m. A
}
' y# F" j2 }. V8 F. ~2 x) S
5 y" b; O  e4 h: X# O6 [if (document.all||document.layers){! l8 L- y0 v# n6 ]) ~" ]
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'); T5 X% h: Z' C1 }6 m0 R# p
window.onload = initializeBall;4 V+ b. v/ R, |7 M
window.onresize = new Function("window.location.reload()");8 A( G# s" b* W9 E% X
}
3 A1 T" I) a) X" j# r3 @5 L
$ c# L% A, [( t# l9 F. q' X</script>

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