返回列表 发帖

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

<style type="text/css">* `! [: a9 F/ h) J
#supertext {* U. h: a, I& _. C. N$ S
position:absolute;
, m) @; D( Y( w( ~left:0;" P. v$ r, I; f+ W* d, H& y
top:0;$ }6 c8 T  _2 X8 C* m# C7 N
visibility:hide;
4 L* g: v! w# Z2 ~1 J& H! Q: vvisibility:hidden;1 T$ t$ p( t2 v: Y4 L
}
$ _& h$ w5 z6 K7 p( g</style>
: q0 S% m- R3 O* M9 }<script language="JavaScript1.2">( h) _: F& @. u9 u+ k) C- f
<!-- 改变下的字体的大小。颜色-->! r$ u; |9 a. H5 K- C' m( O
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% a% G2 q1 O* e, m
var hidetimer='';
% C" x' P2 \6 S9 ]3 Q% V4 C<!-- 改变下的弹跳速度-->, L2 N/ t5 X* }7 b8 e0 _
var BallSpeed = 20;
! q  [; h0 I5 x) P* xvar contentWidth;
# p! w6 k% {' x$ n8 G% avar contentHeight;
7 N+ z4 x9 m# ~var maxBallSpeed = 50;1 u+ v) A# j, S9 p) n; z9 y
' K5 d9 q3 r/ {! P0 H3 z1 P, [
( g) T5 W6 L" q$ g0 {/ o
var xMax;' \  T. ^, Q; Q. Q, t% U
var yMax;, _7 o4 s- s7 O* g
var xPos = 0;) R  K  `' V9 t5 E: c5 I
var yPos = 0;
% h, m& d+ T, Vvar xDir = 'right';& Q: p/ s2 |1 F6 G2 T5 L
var yDir = 'down';
' ^) ^1 _& V+ F3 H7 T! W2 a: n) v4 Hvar superballRunning = true;# t( u2 t2 N3 y1 }
var tempBallSpeed;* x  b" X. f  C- C
var currentBallSrc;" I) o1 P7 m/ _" k' N
var newXDir;% v8 U  C1 J$ p
var newYDir;5 i* Y, z. ~' c& F

4 g, \, {, ]' ~2 A5 `function initializeBall() {
7 c. J8 X% c; t$ }6 h; H5 n   if (document.all) {0 }6 L/ B$ Y7 Q/ h% z0 c
      xMax = document.body.clientWidth- \$ \3 T# e3 }* T
      yMax = document.body.clientHeight/ d. v4 Y7 B- ?0 @! p% R
      document.all("supertext").style.visibility = "visible";
7 @' p0 N1 I0 U      contentWidth=supertext.offsetWidth9 L4 D) E/ h, c# T1 b
      contentHeight=supertext.offsetHeight6 d* U2 y' Z2 ]! F
      }% M: x$ @8 X) k: g$ x
   else if (document.layers) {& D( J2 O4 d  M2 G
      xMax = window.innerWidth;# ~% _  y/ ]/ B$ P
      yMax = window.innerHeight;
* C2 Z' r1 D% w7 `6 K      contentWidth=document.supertext.document.width/ f4 o9 P8 |- B8 W7 U! U
      contentHeight=document.supertext.document.height# h. j& V" t# N- K! e+ r' O9 @
      document.layers["supertext"].visibility = "show";3 Y! q1 ?' X  N) u/ _$ ?0 y
      }6 ]! O5 D# L+ i' I* S
   setTimeout('moveBall()',400);. n. h6 p! w. t; m. n
   if (hidetimer!='')
' Z5 h3 A8 l! S3 X% p! B- f3 g   setTimeout("hidetext()",hidetimer)
: s5 N8 h5 g" x( m5 T/ e7 I# v: l' u   }
' o4 r. c! ^, X  U- b1 a; ~' |& `, o
* j' J, H/ `* V3 x' \function moveBall() {
8 X4 j; W0 v: E   if (superballRunning == true) {  p! }: g4 w, ~* L
      calculatePosition();0 w) v- ?# D: O0 _
      if (document.all) {
) g6 l; p7 A. v( q/ N: o         document.all("supertext").style.left = xPos + document.body.scrollLeft;6 I9 a0 P& H9 a/ B% k" h9 j
         document.all("supertext").style.top = yPos + document.body.scrollTop;- y7 s7 t* E- Q" S% M* j4 z, L
         }
! T; {  \" u- u' V; M" w      else if (document.layers) {3 O2 x$ M( a( X" N
         document.layers["supertext"].left = xPos + pageXOffset;
: \" P9 P& S2 h2 T; g" Z" `4 Z         document.layers["supertext"].top = yPos + pageYOffset;
$ D2 ^1 M: `$ h' u( E& I9 y         }. ]( `, A0 P/ w, l  r
      animatetext=setTimeout('moveBall()',20);( @+ v+ e" p6 L  T
      }! S9 A% Q# |3 a) W; z$ U5 j
   }
/ k& K$ Y2 ?, B' B, K2 _  K: x4 A3 q) X& M8 q
function calculatePosition() {
' ~# L- [8 t3 R% h: F   if (xDir == "right") {
3 ^' b6 S' {1 H4 g9 V# j7 K3 I      if (xPos > (xMax - contentWidth - BallSpeed)) {
; v& v' T, n8 S' r( R5 H' K6 s         xDir = "left";
5 J* M4 t4 l2 w- l) E) q         }$ e5 ^5 M+ c6 a4 R/ P. z/ j
      }
  r1 ~! f8 l$ m$ L  m6 n   else if (xDir == "left") {/ N- F7 V- [" M) T# g. T+ Q
      if (xPos < (0 + BallSpeed)) {$ {$ ^$ b' s0 U& e( N% P
         xDir = "right";; K$ b& b" v8 y0 y: o
         }  H6 o$ l7 {( m# O$ w& ?
      }8 k. L& Q  Y; X. b4 `+ w4 R; {9 j& p
   if (yDir == "down") {
2 [. R+ e) K& A" H# w- w" I+ }      if (yPos > (yMax - contentHeight - BallSpeed)) {
. ^" K3 p) K' j5 W         yDir = "up";
' C3 G- Y, U9 C+ _2 l( ^6 O         }0 X, [) |$ _! A1 X. a4 @- U
      }
$ x, J" m, A% y% b2 x/ c2 P   else if (yDir == "up") {
( X/ g% b/ {( x6 _  _2 w6 e6 p      if (yPos < (0 + BallSpeed)) {# E) e- h0 f1 I- S/ `
         yDir = "down";! X* G; W4 J% }% S! H0 f0 M
         }
7 {- d4 v4 l, u( C! Q' F3 S6 e# r      }
$ q$ E7 v  W0 S1 L( h   if (xDir == "right") {* Q0 E5 x( m' V, p( h: l2 x
      xPos = xPos + BallSpeed;& h6 n: I( t$ Y, [
      }
" O0 N: c8 O  j5 F$ C4 h  Z+ E" y   else if (xDir == "left") {
) O7 J- F; C: A0 I      xPos = xPos - BallSpeed;- m9 g7 v1 L. A3 T& a+ u' B& E
      }
9 u' |. A5 M, b6 j$ X/ m   else {! n/ V5 i, V/ Z1 _+ q1 q! c- g
      xPos = xPos;
( V9 R, K3 @* G' C4 b; k9 D      }
7 |' i8 N/ Q6 e  k   if (yDir == "down") {
2 c3 v- @, |9 |& n3 y  Y      yPos = yPos + BallSpeed;
5 U7 H4 U% M1 l! `% v- l      }
! Y1 k8 P" L$ P5 {7 f3 W  U   else if (yDir == "up") {7 l$ z9 _% m; v0 \! i) P
      yPos = yPos - BallSpeed;
& y- I0 \( S9 A9 e( w      }% ?% g) V7 a: W  Y7 Q: J2 s# A
   else {0 E/ N0 U, H- F& z  z
      yPos = yPos;7 e4 U5 y) _$ [0 H6 F, m
      }
% _6 A! x: }9 e0 z, P   }5 S# V3 Q' Y% }

' B$ `! t7 m9 B$ l, e1 r, p% |function hidetext(){8 W% X5 M' p) b5 c* N, L8 g) h
if (document.all)
6 T" `5 f3 _1 E8 ^7 x- j2 D; Xsupertext.style.visibility="hidden") A! A( K0 G; A8 }3 [( \
else if (document.layers)6 D" ~7 x1 y1 ^) a5 {7 g
document.supertext.visibility="hide"
2 t7 v6 h$ i3 A  d0 ?: t! \& SclearTimeout(animatetext)
# z" ~" L  F% h1 O( U}0 `2 h- @  i4 ?' s1 L( p! Z# h

# \$ a- p4 i8 u2 W# i9 T0 L4 @if (document.all||document.layers){5 Q# ?! P3 P" `% t
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')' G2 e" D2 ^  U/ w- A6 j4 s2 t$ p5 G
window.onload = initializeBall;! [! t. K  z: t# u1 v
window.onresize = new Function("window.location.reload()");4 o; T8 E6 z" ^) [7 |3 G) @- i1 U
}
* I3 ?: t$ a( I  l) Z2 s2 N# f% h4 G6 f9 N9 X
</script>

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