返回列表 发帖

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

<style type="text/css">
* h1 ~2 I9 k" k/ U0 Z# b& H#supertext {
8 w7 x- n" R* ~0 M8 N8 Tposition:absolute;
4 i( C) R8 w1 C5 F& @$ {& L9 ~left:0;
/ M2 {( S4 Z0 e0 y* v! `top:0;
! V; E: @4 }) u% U+ `. vvisibility:hide;
' }7 F5 \7 u" q+ c6 h, V8 Yvisibility:hidden;
- b" ?# U  D+ ]8 h1 A# l$ W, [! r. j}
  x$ Z% M4 B" U" H: R' ~$ F</style>
6 |6 v: z0 q" f0 X<script language="JavaScript1.2">
" Y: ~. E8 u# l  J( Y, a* S9 S* \<!-- 改变下的字体的大小。颜色-->% H' r( K* F$ H2 b0 [
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
& D" L$ f3 T/ c8 kvar hidetimer='';
: Z8 ?6 f1 _& B/ U6 @<!-- 改变下的弹跳速度-->! n! }; [$ T4 P/ b- _( l
var BallSpeed = 20;4 }: J5 B- m; b3 M
var contentWidth;. K8 d0 x2 m+ I+ V
var contentHeight;7 E% M, `4 e$ h3 r
var maxBallSpeed = 50;! D, ~6 X1 }; {

  Z+ _; ?) D& M% `$ n
8 M% d4 b5 H+ |/ I% U+ v6 b" svar xMax;
' Z+ U8 l0 u5 Evar yMax;
1 H9 M  T" f" {( X# h0 Hvar xPos = 0;
+ k0 H9 D; B7 z( N$ avar yPos = 0;
5 m& ?, k( g) k5 C' cvar xDir = 'right';
- y+ A5 w7 H/ a9 g& Z- x3 V" yvar yDir = 'down';5 h& J- D3 Z& V- ^" x, U
var superballRunning = true;
0 L& `; ^; K; e9 l1 Yvar tempBallSpeed;
3 J. N+ v7 [; ]var currentBallSrc;
& x8 Q, q% B5 L- o- gvar newXDir;
3 c4 w" f% ]* x, R. ?2 r3 Bvar newYDir;! R3 T9 }0 z/ x" h' l
7 O: A" Y+ W# d+ F
function initializeBall() {% G. D$ _! e, j+ a+ p, c9 ^0 a
   if (document.all) {
  U) a, C" f# x2 _( {0 c      xMax = document.body.clientWidth
1 o5 K5 g0 r& e+ u6 V& I4 J" M# }- ~      yMax = document.body.clientHeight( |; ?* A1 Q2 b% K' j7 c
      document.all("supertext").style.visibility = "visible";2 o4 B* d+ i+ P5 l1 ?3 |) I
      contentWidth=supertext.offsetWidth( s5 E2 Q. V6 U4 m6 \' a
      contentHeight=supertext.offsetHeight$ q! M0 F) t# i0 W3 Z, s
      }
, ~8 _. F  U, T' Y' O   else if (document.layers) {
5 c( {* E7 O# B, c      xMax = window.innerWidth;
/ q# F3 Z( |0 b* E5 ?      yMax = window.innerHeight;
) t* z5 P) ?' c; o9 B      contentWidth=document.supertext.document.width1 K# c. j. p7 |" ~/ z
      contentHeight=document.supertext.document.height
3 U0 }* F8 y8 u- Z/ V& y      document.layers["supertext"].visibility = "show";/ U- J; E9 U, i# |9 f
      }9 h& O& c* E( {" w. h* E
   setTimeout('moveBall()',400);- l$ t* A& L" u
   if (hidetimer!=''), U1 k! Z2 n/ z7 Q& i: D) E8 ^
   setTimeout("hidetext()",hidetimer)5 Z1 b+ n( Q  c" y
   }
: T3 g: Y% g* O0 `5 {* e5 k& h9 z7 w5 ?9 E6 }! d8 a  _
function moveBall() {1 J# W: B1 [9 C) F6 O" C' X" K
   if (superballRunning == true) {, O$ O3 `8 `1 O& L! {
      calculatePosition();
. M  k1 J! m$ |5 B4 ]      if (document.all) {, I6 m: [4 [& @% H. x* J
         document.all("supertext").style.left = xPos + document.body.scrollLeft;! u: Z  {7 q+ E5 R$ U. V
         document.all("supertext").style.top = yPos + document.body.scrollTop;: l- Q2 ]: Z! m6 q  X% G6 Q
         }/ e/ u+ h( T( T
      else if (document.layers) {
: ]6 A- i6 e8 z         document.layers["supertext"].left = xPos + pageXOffset;
6 d0 T5 I/ H2 T- M         document.layers["supertext"].top = yPos + pageYOffset;
2 E7 x7 i  @# l4 X         }
! G4 H1 k  M, Q+ ?% C) G- t      animatetext=setTimeout('moveBall()',20);
. S$ q) y6 `! h. ^9 |5 A! I# r      }6 `6 v  c. k1 ~( {8 G" R/ `3 [
   }
4 p  y9 g2 S0 d
  r" I. ?3 Y6 {0 f9 j/ afunction calculatePosition() {
( {; Q( _+ j2 b; f1 M( n! `   if (xDir == "right") {
! \* X$ E5 m/ F1 t/ L7 B: l* Y' _      if (xPos > (xMax - contentWidth - BallSpeed)) {) a1 B8 X* M# h  z% v6 P3 k
         xDir = "left";
6 C+ P5 u& n1 G$ O$ ^. U2 S         }
, Q* m( v) |; o/ j: D      }
% Z5 Z* q* n( F6 R2 J8 Y   else if (xDir == "left") {$ N  q; l$ `. n
      if (xPos < (0 + BallSpeed)) {
5 k$ U, p" D2 \& T% f( m' P         xDir = "right";8 ^: p; ?1 N( [9 ?
         }
# R7 g4 c8 U; S9 v7 c! l& ~0 K      }
. V* s1 Y5 N$ V   if (yDir == "down") {
7 ?& L4 H& p' s5 [9 ^  z; M: ?      if (yPos > (yMax - contentHeight - BallSpeed)) {
; Z3 G9 v* Y7 Q4 t+ }2 @& U         yDir = "up";0 B; s2 W( q* d  W
         }" B8 X. p9 Y# R9 q
      }
0 N% Q; ?) \$ e3 _+ _7 s3 f; ?4 V   else if (yDir == "up") {
' K3 H; _6 n# t- _* q8 S! _6 W      if (yPos < (0 + BallSpeed)) {
: h- b3 x3 o% O# w         yDir = "down";/ ]; M- @& J: J% m) J# ]5 _
         }2 j9 P6 m! u+ z+ S0 K
      }5 s! a- |$ N9 ^$ ~) G& d
   if (xDir == "right") {) H" s% y6 V. K, M4 ^
      xPos = xPos + BallSpeed;1 n2 F/ d2 F& C# J( [6 \6 l
      }0 Z1 r& T+ u/ i  B: ~$ b
   else if (xDir == "left") {
( t2 d8 `- l& p5 Q      xPos = xPos - BallSpeed;6 _4 O  I/ \6 M, L9 o8 r
      }
( O! v# o5 L8 F( E; o   else {" U' B/ N8 q3 A
      xPos = xPos;0 U& N: q# l" Q/ V0 e
      }# [& A( }" `7 }# q. z' U
   if (yDir == "down") {
3 j2 U+ o3 O  e6 A6 D7 P      yPos = yPos + BallSpeed;( h) b! ^7 a, L9 m: `5 g
      }- r# c. A. t9 U9 F3 A, J2 ]
   else if (yDir == "up") {
, S: d8 C1 G: L$ u0 x      yPos = yPos - BallSpeed;) `, @+ b+ j5 \2 w/ ^6 u
      }
+ E' I+ F0 v, F) \9 {   else {
! `9 r# ?) L. o% @/ ?      yPos = yPos;
* h& T0 g' ^8 [' E# X* ~* G      }
, I: J& y  M7 G, J' L* Z   }! E% y/ Y4 w" |3 e6 O, H5 t

6 }+ E% T1 o) efunction hidetext(){* n' [' J& l3 q9 O* r4 J% a6 i
if (document.all)( p' Z3 N2 n1 p' j
supertext.style.visibility="hidden"2 z' l7 I/ C) N( R: P4 M
else if (document.layers)
* d- J- J  b, z' wdocument.supertext.visibility="hide"
4 ]& F8 h% t+ ^: a# d- r  kclearTimeout(animatetext)& |; \8 E" A4 q$ ]8 z% R- [& _. S9 O
}0 A/ n/ s5 N- P2 S: ]9 L+ Y

: j* ?$ Z: y% Wif (document.all||document.layers){. t4 t* m  v3 j
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')- s1 g$ t9 m5 Q) }3 Q
window.onload = initializeBall;5 J$ f- l' J4 E4 D3 u8 H
window.onresize = new Function("window.location.reload()");( q3 H3 D$ ^& E- y0 n) Q0 T
}
, a$ |8 p+ O7 l( Z6 l
5 V8 O6 e6 z9 C$ P; u# W) H( C' z: `</script>

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