返回列表 发帖

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

<style type="text/css">
7 |0 Y" o. A& v0 x* n2 V! ^#supertext {
% S0 f0 `0 }2 e8 j, Uposition:absolute;1 \6 e: {( F/ {& x7 {
left:0;
$ [$ W9 G0 S6 Q" O- a* Mtop:0;: u8 n/ R/ z6 e4 l( d6 V; m
visibility:hide;
/ c! I2 p. V+ b5 G) Ivisibility:hidden;8 D) @) m5 z% v* k8 W# a
}1 a1 C' A& v, ^7 c( X3 ^
</style>* S% k$ ~3 R8 D6 T. u
<script language="JavaScript1.2">  h! Y" t# z  N- z& ~
<!-- 改变下的字体的大小。颜色-->" C+ q: `; }1 s5 E6 \3 X' K, F
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 u- }+ _  e6 |( P  hvar hidetimer='';0 v0 V: P! D" O; B. D
<!-- 改变下的弹跳速度-->
/ q: j2 `1 H; P7 V% ~var BallSpeed = 20;
# F: N& I, f+ ^; o# v) Lvar contentWidth;
' h/ @  q/ O7 w2 n5 `& w& N% O6 y0 \var contentHeight;) n4 `/ `1 x( W) e; X
var maxBallSpeed = 50;! W' g, M  p) ?0 \0 Z3 d4 U

- o5 |9 _+ W; W! H% a8 \4 g8 t* [, ]8 m* w
var xMax;: K- n' o+ u4 h9 p
var yMax;2 h* a$ P; k( P2 }1 u, H
var xPos = 0;
- N  _' h6 Z  \9 L5 L* A) U  D; Qvar yPos = 0;) z7 m+ u! W5 V( ]
var xDir = 'right';
2 N% I, A3 q, _# ]; Cvar yDir = 'down';
0 t9 _5 G7 {3 Wvar superballRunning = true;+ @$ m4 n6 x% f( @: L
var tempBallSpeed;
: e7 B- z) m( @0 l; |var currentBallSrc;
  O# K, V$ c6 V4 E5 J" ]3 Rvar newXDir;
7 k6 _& y3 x% c. L3 E1 D1 vvar newYDir;4 A! H) y# k2 m9 x/ ~* R- b

' T$ O2 }* }8 m5 kfunction initializeBall() {# ]- O  _8 f% ?% t! `6 w3 B
   if (document.all) {
" E) f/ c5 X* V  n1 }2 l      xMax = document.body.clientWidth
+ r  z, s; ]% R" C9 E; t  j      yMax = document.body.clientHeight! H( ]. Q7 J8 U
      document.all("supertext").style.visibility = "visible";
$ h$ Q3 |5 z7 U; e2 m& G" `      contentWidth=supertext.offsetWidth3 m6 T& g9 U) X/ N* t. {
      contentHeight=supertext.offsetHeight1 _7 g5 f, |, Q6 x/ z! d5 N4 M
      }9 w( @# H/ n' X% T; N  K7 h
   else if (document.layers) {/ i9 Z. X. S/ W+ G( r& x. A( J, `
      xMax = window.innerWidth;
# S# V' `" Z# |% J! o: M1 v      yMax = window.innerHeight;3 ~( a: \; [& t/ g" ~# {; @( L
      contentWidth=document.supertext.document.width8 V' W, g. n* M5 [1 x+ Q
      contentHeight=document.supertext.document.height0 R3 _. G# a6 W, H# \8 K
      document.layers["supertext"].visibility = "show";
/ n3 P. ?* @1 `! U! a0 p$ g5 O' i      }9 o& c* M0 x, }; n
   setTimeout('moveBall()',400);
9 C2 C" d' I- c5 \: M% t% P   if (hidetimer!='')  m. C4 [+ V( r: }2 b2 v
   setTimeout("hidetext()",hidetimer)- n+ k0 ?4 u! F; S$ r4 W' a2 Y
   }& F% p* |1 }/ l9 h1 a4 }5 Y( `

; H0 m* y: `8 K! wfunction moveBall() {- D2 N+ o- W& ?' y4 r& V' p; l8 S; F
   if (superballRunning == true) {2 y' e. D8 l& N% h
      calculatePosition();
7 L9 X- ^  D+ P; d8 |# y9 k( W, K* _      if (document.all) {# t/ h  j  J9 j; F
         document.all("supertext").style.left = xPos + document.body.scrollLeft;4 I1 ?/ t! z$ ~1 R3 a- K
         document.all("supertext").style.top = yPos + document.body.scrollTop;9 t) w1 S) q1 h# `6 |4 \$ g3 D8 v
         }
$ e% k0 [# y2 P9 J; k  B      else if (document.layers) {' [' ~9 x0 |* P) G6 }+ z1 N% s' s
         document.layers["supertext"].left = xPos + pageXOffset;
* Y/ R0 h6 M5 ?' w3 s1 A         document.layers["supertext"].top = yPos + pageYOffset;6 p9 ~( y! L: Q7 D, z* ?, n
         }
* @" S, g. j; }% J2 y- u& x4 E      animatetext=setTimeout('moveBall()',20);* T9 u5 ]( ?1 t4 x$ T+ K4 n
      }
4 p7 s7 d: a2 v3 x- q6 r  t   }
! ~6 L- m; R  j7 t* \- V( s; |/ z2 p+ s( |
function calculatePosition() {
. {) a8 u" t& |5 ^5 Y1 x   if (xDir == "right") {
  n  |5 o+ ^3 j) e- z7 A      if (xPos > (xMax - contentWidth - BallSpeed)) {! L' c. w7 j2 `, D" F3 n
         xDir = "left";; `3 G' l2 s: @9 ^% [
         }3 \' M3 @7 b  }$ f
      }
$ H. O* K6 Q. X( [* a& _4 ~   else if (xDir == "left") {
9 `' @  j8 K: H& U' J2 w      if (xPos < (0 + BallSpeed)) {3 E, @  m' t& f
         xDir = "right";& f2 o5 e$ ^  q4 k' p
         }, @+ |9 s* S6 }
      }$ O- C3 d  p+ }" e, V5 x' {
   if (yDir == "down") {
) C/ C" L+ {0 a6 V6 w/ u      if (yPos > (yMax - contentHeight - BallSpeed)) {! @$ ~% v  M  }" ~
         yDir = "up";
: Z* z  u  V) c         }' R4 C* f( r+ h/ B$ V1 K( {& B2 Q/ l
      }6 }! C6 L# s0 n( e7 p( r( F2 p
   else if (yDir == "up") {
/ d9 b8 W0 h& Q% n& V      if (yPos < (0 + BallSpeed)) {. z9 x& z- \$ U+ v3 v: C' O* ^% R
         yDir = "down";; x% {4 t) T  B; z1 O+ M
         }0 W( I0 X" b; [1 @( H
      }
) @, b7 V% c' \- X   if (xDir == "right") {2 Q- s* C( A- R. o& ^' W/ ]
      xPos = xPos + BallSpeed;  y" S0 v% F9 i2 H" I
      }$ ^) C) w) ?6 u9 q" Z2 v& e; Q
   else if (xDir == "left") {" Q$ h6 n, i9 @* N% p1 r
      xPos = xPos - BallSpeed;5 H) J( C8 s5 u! G" i) `
      }, p3 M( z) c, |0 u. ^7 I- C! `- C; A
   else {7 F5 H$ J7 K* t8 t- s6 E6 E$ B
      xPos = xPos;, K- z: \4 a6 f+ w  Q0 D
      }
: r& F; v' i3 p5 P   if (yDir == "down") {
4 {& A" L. g& [: a      yPos = yPos + BallSpeed;
2 v( |8 T4 ~3 f. s  _  L      }/ Z2 W! E* E( J, _3 D6 ^- v" U# @/ o
   else if (yDir == "up") {5 F- Q( F1 _1 Q# d) f3 t: W- _
      yPos = yPos - BallSpeed;7 r, c; `/ l1 Z, j8 p& k
      }5 ~$ G2 j( p, ^) i( T- \/ d  H9 C
   else {' g  c+ ~; W+ k" c# S
      yPos = yPos;
* m3 D/ h+ ~( C/ W      }
" g$ Q2 ~. p) s0 V: A5 @. ?. H# ?   }. |. Q- a, ?8 j# @

0 ]0 l" o/ L2 `6 K% ~' ofunction hidetext(){
* X; d$ M9 Q2 xif (document.all)
4 I. {; \/ @5 ]' Z: M7 lsupertext.style.visibility="hidden"0 m8 |! Y% {- q; C! o/ F. L9 J
else if (document.layers)
- o0 u5 \! j! v: T- f. D1 cdocument.supertext.visibility="hide"' u1 m0 y3 e- t3 d3 b
clearTimeout(animatetext)% [( E# N) ]$ r. w9 P& b
}! z2 `  a- R3 X  }% ?% `6 G
$ S1 {% m3 ]" t/ [3 B/ d' `, ^# ~
if (document.all||document.layers){7 V1 T4 W0 z  X1 ^) |0 s
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& a8 ]7 {' G/ \3 {$ L" S  X# h9 {
window.onload = initializeBall;8 R# k3 b& Y6 p( \6 t7 y* W
window.onresize = new Function("window.location.reload()");
/ [! N3 N: H3 k+ H0 h9 f}
0 U6 _5 ^5 p* A0 S2 A
4 E1 ], u: M4 W! l. G" {</script>

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