返回列表 发帖

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

<style type="text/css">) R- @9 @) h" R' q# s% t# x
#supertext {
6 J' y; I- d/ J- g1 Kposition:absolute;
* Q+ X- q" ?1 q* F, X& C- Tleft:0;
9 ~, j5 n+ G9 I) ^top:0;% e9 g: _  l- M
visibility:hide;
& r: _( H  n& s' l% {2 v, @* c, Zvisibility:hidden;* S8 N# T/ l0 h5 T
}8 L( Q/ w6 k& K( I: {
</style>
2 d2 K- r, N9 S8 p  W<script language="JavaScript1.2">
  J! x1 r) L8 Q% Q<!-- 改变下的字体的大小。颜色-->
" R( X: k1 ]) v8 N; s+ M2 Ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 ?; l" F9 ~, W  E8 ]( |) [3 @7 D" Rvar hidetimer='';4 X! X% {/ ~" @9 x
<!-- 改变下的弹跳速度-->
" o9 g7 L; w/ Q( e8 }' t0 evar BallSpeed = 20;* l0 N( g( d/ ]& `
var contentWidth;
+ X, i$ a/ \8 g: @var contentHeight;
4 d/ ?; O1 a( G7 F1 w7 v+ vvar maxBallSpeed = 50;
, O7 }% {9 J+ K+ v! E. ?+ H5 X. X+ O6 T$ V+ ]% A

0 _$ w: H& \9 M7 B) Dvar xMax;
" h/ c+ I; v: e' ~6 Rvar yMax;+ l1 a; e! U& ]( k' a/ U6 H& j" P8 a: g
var xPos = 0;
/ f% K7 Z% o$ y( f0 q  }. {var yPos = 0;
6 f3 o: U# |/ i, n) Tvar xDir = 'right';& Z1 S: a7 E' a; o
var yDir = 'down';' B# p  n3 Y  k; k6 W8 ?3 w0 ]" p
var superballRunning = true;0 O# U9 X1 z( X) g- W' N
var tempBallSpeed;
$ Z3 `( L6 N% l2 \0 a: h2 `% Cvar currentBallSrc;
, P4 N9 z/ E5 v, S" R8 ]var newXDir;
" Y/ S7 Q; Z" uvar newYDir;$ X* R) I/ n& b5 t6 m" Q
7 R& i7 k# k0 B: |2 l* ?
function initializeBall() {) `' d; P' ]6 n, d: ~/ B+ ?9 M4 m
   if (document.all) {. R$ X8 f/ a! A, U; H: ~
      xMax = document.body.clientWidth
, s. U2 H% E( E$ \      yMax = document.body.clientHeight
0 c' E6 A6 a; s: W. X1 h0 W3 |      document.all("supertext").style.visibility = "visible";
/ Q" b7 o$ |2 s, m7 u; r/ B      contentWidth=supertext.offsetWidth
8 V4 t% H0 o8 r5 ]1 Z( n( n' v# y- T8 L      contentHeight=supertext.offsetHeight
& s$ H- w  o( T      }2 ^  C, e4 D6 V& L5 l9 J
   else if (document.layers) {
9 i) ~! D3 w! n5 g/ V# z+ X      xMax = window.innerWidth;
! e" _* ~6 x: p      yMax = window.innerHeight;
( H/ T8 k1 u4 }      contentWidth=document.supertext.document.width) N3 S8 J' f' a1 Y) u( m+ H1 Y
      contentHeight=document.supertext.document.height
( h( J4 r' k3 Y( ]" q2 [6 |      document.layers["supertext"].visibility = "show";% K4 \5 k) \+ y; p% J, U  h
      }. g7 g4 {- m. ]) s  }9 [6 i
   setTimeout('moveBall()',400);8 Z' o. W' K" r, z$ G
   if (hidetimer!='')9 C- ^( L9 w/ ?
   setTimeout("hidetext()",hidetimer)# h0 }' Z$ V; f6 t8 p
   }7 _- _" M& [9 D5 h( s
* ~7 r. Z$ g& u0 [
function moveBall() {
3 N  L7 q$ S. W6 g; K' B: p   if (superballRunning == true) {3 @+ G3 o7 e" c+ @, ?, Q6 k
      calculatePosition();# {- T. D9 l. ^$ f
      if (document.all) {2 c' @$ \3 ~( C. V8 p6 \* U; P: t
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
: M, |. g% j' h- Y$ x$ b- Q         document.all("supertext").style.top = yPos + document.body.scrollTop;
" e7 v; D/ R- `# o2 h) G         }# o4 D3 P* C9 n: P7 C+ u7 M
      else if (document.layers) {
% O2 A. Y5 n* M% y2 S         document.layers["supertext"].left = xPos + pageXOffset;
, ]/ e: W4 s9 Y- l' R/ O         document.layers["supertext"].top = yPos + pageYOffset;9 n5 }' R% C' ]# u, j* X  g% ^
         }- ]# ^6 ]8 F# e# K
      animatetext=setTimeout('moveBall()',20);5 e( B. a- [0 [. n; L
      }, j" f3 y2 g0 L  a7 `) C  i! @5 S6 R  @
   }" Y7 h2 H0 r, o; l7 H

. r. m: k  Z$ N7 o3 z& T! _function calculatePosition() {
$ W8 |# Z* }- b: I3 W4 F   if (xDir == "right") {! B; T* V3 t+ K, d4 I% J7 h
      if (xPos > (xMax - contentWidth - BallSpeed)) {& Q$ A7 G& n) }7 X5 {
         xDir = "left";
1 R( j* F  O% I6 i6 ~: D! m7 R         }/ u1 ~$ r$ D# c( \- A& E
      }
' R- q8 T! S1 N7 y& E5 m+ x- @   else if (xDir == "left") {
6 [6 |% i# y/ @4 G      if (xPos < (0 + BallSpeed)) {' `, u2 c. o2 i# D# Q2 P: b
         xDir = "right";
) A& p& u( A8 [' P: F7 s; y         }5 z8 n* y- k3 c2 T, D
      }0 C7 o6 m% E2 A  e7 u; h! t
   if (yDir == "down") {
) f# Z- d4 t% r/ f' l7 y7 }# ]      if (yPos > (yMax - contentHeight - BallSpeed)) {% D" ?; v% o: s, ]$ k$ l
         yDir = "up";) V( U& B2 I% O& O  l0 j
         }
9 s/ H/ M' Z" i# j1 Q7 y! g+ W      }+ d9 b( C7 r+ j3 _9 U
   else if (yDir == "up") {( X) r, m8 g% z) V3 m
      if (yPos < (0 + BallSpeed)) {! c' Z& }0 o0 P' [* b  [1 N
         yDir = "down";
6 {( F- J2 O! M  j% E6 i  A         }0 u* \6 C, K+ N# p5 K" ]0 k2 _& o
      }7 J) I/ E4 \' V  C9 k
   if (xDir == "right") {7 }5 `+ Z/ D- j3 _) ]! r! Z
      xPos = xPos + BallSpeed;
+ S  u( r9 O0 v2 |      }9 u$ m7 d8 W8 r5 O7 d
   else if (xDir == "left") {
7 m: J' N+ M) r% H  p+ K& Y! b8 m0 B      xPos = xPos - BallSpeed;
1 w6 }) ]  L$ b7 b, h. j3 n      }
9 T& _% U3 q! T5 F7 b   else {' I8 y0 n3 B/ e5 q# V3 M
      xPos = xPos;
9 B/ |- g( N- `7 I      }7 ~/ p3 \3 x" J5 L+ ~+ I3 ]1 a% I
   if (yDir == "down") {
* y6 O0 a: u6 `4 E0 P) s9 z      yPos = yPos + BallSpeed;) K/ L7 X0 h! m9 B  Z% p! l  ^; H
      }
7 y% G  M* D0 _* u2 ?   else if (yDir == "up") {2 [. U& j  b; X% S% ]
      yPos = yPos - BallSpeed;1 h  K( y5 ?4 H" z( n8 V5 n4 E
      }
6 K, R6 @0 H, f2 l: A6 R& i9 W   else {' d' g% e$ h* [& y
      yPos = yPos;
# f) J0 |; @( e/ ]1 O      }" {  A$ B3 h4 u. G) `' Q7 J1 Q# g0 @
   }
+ {: q( L4 c4 Y: x
3 d- k) z- R& _+ Cfunction hidetext(){
$ m& w: R) U) F1 R" _' S1 cif (document.all)
, X! w$ r1 E6 Y2 O1 Qsupertext.style.visibility="hidden"
* K, ]9 h) R, @, f7 Yelse if (document.layers)5 C: |- {2 c; u0 U, d) i8 J/ L
document.supertext.visibility="hide"
% S- g/ v: l: C9 h( o  hclearTimeout(animatetext)  S9 X6 |0 z+ O6 q
}. o4 t: d" {# D9 S3 B3 S' Q7 A
" b* ]" U6 f* e# ^, j& Q
if (document.all||document.layers){
& p2 B8 @0 Z% K8 F- \! \: u4 [- Idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')" o/ G( B% Y4 p% C, K' U" {
window.onload = initializeBall;6 \& n9 y- P3 f+ ?, R: v, X4 i
window.onresize = new Function("window.location.reload()");
! c, U! Y+ Z5 p6 q: u}& Y8 ]) S: ?' |9 h! @" y

- e2 F6 ~7 a' S) i0 F</script>

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