返回列表 发帖

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

<style type="text/css">
1 H% p2 `5 Q: z#supertext {
4 g" Q5 i# m0 T; X: Yposition:absolute;1 b- j' h9 Y' c
left:0;% ^0 y) ]  k3 [- O# D' H; [9 V
top:0;
1 X- e* Q) _% [9 s0 d. h, Wvisibility:hide;8 u8 a; F# ~- h! W/ F8 X$ b
visibility:hidden;
5 r5 W4 j) \6 Q$ c}- {$ D8 D- j* u* s+ b4 n
</style>. J2 d- R! T9 b& y
<script language="JavaScript1.2">
3 v4 {. C0 l3 H' i<!-- 改变下的字体的大小。颜色-->
/ D4 i3 A8 ]" ?; ?var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
; p. Q. Z" F# e# \. {" hvar hidetimer='';. w" b7 ]+ V; T9 A- d) k( D
<!-- 改变下的弹跳速度-->
7 K. j5 |; h% e' W+ f, a+ D: Dvar BallSpeed = 20;
; X3 d+ F1 @' G9 I. I: j7 @var contentWidth;
9 @1 a# G& J3 i+ P+ d0 P* Ovar contentHeight;
/ ?( C+ r' Z% Z8 T" Xvar maxBallSpeed = 50;
! b8 V; i6 ]3 W- e: i9 e# t: M) K8 u; U

& v7 F0 g  L8 f( n& W$ q8 avar xMax;
- b# r) k7 I# }6 {+ Rvar yMax;
* s; c- k  T  P3 |% Lvar xPos = 0;1 H2 f1 k# N1 g/ I" p* v8 c
var yPos = 0;
; d& U  Y3 v. ?# a. [; n$ n/ tvar xDir = 'right';1 Q0 {: F- g. a. M; A! _8 W
var yDir = 'down';
9 V, [& h! y( o6 Y9 \& l' Pvar superballRunning = true;
! u# f; _3 r9 V( m3 T7 w% q: _var tempBallSpeed;
: E$ D% B! t: e$ V9 U% |var currentBallSrc;; A3 R4 w' h- W9 d" R: [+ Q
var newXDir;+ {. ]3 ?8 y5 S2 {( P6 I
var newYDir;% u8 ]7 q& f& C8 Y  |' r
& P, y# i+ d/ a4 h9 R& v0 i  g8 _
function initializeBall() {" x8 _: f" q% m2 G- \
   if (document.all) {6 X- f. v! ?! k
      xMax = document.body.clientWidth$ _, m& q5 c) ]
      yMax = document.body.clientHeight
. k% G2 I4 [9 D0 q' W& _+ b      document.all("supertext").style.visibility = "visible";
3 h: f4 R6 ^# l1 ]/ p! e      contentWidth=supertext.offsetWidth
- m* m2 p$ @: K! V' x      contentHeight=supertext.offsetHeight
5 v# _' V1 Y3 n6 Y* F+ T      }' Q9 M0 L, g. l3 |# a, i( r: ^
   else if (document.layers) {
4 z9 J- g% A' `  Z* s' }7 y! A; B      xMax = window.innerWidth;6 K2 q4 f* Q5 w! D" A: Z
      yMax = window.innerHeight;2 z1 d9 t$ }( }
      contentWidth=document.supertext.document.width
* k% j1 Y( E, _3 g) _* P4 z8 }      contentHeight=document.supertext.document.height
9 N& y  u/ w2 t4 n( Z0 Z      document.layers["supertext"].visibility = "show";" }# h! H; r3 o
      }
; Y( V5 ?  g5 Q% R9 d   setTimeout('moveBall()',400);
5 x/ V6 x5 Y) O& J   if (hidetimer!='')( ]# p, X$ h6 a. a5 W$ r7 n
   setTimeout("hidetext()",hidetimer)8 H  ~9 |& ?, F! f! n
   }3 \: d  e8 I  g* l

# ~" j. y6 E) m3 ^function moveBall() {
6 ?. [' }* Y6 e0 ?   if (superballRunning == true) {
) ^1 d6 N( n, Y      calculatePosition();! A9 o, c9 L- t
      if (document.all) {' Q/ R+ A# {' x8 _9 R$ V
         document.all("supertext").style.left = xPos + document.body.scrollLeft;7 N% h% i8 Z4 V4 i! Y8 ^/ E3 J
         document.all("supertext").style.top = yPos + document.body.scrollTop;4 T/ X! Y* ]! H4 ?
         }* S/ T4 v' W' F/ c
      else if (document.layers) {, ]" L8 @) w4 t; t7 }1 T  N
         document.layers["supertext"].left = xPos + pageXOffset;# E' D9 D$ K3 q; s6 Z+ m
         document.layers["supertext"].top = yPos + pageYOffset;, w/ u1 Z9 Y0 M' K
         }8 U9 U3 H/ J4 W& {
      animatetext=setTimeout('moveBall()',20);
7 |/ l: N. @- C/ H& V3 x2 t. N      }
; s/ ], C3 o+ q   }
* B8 z" ~* {: R+ f4 v8 F) }. ?+ r4 B* L. o+ `
function calculatePosition() {
7 }3 Y' D/ O, |% d   if (xDir == "right") {
3 K" Q* V- {/ L" ~+ F% B  n      if (xPos > (xMax - contentWidth - BallSpeed)) {  Q1 \7 ]# ?: w/ j
         xDir = "left";
; W3 K1 A8 b/ y" h. Q/ o! Y         }
6 }, Y" E1 s! u/ k4 X3 ?. E      }$ u; p2 t7 W1 O" Z2 q0 b
   else if (xDir == "left") {2 Y7 }& J  @7 ~' l+ R5 U% G8 X' m/ `
      if (xPos < (0 + BallSpeed)) {
3 D3 }! M. f1 F- r% E! w: V. J$ x) r         xDir = "right";3 X0 y) [# b6 s# {/ j+ _; I
         }
7 s0 U( k( T2 V( S( V- F8 q      }2 \; C* M- X! n/ g4 H
   if (yDir == "down") {7 j! a# m9 e! ?2 c7 E8 y+ M3 e
      if (yPos > (yMax - contentHeight - BallSpeed)) {. D! |- V; H, o0 n
         yDir = "up";6 D  q& w: p' q4 L4 \, h' N0 B
         }# }" b4 q( R, E8 @6 Q) R8 N! [
      }5 y4 ~% S. O6 O1 }4 f. Q% b
   else if (yDir == "up") {
- A8 t2 t! d8 ]1 p+ p      if (yPos < (0 + BallSpeed)) {
- f) Z4 p9 Y5 s4 V7 D         yDir = "down";2 ]. f, ~% C, D/ c
         }
2 U# j' s& ^& x# L- x      }
% a) P) Q+ ]. H9 D7 u   if (xDir == "right") {
  G, n: ~5 b( n% O- y      xPos = xPos + BallSpeed;7 n" l: z$ [5 j. z% N
      }
$ G' k. c7 ?. T* Z" a$ F: b& N   else if (xDir == "left") {8 ^8 ]. {1 w" Z) C' `
      xPos = xPos - BallSpeed;6 G* P+ ~1 h; V9 w% c& |; Z
      }0 D2 W$ i$ a' A" p) o, G
   else {
& t$ v6 r, }3 x0 h) _+ d9 Y# y      xPos = xPos;
: L, p. E* ?& @" `      }
, y! ~" g7 w  L: h$ f   if (yDir == "down") {0 p  F' r  p% v/ r( [
      yPos = yPos + BallSpeed;, a& B- o# |0 a: W) j
      }
2 B# d( F% c- j/ j/ O/ U' q/ z/ W* V   else if (yDir == "up") {* O1 C0 v8 C; Q1 V+ B
      yPos = yPos - BallSpeed;- b0 A1 y6 o: d$ F, T3 j
      }+ p  j! ]( B. c- z, w
   else {7 I$ u/ P1 x% u- _
      yPos = yPos;/ J* R, F. k" }
      }
8 {- Z. A0 G9 W! J$ k% U* C. U   }
6 M5 [" Q2 T& k: P0 S7 d4 `
2 X' _! T6 e3 @1 f2 Yfunction hidetext(){
. f. ^0 m8 s" Y& X4 v5 a1 [5 I5 Vif (document.all)- J) G* K& i* V& D8 s* |. [
supertext.style.visibility="hidden"1 O3 X" h2 t+ Y
else if (document.layers)
6 ~5 x' z* a  \8 Kdocument.supertext.visibility="hide"0 O0 i( C. @7 `9 S( o$ Q
clearTimeout(animatetext)
% p0 B% x8 p( U$ r# `}" H; ~$ n+ D( A, W1 \

0 y$ [% |2 M4 G; y5 kif (document.all||document.layers){) l2 {3 s9 \0 x/ w: q. W
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. m3 F) ]  p! w& l. \window.onload = initializeBall;
6 D  E2 G5 \( M4 Hwindow.onresize = new Function("window.location.reload()");$ r9 y4 Y5 b3 D# Y
}% k$ }8 P  e4 }7 X
7 U' d3 R- g' y) r" ]4 b1 @
</script>

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