返回列表 发帖

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

<style type="text/css">
1 |8 i( W0 @: X5 O#supertext {3 z, D0 k4 n. {8 ?+ \; X0 X
position:absolute;
) P0 S. Y0 E' B' s) {left:0;( }% A+ |6 y, {+ I* f
top:0;
- j  _" K/ Y  Z8 h  ]  Hvisibility:hide;  k, Q" G% N. h) L7 C$ F
visibility:hidden;( E7 D* J1 D0 k# O+ }0 Q: F
}1 S! u  ^( e: q1 s" |3 H& T
</style>; v* Z0 R/ G! N
<script language="JavaScript1.2">. W) @; Q* J6 D0 Y
<!-- 改变下的字体的大小。颜色-->
2 T4 F" I0 U; W1 wvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
+ p$ g4 H- R* s6 z# U; tvar hidetimer='';/ j0 ]1 B% W  U5 K4 ?
<!-- 改变下的弹跳速度-->
- ]" V- m# J0 t% bvar BallSpeed = 20;8 k$ o% O. z1 e8 V* Z# \$ T
var contentWidth;  R- H7 A: z' f/ Y* ^
var contentHeight;
4 d/ I& G- K. Z% dvar maxBallSpeed = 50;! K' P, P* Y- B" X
# S/ ]7 A' Z0 m, w

! k+ }( V) Q1 A6 Svar xMax;
9 v: e. `" @3 jvar yMax;) r. r* m! k: M- S- K) X
var xPos = 0;
  u! B. a  i* W0 ^$ cvar yPos = 0;
+ T$ o( F2 f; t& {+ gvar xDir = 'right';
/ G( e( [0 j+ F, X! j& Wvar yDir = 'down';7 a- M% m. P6 h9 o, }  i
var superballRunning = true;
2 p5 u8 Y+ o: vvar tempBallSpeed;, e$ J$ b  Q) P0 s9 K7 t1 U( \5 v
var currentBallSrc;5 P& j8 R9 ^9 U  Z: a$ m; t6 P+ Z
var newXDir;
- c0 ^8 o* q& h* |, j2 ivar newYDir;8 B; R0 e  {9 L( F/ H& l

: C4 w7 d: ~2 {) q, |- Sfunction initializeBall() {2 T& {; O" O- @. G. C" a1 c
   if (document.all) {3 @# L  L3 D! {# f3 e
      xMax = document.body.clientWidth' z/ A+ v& h8 T, c
      yMax = document.body.clientHeight
3 h/ a1 S7 B( \5 {; P" a5 v9 J      document.all("supertext").style.visibility = "visible";
( n! @$ \; z# y      contentWidth=supertext.offsetWidth
7 W, G0 f7 Y  ?6 }3 [! ]2 \      contentHeight=supertext.offsetHeight: j* u* t9 |9 ~0 u
      }
2 a8 r: |4 _6 h2 R. d   else if (document.layers) {' l% n7 t% j/ J) F, N" ?- ^
      xMax = window.innerWidth;
! ?1 l9 p" m! A7 x8 c6 Y$ x  ?4 X$ i      yMax = window.innerHeight;! U. O$ O% `6 `5 N( J) `
      contentWidth=document.supertext.document.width
- ], d" h/ r6 D  |  S) a' }      contentHeight=document.supertext.document.height
& Y8 u% A* R# w      document.layers["supertext"].visibility = "show";
" l6 O7 ^5 I( x2 S8 b. i4 {      }
2 X4 z2 y, q6 y" b5 b9 s   setTimeout('moveBall()',400);8 K) F' G' C" j) t7 l' c3 G
   if (hidetimer!='')
, g3 [7 K1 O& I' `; {: A% e1 y+ j   setTimeout("hidetext()",hidetimer)
" w5 v; o2 a4 A5 z   }( ~7 ^% h9 D- Z" Y1 x5 a: ?; C
+ w1 c) e6 A" \! N2 m3 z, q$ A
function moveBall() {
: W& Q2 s" \) y5 z+ J6 H   if (superballRunning == true) {
3 x% s6 e! f; @      calculatePosition();
9 t) [# @0 u% U7 T5 h      if (document.all) {
& W! Z) @: O( j         document.all("supertext").style.left = xPos + document.body.scrollLeft;
% J& ^% f( a) H, \8 V         document.all("supertext").style.top = yPos + document.body.scrollTop;! V5 S8 A8 }. J& n/ }5 J$ }
         }
# F" z' q6 r  w7 B0 L! q( K      else if (document.layers) {
0 D8 U6 y: I# ^         document.layers["supertext"].left = xPos + pageXOffset;7 S0 a% ~/ |! @# O# y
         document.layers["supertext"].top = yPos + pageYOffset;
% X$ ^& p/ _  b# K         }
8 d% d9 D% q+ `; k: a' C      animatetext=setTimeout('moveBall()',20);9 t" g; p% C0 B9 s( C! [
      }* a4 R  O  Z0 K/ K( u
   }% j! Q: I% l. R" S2 S8 l  [) [
8 Y% {9 F) _' |7 [
function calculatePosition() {
7 Z" v4 Z# ?( i, k   if (xDir == "right") {. m! h0 F) I9 C7 f! e+ r5 U
      if (xPos > (xMax - contentWidth - BallSpeed)) {
8 M# F' E" K/ z: W/ C2 E9 Q         xDir = "left";
! V& q& y3 a1 B; L5 H8 S) E         }# \* f. r- V. y( l
      }  E$ D6 m7 l, [: L
   else if (xDir == "left") {: E2 P' x" Q$ q# l, Q, X
      if (xPos < (0 + BallSpeed)) {
8 V. k' T1 f& C) B$ p7 a2 ~0 z$ I  I         xDir = "right";
# U- e% T1 `/ B0 f4 ^         }
% L/ K( @8 ]! K; `3 F; V      }" U) O8 a6 T1 O- t1 U, X6 O
   if (yDir == "down") {9 c; c, N. }/ T, m
      if (yPos > (yMax - contentHeight - BallSpeed)) {: b- H: T. p9 `1 h9 G: x
         yDir = "up";6 d8 m- `! o$ F  ^) o3 ^
         }  R6 ]4 s. t" Q2 A( u6 c
      }
! }7 _3 t) r' p& V! @! X$ D* Q   else if (yDir == "up") {
8 m. i: M! ], R' h      if (yPos < (0 + BallSpeed)) {+ Q( o! ]& i7 ^* b+ c8 y
         yDir = "down";
& Z/ {; Z1 k/ s! t2 p3 `         }
' I5 c4 m, k5 p  n      }. l& f8 G% o9 Y  Q
   if (xDir == "right") {
4 M" T8 ~* B, l( O2 e- m      xPos = xPos + BallSpeed;0 \* F' N' E- h! b1 C2 O/ H- P4 G
      }1 Y0 ?: |0 r  M- b/ `4 C# Z
   else if (xDir == "left") {
+ Z7 F- T/ G( d      xPos = xPos - BallSpeed;7 ^* Q: S7 n1 A+ C
      }& h) W2 {/ ^: V/ P- L: T) e
   else {" z7 t* }, u* s% p4 L
      xPos = xPos;- @- h0 z1 }" ^( ^
      }
1 t3 a0 n) `- T) ]   if (yDir == "down") {
" p1 t' a/ \! F) `; B6 A9 x2 F. {- F* N, y      yPos = yPos + BallSpeed;
  G7 R2 L8 I, B- o0 R- `      }
  o% w5 e0 B4 X0 ~4 {2 |   else if (yDir == "up") {
9 |: [. r8 k( D' z2 ]5 P      yPos = yPos - BallSpeed;- i" u1 p! }) [9 Z4 k3 D; ?' l
      }
) Q! e7 n7 K, F1 J   else {3 V$ ?) A4 O% {: B, P/ v
      yPos = yPos;4 ^  u& i& v( X* C% Z% c9 O
      }; P. O& C7 q* @2 ?; L
   }& X3 C: p! f: w1 }4 y

' ^+ G. x5 S& O* i( C, xfunction hidetext(){, `* l# s0 _6 d! w+ a# @
if (document.all); _4 M! S% P& R1 I
supertext.style.visibility="hidden"2 e8 z. S: _. G, r' A) C
else if (document.layers)7 b2 l3 [; R' `" W3 `
document.supertext.visibility="hide". S. ~0 D5 i5 b' T: s
clearTimeout(animatetext). {3 W  F0 |' a1 |+ u* S3 @
}
) Z  }4 l; {+ D+ z# A/ `% B& N& A, U+ ]
if (document.all||document.layers){
3 s6 G1 F$ D1 d" q1 K1 H; \document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* j' s. x6 {2 p0 y( h) T; o7 b8 U  u4 }window.onload = initializeBall;* J$ i- R( E) ]
window.onresize = new Function("window.location.reload()");
3 r" K  H# @2 p}
% I/ A2 ~8 u. ]# C# Y2 p* k' A9 V. y2 p9 n
</script>

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