返回列表 发帖

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

<style type="text/css">
% j! ^( ]2 v9 ?9 D% m) l9 _. q2 W#supertext {
% @8 P& g* o8 ~3 {# Hposition:absolute;% f, ^$ j/ V) D( [: r0 K
left:0;
) x% |5 u2 x! _. j& Gtop:0;
% M' j+ k$ t4 g/ b3 E- L2 zvisibility:hide;' R, y' ]  d) [  u
visibility:hidden;" n* P4 U/ X* R. O- V' D) J' [
}* v5 ~+ m' G' ]4 F1 T0 s4 W. k3 r' v
</style>/ b, ^+ w  L8 M4 q8 s
<script language="JavaScript1.2">
7 P6 @- p1 _. s<!-- 改变下的字体的大小。颜色-->
8 R5 c2 L- _9 X4 z7 ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
$ R7 t. f4 z. T* ]- |* zvar hidetimer='';
, K: X' V2 J; O- z0 w% ]$ l<!-- 改变下的弹跳速度-->2 C$ N1 M. z' t( `
var BallSpeed = 20;9 U& \' {& d% L6 h+ O" X, Z
var contentWidth;
8 ~- G1 u9 s+ i' }% Pvar contentHeight;
, X- O2 m8 e" q. N  {5 Hvar maxBallSpeed = 50;
5 A% l0 i' k# {' G3 q2 c8 \- O/ q' C( e# w* X' v3 T: S& q
& T- p4 f% Z4 Z% u& ]. {
var xMax;+ W6 B2 p: P% f4 w
var yMax;
. ?% n! m9 z' y  v8 P+ ]0 O& Mvar xPos = 0;
; r2 M; J! ]0 \8 [var yPos = 0;  |# P2 f5 a1 {2 Y0 r
var xDir = 'right';  |% e, [9 X$ S; }6 F8 j. M
var yDir = 'down';
, V) G% B; H) b5 B& {$ Uvar superballRunning = true;
- I# L9 X/ J' D# n" ~7 Svar tempBallSpeed;
9 y/ E5 s: V7 M2 z) c" z1 vvar currentBallSrc;7 y  m8 Q9 R" q
var newXDir;
( P6 p, L4 k9 Y# M) G8 L3 xvar newYDir;& H7 O3 k+ \3 h0 \8 F8 S

$ t  M! G. F* q  ]+ Zfunction initializeBall() {
" n" I3 F- N& R( d: C0 B   if (document.all) {
2 p; ?# l. E( a) J3 v; Z4 Q      xMax = document.body.clientWidth2 Z8 G% O+ X) I# [" Q+ ?; A
      yMax = document.body.clientHeight
+ t4 C+ t8 S# \* y      document.all("supertext").style.visibility = "visible";
: d* R; I  v) u6 {  U4 d) }8 f) s      contentWidth=supertext.offsetWidth; m" P) _0 q! k0 q' |, @& n
      contentHeight=supertext.offsetHeight
; F2 @0 G  w5 g( w      }8 }: n& b1 z3 ?9 p, h8 O% P
   else if (document.layers) {$ }- ~' N( c3 p' y' t
      xMax = window.innerWidth;4 ?+ f) _2 g0 f
      yMax = window.innerHeight;) A+ p0 t6 N$ ~
      contentWidth=document.supertext.document.width
$ q$ T* K- a' X' G4 ?6 S' c5 D( v  z) g      contentHeight=document.supertext.document.height0 B3 q# ~) F/ F- g
      document.layers["supertext"].visibility = "show";
9 J- w' M8 W$ s5 [# V      }
8 P# y1 h" q& m9 ^   setTimeout('moveBall()',400);! _# P7 W, R4 ~% F
   if (hidetimer!='')& B; F- O% z) t! C8 M9 }
   setTimeout("hidetext()",hidetimer)+ C  O9 |! Z" F, J9 ^; H- z4 f* O
   }
, B1 N& G; r4 G3 f1 w$ D1 L- t) g3 _8 y' S* k& q
function moveBall() {
0 d+ {( {0 v2 Y3 Z- k   if (superballRunning == true) {
: X  R! C- h2 \: K3 D0 S% U      calculatePosition();
  i+ v; _# j( v% P- Z; _/ B* m8 s. f& s2 X      if (document.all) {
0 A& ~2 v3 a8 r6 M, a* T3 I         document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 |& j, ]7 I" o: r         document.all("supertext").style.top = yPos + document.body.scrollTop;
, R  Q' q8 i% Y" E: N2 ?; b         }
) G% e4 D  B7 }0 Q3 S      else if (document.layers) {" B6 p- i8 i& n( z2 u( y
         document.layers["supertext"].left = xPos + pageXOffset;- a, y9 C$ o' q! F
         document.layers["supertext"].top = yPos + pageYOffset;
* @& O$ y' \" i& B* \. t$ S: G8 n         }% U( Z% `$ J& m+ D3 U
      animatetext=setTimeout('moveBall()',20);
0 Q7 k7 _8 A5 |0 ]0 u      }9 b; S% a' X+ N# s" H( }+ N
   }- o' x6 y5 A& O  ?
3 {6 e+ _/ n2 g- \+ ^
function calculatePosition() {% R; b* g# B4 u, s9 k9 r; B
   if (xDir == "right") {
9 b' D* `) n" h      if (xPos > (xMax - contentWidth - BallSpeed)) {
2 U2 l8 c" C( C! t% l* A' M% n         xDir = "left";
& k9 }* t- c2 k: u% s' m         }
% ~* i+ L: Y- b* j      }
. Y6 g! z' X. \) q; s0 v   else if (xDir == "left") {
0 z: m- @$ _8 I      if (xPos < (0 + BallSpeed)) {# C4 A  x7 f6 [1 E- z# z% ]2 f
         xDir = "right";' w1 |- M2 \0 [1 L% Y
         }
$ S1 F" S" u$ z8 \( [! ^" [      }
) g) ]4 d; r0 @3 H   if (yDir == "down") {6 |5 K0 a% {7 I" X; k6 ]1 T; h5 R% a
      if (yPos > (yMax - contentHeight - BallSpeed)) {) `0 B$ _" j9 j9 c  Z7 T6 P4 h
         yDir = "up";9 {  i7 D  e0 b' I7 ^
         }
. O* o! d( }* a7 r. i. ]      }
- D/ j+ d  ?4 O) ^   else if (yDir == "up") {
% U( k) Q  P: z! v6 e      if (yPos < (0 + BallSpeed)) {
/ Y4 S6 d: ~7 {( m& s5 G         yDir = "down";2 }7 L) a- D4 c7 [
         }, h$ G' a8 X- a. I  `
      }
" b" d0 d! l3 E# V$ z6 k+ N: U   if (xDir == "right") {
( O4 g( L1 k+ o* Q/ K3 i/ X      xPos = xPos + BallSpeed;' N. G+ t' S0 W% m3 S1 e0 \, v" H
      }7 L8 i) z0 M) Y, w7 C" e
   else if (xDir == "left") {
$ p- \! N: I; ^% n* H8 N      xPos = xPos - BallSpeed;
- t  e6 {$ n+ [) {      }
5 @* ]% ?8 x5 t   else {& [* S. ~- j* Z5 X8 r3 n; U
      xPos = xPos;$ M" I0 Y1 y. Q& i) G/ ?+ W- V2 W, ?
      }
( n2 Z# i! U/ d* [1 j+ t   if (yDir == "down") {
5 ^, M: S" T. w      yPos = yPos + BallSpeed;
+ e3 A" ~6 o7 X; _$ e7 C7 z  J      }
- g! j0 x. ^. g! }   else if (yDir == "up") {6 F. ?; U) ~% F: w$ l# K# W- y
      yPos = yPos - BallSpeed;
. Z: n. m" U# W      }
# W: y; E5 {: I1 \- P   else {( X$ q7 B, x& n0 l  Y
      yPos = yPos;: r/ j# V2 ^. i4 Z& g( P
      }. `( E8 o/ K( A) Q, V! ~0 S
   }
" c1 w; s, _' [+ u) _! l5 {
: O- y+ N( d3 l# j0 f0 l- Kfunction hidetext(){' n. f7 @" T* U, G2 K4 D  ~
if (document.all)
9 h7 C2 s6 k' E  A* e; U2 ssupertext.style.visibility="hidden"  r  s: g9 |  w* r" u3 U
else if (document.layers)3 w" Q) L4 h$ K' r* E# j: m
document.supertext.visibility="hide"
6 z; K: E( @. B  p- m. AclearTimeout(animatetext)( L: H! z' U- A  ^+ x( o  K- n
}
" i1 ]" z& }) }8 ^6 ~% ]- P- m
0 D' u4 o  q$ F" W3 X) S  Iif (document.all||document.layers){& q/ \4 l. q  o2 K' [
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 V9 P2 W: X+ O( G! }
window.onload = initializeBall;& N* t) I* {# O3 |' k
window.onresize = new Function("window.location.reload()");
5 q# U. G0 a2 m# i}
6 {+ Y/ N4 E- o5 D/ x4 A2 m; |2 h( x5 N/ D
</script>

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