返回列表 发帖

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

<style type="text/css">) E4 o# Q& t; r# S
#supertext {. Q$ p$ v7 R4 C9 c6 K5 w
position:absolute;1 V; [9 ]6 z+ }+ g) ?
left:0;3 u+ l0 b( S) o$ a0 h
top:0;( U$ H. z% Z5 r' O6 h, j) X; m
visibility:hide;8 b% ^0 s. L  h9 V) N# ]7 c, J, Q
visibility:hidden;
: r# Z9 o  Z- D4 i1 `" q}
# l, k; K, E* {9 o/ ^' e</style>+ ?3 V- e$ ^: v9 W/ J4 \% M
<script language="JavaScript1.2">3 n  z1 `8 v9 ]0 B
<!-- 改变下的字体的大小。颜色-->
/ b, q) n4 _) R5 ]- L  dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ l- M* X/ s6 F5 C; f# k, U
var hidetimer='';
; i( c3 a4 i6 H. ?<!-- 改变下的弹跳速度-->/ y, G$ n! ~) X7 y5 {
var BallSpeed = 20;
- K' P$ W" l% X$ }, rvar contentWidth;! W9 b! j1 ^6 a; f" j, [
var contentHeight;
2 K# b4 N. f5 Ivar maxBallSpeed = 50;
7 L7 {, I; V& o1 H+ T+ }; C/ K& k* A7 x

, l# T4 t" m. r" q. J1 s% O: Dvar xMax;  R/ y4 T. t& ?& I3 U, D9 w  A+ `+ H5 ]
var yMax;. g" `, U, R1 u, T! _- U! n$ E
var xPos = 0;
  l" P+ n- E$ M% cvar yPos = 0;
0 F* E! o7 [6 [0 Tvar xDir = 'right';
+ l7 B2 s, Q- Z1 |/ O3 l4 Tvar yDir = 'down';
3 Z$ h2 C- [$ \+ yvar superballRunning = true;. g( y. _5 M: r( `. R* Q. H8 ~
var tempBallSpeed;1 ~) s2 T0 k4 r5 U1 w) z
var currentBallSrc;
1 l2 n  i6 h+ U, ^8 c' Hvar newXDir;0 E" F- p0 Q+ |2 Y2 K1 M$ @* x
var newYDir;
3 v+ y. V' j- k. Y( C0 z/ L0 g" P
function initializeBall() {$ ?( V5 @3 r, d# X
   if (document.all) {
, n, I1 J( Q# ]+ I! W, Z      xMax = document.body.clientWidth
, L- E6 r3 E# g2 b: o, a      yMax = document.body.clientHeight
& I8 T" I6 E0 Y. X9 T: y1 Z1 k" x7 a      document.all("supertext").style.visibility = "visible";
3 c' r0 y+ d: a) R7 R      contentWidth=supertext.offsetWidth+ f5 [! @" \0 x) |
      contentHeight=supertext.offsetHeight
7 f4 w6 T. x" v* [9 W9 V% [      }
7 r! e" B  L5 s$ l$ ~0 z   else if (document.layers) {+ L) u7 l) R, _9 `8 g
      xMax = window.innerWidth;
( n5 O8 F6 \8 Z8 w1 j+ Y      yMax = window.innerHeight;
& f5 |1 ?5 r' c" Q      contentWidth=document.supertext.document.width2 t8 H" F3 |* T& a, b3 T: v
      contentHeight=document.supertext.document.height7 K- C2 }+ r+ a% B6 j# v7 Y
      document.layers["supertext"].visibility = "show";& I. _- H( k0 M3 Y' {
      }
4 [$ V" E5 l+ g) Z# s   setTimeout('moveBall()',400);! c( v3 J( _( }7 x) A& z% D
   if (hidetimer!='')* L! h! Y( W- N
   setTimeout("hidetext()",hidetimer)/ Q+ w" ^, e+ E: k" J4 t9 n
   }
) a% [( c+ V! X; _8 \! h
6 X1 E- W2 ]8 j' _function moveBall() {0 q4 n4 Z5 W$ I9 d+ ]8 |: D
   if (superballRunning == true) {! e3 x3 i) G3 _' |* F) I
      calculatePosition();
8 L( n9 Q) s4 Y/ g4 ]      if (document.all) {1 d  ^7 j- ^0 c' M; U+ \: g
         document.all("supertext").style.left = xPos + document.body.scrollLeft;2 O, T5 K/ t7 B) G4 l) e
         document.all("supertext").style.top = yPos + document.body.scrollTop;' _6 t8 i, k' A8 `+ ^+ z7 T1 U
         }
5 b+ V. y2 n2 b& [1 B2 p. s- j  B5 Z* D- i      else if (document.layers) {
0 v6 J0 D+ g- y: _5 z6 C4 K, |         document.layers["supertext"].left = xPos + pageXOffset;# J( [5 c9 Z5 g+ G6 }5 M6 l( p
         document.layers["supertext"].top = yPos + pageYOffset;* E0 H" a2 z7 p* V' L7 j* ?5 K
         }
5 E/ G* I7 C( o, F5 m      animatetext=setTimeout('moveBall()',20);) {! M5 s+ t( D7 }+ a3 z" e4 ?
      }
+ d% N  |: R* b   }
, [0 u& Q" _5 O. c/ Z! f. Y, _; A0 A0 \# A5 D! s3 S* {8 B" x
function calculatePosition() {
; L' ]$ F0 `! E. g) S   if (xDir == "right") {
% ?8 N  Z; W5 E2 z      if (xPos > (xMax - contentWidth - BallSpeed)) {/ f1 \( a  `# X8 d0 P
         xDir = "left";
, e+ D; n0 O7 M2 d( V5 f         }
4 _( n" i* n+ D, ]4 e      }+ l  @4 _, h- M# _* E8 r
   else if (xDir == "left") {( t; Y8 l9 P8 p" S
      if (xPos < (0 + BallSpeed)) {
& R/ @7 h* y/ T& @& N( {/ O1 B7 v. N         xDir = "right";) y/ @# _0 h8 n0 x. }- `6 S) S
         }
( W; @( y! q- Z! m% R8 o      }
2 W, u9 ~% B4 w9 |' u& f9 C   if (yDir == "down") {
- f" v. P* V) W. m      if (yPos > (yMax - contentHeight - BallSpeed)) {
( O/ y/ c$ E3 K/ w. m" i         yDir = "up";
$ D5 e6 H7 I/ e         }. \7 O% _( ?9 ]/ s: T9 \
      }
$ Z2 Q8 i4 h' {2 B; f  X   else if (yDir == "up") {
& I" C, v$ R+ a      if (yPos < (0 + BallSpeed)) {3 v: C  q% [. l. F  X' {! c
         yDir = "down";
# i' h& b- Z. E) p# s- n         }5 T5 q5 P! k) t/ T1 S! ]
      }
4 T( C9 U7 M; b0 B3 s   if (xDir == "right") {: \8 c! c7 h+ C. S& |& }
      xPos = xPos + BallSpeed;
; i$ C: O9 c- }3 b( T      }
/ ^% q0 ^6 f. s/ H# X   else if (xDir == "left") {" T- @4 S* h+ {) H
      xPos = xPos - BallSpeed;$ t- i9 e  |) Q' M; g& f
      }
$ \* A1 y6 e& a! M   else {' x* d  ~( s7 h: H4 J. S/ E
      xPos = xPos;
: I/ K2 \2 J& t# J8 i; R) n      }
9 T( \. C2 k  F2 l   if (yDir == "down") {
) K( p1 z* J8 Q! x1 R, V2 w      yPos = yPos + BallSpeed;
3 P( E4 y% s6 X, _, X2 }      }
8 V( G3 e0 D6 J6 B2 U$ Q7 ~$ X   else if (yDir == "up") {
5 G  p; W1 Z  L6 n) {      yPos = yPos - BallSpeed;# a# @$ w) D* O$ q
      }- h+ v+ _# I' Y
   else {) L$ F# L" w9 a) Q# K2 E
      yPos = yPos;
$ `4 b% `5 h: H      }
4 {2 |% ^! j$ G6 w   }, a# w# m$ |* \& \# t

6 z$ H! k; d: [0 g6 X3 |& Bfunction hidetext(){
1 ?; a  G8 I$ s- h. Pif (document.all), @) ]# P5 [1 B, u. ^: Q0 Q
supertext.style.visibility="hidden"! \. e  K. O2 V2 O
else if (document.layers)
1 C6 b2 B3 R" |0 i* i, M* ^. Cdocument.supertext.visibility="hide"% i  g/ [' ?0 K  b, I6 Q
clearTimeout(animatetext)
( x' |$ o  h$ i& F, u: C" K. [}$ h( S/ Y; Z' O4 y2 r

1 c" f6 C6 {3 B! E$ R1 A* s6 tif (document.all||document.layers){8 r9 z, M; f4 t. U4 {
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), e! J5 H$ q: v' ~; M6 O/ ]8 @" G
window.onload = initializeBall;, M: B; e  _: f' `: b
window.onresize = new Function("window.location.reload()");# d  j' N9 N$ B
}# _( o$ }( W5 V
' ^' L. p; k6 ^/ l
</script>

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