返回列表 发帖

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

<style type="text/css">
% [- [/ `# [. b2 C; ?#supertext {: L& g7 n* @# o5 f' J
position:absolute;' z* A6 |5 I, Q* V8 K/ m6 @3 W
left:0;( L& f1 ?9 }  G+ |) ^7 I* J
top:0;
, @* N& C! u4 w7 svisibility:hide;
4 p5 g$ e2 s9 [- e+ p& Svisibility:hidden;
' F$ }. [% \$ C}6 t6 J+ d* N) p! Q4 ?7 M
</style>
! O5 [% P$ c& @' e3 ^; f- L<script language="JavaScript1.2">
( @7 m- {1 m  n; H<!-- 改变下的字体的大小。颜色-->
: i- j2 s! R& I7 O. @( M8 cvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') p2 k+ O. @: @" v$ p
var hidetimer='';
/ J0 M7 X  m! X<!-- 改变下的弹跳速度-->: H5 W! q( L- J1 j
var BallSpeed = 20;
' c7 `% x; B5 }2 Uvar contentWidth;
9 W9 |0 q% y3 S/ J. G3 Evar contentHeight;
( s" g; p& @* _: vvar maxBallSpeed = 50;
# o% A& y& w# ~, R+ L+ w6 o/ f5 a* o8 k8 q& d' R9 e
1 g6 t3 o. J4 J3 g2 Q3 d. v* W
var xMax;! U  N, f  e1 [& S, @2 i
var yMax;7 u( v6 E' U( O$ [6 Q; ]' R
var xPos = 0;
7 d2 G- k  B6 {3 [, vvar yPos = 0;
2 |# n+ i$ D: h3 o7 c9 gvar xDir = 'right';
2 o$ |. e' @; R+ N6 Wvar yDir = 'down';8 `; L3 m5 @/ {, P0 H
var superballRunning = true;
& _& z- e2 m5 T/ V& T9 C( y5 Hvar tempBallSpeed;/ C$ E7 [$ Y; A" e% P
var currentBallSrc;' s7 x% X1 e9 z+ P- R$ |+ M4 v
var newXDir;3 }% H+ i7 ^" K/ p* f
var newYDir;
  m( y. \; b! t# ?3 Y- J7 k' e0 ?& g3 n- o% T- P+ X: C$ c
function initializeBall() {2 e( h; Z1 Z. K# f* n) Z
   if (document.all) {) S2 E5 v6 k# {' {4 }
      xMax = document.body.clientWidth
, m; |% f$ e% [      yMax = document.body.clientHeight
" }  w6 ~4 _, j/ z      document.all("supertext").style.visibility = "visible";
' |$ I: U3 `% x9 L( O! k6 m7 ~      contentWidth=supertext.offsetWidth
5 a$ p% V3 R( @2 J; t      contentHeight=supertext.offsetHeight
3 t. K* e- c! E2 @4 r, P/ f      }
0 u! `; }5 o+ J) K6 \   else if (document.layers) {
+ H( ?1 }! r9 `8 l      xMax = window.innerWidth;8 H  M0 B7 ~& s
      yMax = window.innerHeight;
8 r/ ^" |8 p# f$ W      contentWidth=document.supertext.document.width/ M" x1 z0 K6 z
      contentHeight=document.supertext.document.height( D8 y+ F8 o3 H4 L
      document.layers["supertext"].visibility = "show";
% {) p# `( ^( `: ?5 t* E, `- }      }
/ w' B5 A+ i2 u& [) J1 h& W   setTimeout('moveBall()',400);3 f) v9 J$ `$ l7 t* Y1 Y
   if (hidetimer!='')# R; Y% s8 c* j& Z+ f
   setTimeout("hidetext()",hidetimer)! Q, w, d3 u; @9 U
   }6 y" z0 F; ~" d* B

; G7 T% p+ E9 D& b+ Vfunction moveBall() {7 i" r1 q3 @) x* I# u
   if (superballRunning == true) {# J( s' }/ p4 k4 U. r( T
      calculatePosition();+ Y3 y& Y" O# J0 I" W+ E. ?- H
      if (document.all) {% k, F% ^# {3 Q6 @! e7 O8 ^' o
         document.all("supertext").style.left = xPos + document.body.scrollLeft;' |5 J" ~! p) V8 m' \, i
         document.all("supertext").style.top = yPos + document.body.scrollTop;" ~1 n6 c, ]! G" D
         }
8 A& U; Y) J6 D2 j      else if (document.layers) {+ C: O  C: v+ U6 b1 w, J
         document.layers["supertext"].left = xPos + pageXOffset;5 t4 V* B. K4 }; d# Q% M% E* h- {
         document.layers["supertext"].top = yPos + pageYOffset;& d5 g- g3 u/ O4 z* o
         }
# j9 I) Y0 c# ~* |# ~1 M$ m      animatetext=setTimeout('moveBall()',20);
8 S; E' K. x' b" t4 O1 k      }! S; H3 V$ W$ M* \. ?" N' ^4 J: F
   }% k0 J* u- k7 ]8 M- b0 n' y
, d6 y  z9 m, g  ^6 J
function calculatePosition() {% n. |3 k% w4 u- @& ~- b
   if (xDir == "right") {
9 e$ g* @. m' j      if (xPos > (xMax - contentWidth - BallSpeed)) {
# g' ^: P# o% m' h1 ~* c1 R         xDir = "left";- E  t# E2 E( p( R* A% d
         }: t0 y7 Z% }5 `" r# v( G
      }
  Q$ z4 @: j  v5 S; K: r4 R4 |   else if (xDir == "left") {
, p8 i  k$ s& k      if (xPos < (0 + BallSpeed)) {3 I2 ~, G& K5 p% n, v
         xDir = "right";
+ ~! B4 D3 A( l7 C         }
& F4 d" y- v7 v- m+ \0 A      }
; u: u9 z& i9 y9 R) s   if (yDir == "down") {4 m5 I0 _& G- `7 [% P
      if (yPos > (yMax - contentHeight - BallSpeed)) {# e1 x2 b  T3 K2 ]. R8 a/ O0 ^
         yDir = "up";
- C7 a' e& ~- i         }! P$ V: i4 M& _. H
      }8 k3 W% u8 V' G% @
   else if (yDir == "up") {
5 w" x3 f2 N  [5 y6 F( S( m6 J) E      if (yPos < (0 + BallSpeed)) {5 b2 x" W0 S) c$ G) r; M  x
         yDir = "down";6 r' Q% e  y) Z. u
         }8 W# F% [/ v, ~& e$ {1 f
      }+ f7 f9 T* c8 W
   if (xDir == "right") {& v3 ~; ]6 k5 `3 H
      xPos = xPos + BallSpeed;3 t2 `# C( s# F6 M
      }6 x* r, d1 @( h3 S* M( Y2 B
   else if (xDir == "left") {
3 x: P* h1 j/ R8 A- _      xPos = xPos - BallSpeed;& L& ~, X0 N; ~6 H. w# X, C; C4 v$ s
      }
' u' N- R; Z! s( c9 h1 r* U   else {7 \5 _2 s# }( ~
      xPos = xPos;6 k% e! M- Q: b, A1 w8 S1 `
      }
, b& S% ?6 t$ F5 N   if (yDir == "down") {
! R. l2 D7 |- _8 X      yPos = yPos + BallSpeed;' J& h4 D% ^$ _" a4 q6 _
      }6 m' c9 k- M$ U6 R% G: R* v" j, Z! h! a2 u# g
   else if (yDir == "up") {
: d$ z' O' _6 U6 Y( C      yPos = yPos - BallSpeed;% i1 U* @7 R" u
      }
; i9 e. V! s7 H- N5 E% h5 r   else {5 Y6 ~6 M! j* _* ], G7 A" V* y
      yPos = yPos;3 K' _) K6 @% O5 D) K& e
      }% L" u7 I) W& G5 K
   }' u1 l, J3 W/ d
+ U+ q, i4 }. {9 T
function hidetext(){0 o3 A8 C0 s+ h
if (document.all)# D3 `: w3 [, n( B, M  p
supertext.style.visibility="hidden"( ?; v6 V: l/ u
else if (document.layers)
) I' A; h3 w, F2 V( j2 i0 ^document.supertext.visibility="hide") p5 o7 S/ w6 C9 G" f' |. n9 e
clearTimeout(animatetext)- s2 y: V* F/ P2 E2 ^+ i
}: C1 @: l3 y% ?0 T4 w5 y$ w/ _; l+ A& S
# L) X, S6 B' e0 d) i& n5 a
if (document.all||document.layers){+ g9 |9 i9 c! E; Q2 a8 C
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')- @- v3 T% z& U4 j, w
window.onload = initializeBall;
; _8 A- ~+ t* g- L3 `3 Uwindow.onresize = new Function("window.location.reload()");
- V9 I, E% l7 S- w3 b& Y! A}
  _5 x/ ^1 n/ Y+ N) n
4 \1 n, h  [0 Q</script>

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