返回列表 发帖

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

<style type="text/css">8 }  f* Z: f. f" }  c
#supertext {; J( ~" c6 q! x5 A! m
position:absolute;3 F6 ^, c3 ]1 B$ Z  n! C
left:0;
& u* j# ~( j7 @: d' Dtop:0;$ E& d* J. U, A# F1 `2 G
visibility:hide;
2 r% s: Y2 [# q" X1 ivisibility:hidden;) Y% a+ F1 t( S( ?
}
' w9 y9 B- S0 `0 M0 J; m' @</style>
" O) A- x8 m' y/ L- [* O<script language="JavaScript1.2">" ~+ O/ c$ o& P1 C
<!-- 改变下的字体的大小。颜色-->: ?, i2 o' n* O: a& `' x) t) N" Y8 p% j
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 C% ~/ p! Q7 N! n; N' jvar hidetimer='';
6 q; _- G4 Z. z<!-- 改变下的弹跳速度-->/ X& z' q9 P) F9 m  R1 L, M
var BallSpeed = 20;
2 Z8 j1 f2 w0 c* U; z5 qvar contentWidth;
& ]5 s/ F% `' r% K7 k/ w5 E0 Rvar contentHeight;
! l  H4 Z* n4 @( |9 I  cvar maxBallSpeed = 50;
8 Z  k8 E# H5 Y$ Q, \# s! N3 a; \" p; w* w9 W" S

* y, b% A( j, S. |) _/ uvar xMax;3 D( L& r7 ^/ p1 [8 Y
var yMax;
# K) H. b2 _1 I/ H! P) c, jvar xPos = 0;4 Z! t; d: Y6 U* n' u0 G# Q/ a/ h
var yPos = 0;  N7 S. p" i, q# _" R6 I
var xDir = 'right';- F+ T7 D9 {2 @, ~, p# n
var yDir = 'down';
3 G" H# \: {( Hvar superballRunning = true;
0 S: n) `" g" ]) G/ Yvar tempBallSpeed;
9 _9 ~1 z7 a! H8 G6 Q, y# q( Cvar currentBallSrc;
. m# B2 z5 Z1 B- }var newXDir;
+ S8 N* o" q4 q: {5 b, H9 }var newYDir;
* p2 i7 V  o0 G: m* O: k1 q1 G. W3 V, x! F/ i$ m
function initializeBall() {! |  o5 {: S  a9 k6 K9 R3 R
   if (document.all) {
7 _$ G- J; g) l      xMax = document.body.clientWidth
  J( m- c' T* B# v+ P      yMax = document.body.clientHeight: n5 X( m# W% _. y9 m
      document.all("supertext").style.visibility = "visible";$ j' @3 G- Q/ k) \' t. L. J6 {  z
      contentWidth=supertext.offsetWidth
3 r/ _. J& P9 m+ ~$ F      contentHeight=supertext.offsetHeight
+ Z, g9 f8 x, e% u      }* A5 `7 F& G) g5 O; S/ C
   else if (document.layers) {  j+ X8 E- ^5 T
      xMax = window.innerWidth;, L/ \' j% S" ^9 z. a$ `1 o
      yMax = window.innerHeight;
, h( C" g( r( |& _; [$ H% E5 b, \' i      contentWidth=document.supertext.document.width
* i* r. m0 X( E/ x      contentHeight=document.supertext.document.height8 [& ^1 X- |' Y: y( U" D5 L
      document.layers["supertext"].visibility = "show";
, P1 ]( e& q  \      }
, T/ f4 ^* a2 W6 `, y   setTimeout('moveBall()',400);
, D6 X5 A$ C4 V$ L% r   if (hidetimer!='')
( V1 t, ^: A( J7 `   setTimeout("hidetext()",hidetimer)
" e4 b6 ?4 W; S, g4 I   }# _. @, C2 B7 n, n7 l5 E

8 I1 u, [" k: E1 R, W% N: J# Gfunction moveBall() {- s* c* B8 h9 c4 X& F2 b: M# P# X
   if (superballRunning == true) {
9 N% f& f. k2 i/ y5 m      calculatePosition();0 }0 A4 o& L$ `* q4 ]* ^: y
      if (document.all) {) A' I0 }, b/ q1 Y. ~
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
- P# ~7 @4 z* ]  W! M3 \& R         document.all("supertext").style.top = yPos + document.body.scrollTop;
, f. C0 C- ~  \* R1 V         }3 \" @' I6 w3 T1 ?, q, n
      else if (document.layers) {
8 u2 }7 \  r& Y/ {, u* q6 a; }         document.layers["supertext"].left = xPos + pageXOffset;
6 K. b; e* I! L  S( Y. S: s         document.layers["supertext"].top = yPos + pageYOffset;
2 u3 p3 ~  i" P$ M4 h% S         }
# T  f4 a* o: P# G      animatetext=setTimeout('moveBall()',20);
9 o& m' G8 V/ h      }
* f/ X5 `! L5 w& l" P3 }+ `   }
0 K; L# t5 h( `$ X! j: Q( j' `5 |- |0 _3 q
function calculatePosition() {
) J) v3 v3 f- V   if (xDir == "right") {6 K- q# [# l% m! Y% D! H
      if (xPos > (xMax - contentWidth - BallSpeed)) {
+ }& |! ~9 V! K         xDir = "left";
- B/ u7 A, B# _         }
& t( v* }2 h; r$ z! `3 Z3 s9 y      }' E, @) n) r4 C. L6 B) H/ D# \
   else if (xDir == "left") {' }4 x, _- \$ ?
      if (xPos < (0 + BallSpeed)) {
) r( d2 C; j' i7 {3 A         xDir = "right";$ S4 N1 n; o5 L) p3 T4 v
         }" H" @# _6 g6 K/ W4 d+ G
      }/ G) x- S0 E) h( C1 g
   if (yDir == "down") {, U* A, ^% ~6 p8 v2 r' S
      if (yPos > (yMax - contentHeight - BallSpeed)) {# `- k; s+ {$ X. ?: [: S$ M* Q
         yDir = "up";
% }8 D- z* U% h8 I1 s; `) y5 K         }
$ ^, z" f4 }7 f+ c& R2 X9 g* I      }! O, L# \+ s7 h) ]8 [! V  S! @
   else if (yDir == "up") {
% K4 O; e3 v" S! }      if (yPos < (0 + BallSpeed)) {
9 Z+ h. [0 E, p7 z% N         yDir = "down";
( v2 t# {, h6 P) @9 z7 ~. {         }/ {& x5 i# R; {& a+ M& j. w
      }0 M- S+ G/ N/ H! V
   if (xDir == "right") {
% w- n& W. c! s      xPos = xPos + BallSpeed;
* ^, Z( N$ W/ j& |, o+ I      }% N9 w1 m: K4 G: N3 s
   else if (xDir == "left") {
$ S6 Q: _4 X5 V, ^+ H, |      xPos = xPos - BallSpeed;
. T; e' c  N/ _, o& J# P      }
1 A1 A' H: [, U* B/ `   else {* b  ?' U4 }; G0 t2 k3 [$ {
      xPos = xPos;# W- L( P: S. m( A. Z$ S( C
      }
0 y6 [3 J) x7 E   if (yDir == "down") {1 y+ W0 @; k. S* R
      yPos = yPos + BallSpeed;  F4 b9 B+ b$ ]" K% c
      }. J, k6 X* U2 S  q6 o; _
   else if (yDir == "up") {
7 I' B; h$ ]! F+ e; \      yPos = yPos - BallSpeed;6 c3 N* l8 Q8 ]- Q4 j
      }: n5 U9 M: q; h$ p; l. A
   else {" X# O) k) L- ?  R
      yPos = yPos;3 C; V  p* Q9 R1 G; G
      }
) N3 d) _" b/ L; o   }
  l4 f% M0 S8 I0 g6 S$ C; y/ D, o  h9 r" C7 t7 N$ ]9 g/ o
function hidetext(){
1 X. J) X4 v' Y: B! pif (document.all)
6 h+ X( `, f; V# s  d! b! @supertext.style.visibility="hidden"
6 L' y0 }* y' M0 g  h9 ~8 I3 felse if (document.layers)! M  U) C3 s: t! U3 Y. o0 T4 `; }
document.supertext.visibility="hide"
' @0 R& t* ?+ t  KclearTimeout(animatetext)& p. u- ]! y( s
}/ m6 W$ J- h, k6 I2 q2 f- E8 M
6 |9 k! L1 W+ q2 f( U) Y4 R
if (document.all||document.layers){
0 y9 o& {" k+ n) D, ^document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; Y/ k% z  r3 i9 T! `window.onload = initializeBall;1 y, N* i- s) [9 r- c, n
window.onresize = new Function("window.location.reload()");
8 g& g: t, O" j% y  W, Z}
, q! S$ \" h3 z' f5 J( P$ y
. ~. H3 U  N1 {' M# l</script>

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