返回列表 发帖

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

<style type="text/css">. G' r; a  Z. w) O* L( r
#supertext {) y$ ~+ @0 s6 A/ q
position:absolute;. _! c0 I4 n( g$ c! E" P3 W2 a
left:0;
* D6 b* S) \5 Jtop:0;4 ?' _: H6 c% q  @& j
visibility:hide;, u' R. z5 R  z8 Z
visibility:hidden;" y( q0 X5 T( G0 U7 _( s8 G
}
3 o! R1 @5 [; [</style>
  U' W& G) A9 d: ~% l% t1 y<script language="JavaScript1.2">
! A) }/ G5 g8 ?' `8 n<!-- 改变下的字体的大小。颜色-->
$ H, D! d% j" R5 b, `var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 @& r: n+ O6 M* {& Wvar hidetimer='';1 l1 L) @/ v7 V' d  L" s
<!-- 改变下的弹跳速度-->
" y7 |1 o3 D( u. ?0 |- Mvar BallSpeed = 20;
3 B  n# }* \5 fvar contentWidth;
7 ?3 W! G; `  g" d1 Svar contentHeight;; r& s: R" d' \& W% ]1 e
var maxBallSpeed = 50;. ~# l2 k+ J% q$ M& k7 Y

/ Z0 w. U  l. i: |5 H, c- p2 \5 t% y8 L8 J  M0 [0 ?0 m
var xMax;1 M# Z$ \6 i$ Q0 k4 v4 o8 |
var yMax;
7 j) ?( @% u8 Xvar xPos = 0;& \1 A" f( b9 J3 ^, c
var yPos = 0;
; N( ^) I4 Y5 y$ S) _$ Wvar xDir = 'right';
3 y  _* Z7 d- A  G9 Cvar yDir = 'down';8 m: [  i8 ?. l+ M6 c1 F
var superballRunning = true;  Y$ K3 R6 s0 i
var tempBallSpeed;: V7 y5 d4 v# M+ L( I; A
var currentBallSrc;
6 F% ]. o* p. T0 \" Zvar newXDir;
. ~1 ?, {5 i. s' a$ w) D4 ?var newYDir;4 y0 o: ]6 F- \3 C; j* g
6 B9 Y; J+ S2 D/ i" F& a/ N8 [  b3 x
function initializeBall() {
: l8 q! H4 Z0 @0 {   if (document.all) {+ @& R; i7 s0 g! M' k4 m
      xMax = document.body.clientWidth2 H2 i" Y" F5 V( O2 |# w# X; M% j
      yMax = document.body.clientHeight
, O" h- H# w, N      document.all("supertext").style.visibility = "visible";
( M# G! J8 k1 @/ Q0 a      contentWidth=supertext.offsetWidth5 Y# ?2 v' G3 _) }
      contentHeight=supertext.offsetHeight5 L: q# W7 R5 y5 v1 E( g' m- g
      }+ x# Y2 V& ~5 d5 ?4 W  ?5 q, Z
   else if (document.layers) {1 |: y" ?8 Q( ~7 D: f0 k0 Y6 e6 `
      xMax = window.innerWidth;
: X1 F( v* t$ j% S      yMax = window.innerHeight;: H, e7 J2 Y% ~1 K2 K0 D
      contentWidth=document.supertext.document.width8 L, l3 B5 a) p- Y: ^: I
      contentHeight=document.supertext.document.height
7 T' n7 C7 G# @) }      document.layers["supertext"].visibility = "show";
9 b; E$ C* a) N  E      }
9 e3 k8 D6 y, V6 s( J; |, D   setTimeout('moveBall()',400);5 e, a7 s! ~  X0 Z( l" {3 Q. D
   if (hidetimer!='')8 c6 `: P/ x5 ~0 g! ^+ V
   setTimeout("hidetext()",hidetimer)
0 p, U& _4 C3 s. E2 X5 {; v) [   }
( \3 t0 C$ J2 `: t! y6 E, T8 j* X% q# ?  n, }& E. w* V2 s
function moveBall() {" V  ?0 j6 E3 p
   if (superballRunning == true) {
7 H' ]* |/ l; a+ @      calculatePosition();
" ^4 Y, A) D! D$ P- ?% w6 h& k      if (document.all) {1 P# r3 j/ K: W, s2 ^
         document.all("supertext").style.left = xPos + document.body.scrollLeft;( `! p2 ~7 `( p1 g- X5 s$ v' q
         document.all("supertext").style.top = yPos + document.body.scrollTop;" B. Z6 p# G9 s% {" U
         }9 N$ ]1 R) z6 O- x
      else if (document.layers) {
9 K" \. v  t7 n8 T' ?% Q6 R( u1 [         document.layers["supertext"].left = xPos + pageXOffset;6 u& l  w3 y2 q9 T; P
         document.layers["supertext"].top = yPos + pageYOffset;
$ p" v* b- [& i9 q8 t. W' n' b' |         }4 o2 M) t( ^% `# S& s$ _8 t4 Z
      animatetext=setTimeout('moveBall()',20);
* u7 F+ M& j8 I( g& ?3 N      }
& }; i2 h0 C' n& i6 Y' @; F* d   }
# f1 j$ x/ Y5 B
/ G/ d% y  M' L$ V# Ufunction calculatePosition() {
$ Q' I4 d2 i7 M  x   if (xDir == "right") {
6 M+ Y1 S2 p$ e2 Y      if (xPos > (xMax - contentWidth - BallSpeed)) {
; v+ \1 y" L+ n: S  B- a) W# A         xDir = "left";! q7 r4 l4 @' s/ u1 ]+ _5 S3 N: F5 W! U
         }
2 ^+ s/ J5 v2 x$ M/ Q7 c$ P      }
7 a) ^2 K2 r" m4 ^6 x& t   else if (xDir == "left") {
4 @( j+ X& o3 e$ v3 g) y- N9 O3 O      if (xPos < (0 + BallSpeed)) {
! v+ t" g# O( b/ G8 o' }         xDir = "right";: B5 l9 G! B/ U6 K3 X
         }' m7 m: w; R! |$ C; p  t) N
      }5 |% S. T/ `9 y/ B
   if (yDir == "down") {
6 e# d" I; {& W7 I+ P, J& x% n      if (yPos > (yMax - contentHeight - BallSpeed)) {, a. |: X, T0 d. y8 ^
         yDir = "up";
' i5 o1 q* Y4 o( A% J- i( `         }/ Q) o) j. A; ]5 _
      }
( w9 D2 Z) w% i& M; B5 ^9 b   else if (yDir == "up") {) g* |" {# \% t8 _
      if (yPos < (0 + BallSpeed)) {7 H) F- K. G6 h3 T
         yDir = "down";
' T2 d4 X! [1 e( I7 _         }
6 `6 ^& T0 C0 c: L      }% I* v) T1 q8 r3 P
   if (xDir == "right") {# u" n, q3 Z" P8 V* X4 h( |5 V
      xPos = xPos + BallSpeed;
& d+ v, G! B2 g8 V+ c3 g8 [( S9 M      }* X* j" C' U9 F: f4 q
   else if (xDir == "left") {, U' H, t( d: x8 @8 J0 s- M5 T& c
      xPos = xPos - BallSpeed;- S6 W9 o" u, f1 c2 c- _$ y, p
      }
# n7 ]3 |; h, a  j4 E   else {
3 E& U6 u" E3 h- H2 q      xPos = xPos;* r2 k1 K) b9 w6 I7 X" J' k
      }5 D$ S( i7 s' U; W1 I+ O7 U
   if (yDir == "down") {
$ V* l  t' O* T8 l# u5 k  ]1 U      yPos = yPos + BallSpeed;; \& }! \' j' q$ L1 L: F
      }
( `+ o) O8 n# i8 n! r  |6 V   else if (yDir == "up") {
: W1 X1 Z7 I1 t3 L' j9 B0 k      yPos = yPos - BallSpeed;  j( B0 `; O8 G5 q7 y# [
      }
! ]  |/ \$ u7 d( P2 e   else {  {8 Y) j6 v1 z) K" L
      yPos = yPos;. w$ v0 _$ U+ D# j8 _
      }
* ^9 Q# `; }5 `+ }2 q9 K   }
) S1 h) z" i& }9 l
9 S( B6 L( k9 w7 e1 dfunction hidetext(){6 _. n9 c! c4 w. L5 m2 W
if (document.all)+ o, K" f0 J3 S: Z
supertext.style.visibility="hidden"
- t9 U# j, ]8 Delse if (document.layers). V# `" C8 y1 i: T* \# O" Q; E; p3 F
document.supertext.visibility="hide"/ x3 U! m% `8 _
clearTimeout(animatetext)7 s- G+ I/ P5 Z, q4 X# P% t. q. A" r
}5 w  `- ^  h& `$ W- I* o

0 o( t- X& F* b) b  J) W# iif (document.all||document.layers){- P) g4 Q! y% c
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')5 l* M% h/ K, `! n: V9 \
window.onload = initializeBall;
, H( [; x. J% i% T/ S) m8 Hwindow.onresize = new Function("window.location.reload()");. D( a7 T2 X0 W# f
}
4 T( m' H2 @! c( W5 O  s
5 O0 c! l% M1 c( ^. S. A; J</script>

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