返回列表 发帖

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

<style type="text/css">$ m8 F, j* j. S) e( o3 d
#supertext {
+ b1 Z6 r1 k3 K2 N0 d0 M8 Z; kposition:absolute;
$ ]$ @0 L" A; B' W. fleft:0;; S4 }' A% e4 H0 F
top:0;
, _: b  K1 L  o% A% B' ^- _visibility:hide;$ d+ h+ [3 `8 I+ p( V8 W7 g
visibility:hidden;. ]+ P5 d9 [! L: }# U# c
}- ~/ y5 I+ @) b2 g
</style>  k# p0 H, g& g- m; J
<script language="JavaScript1.2">, b8 n, Q; t/ _  h
<!-- 改变下的字体的大小。颜色-->  A1 _4 p' ?5 D2 K' F
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( ^. B9 b  v/ ^var hidetimer='';
! y- x6 z6 `' {2 `<!-- 改变下的弹跳速度-->2 f7 J! t9 @; b
var BallSpeed = 20;
1 J! ?5 a, U& p' p) l, Yvar contentWidth;6 G% ]4 [+ w5 {' d
var contentHeight;
8 o7 j2 R4 R' Evar maxBallSpeed = 50;
% [+ s4 p  B/ W+ T
( i5 O' Z) ?8 K: C$ p, u/ I2 y+ e, n. W! J/ X
var xMax;
6 h' J) u$ \3 F' Jvar yMax;: X0 U$ R3 o- D8 `% h8 z# C5 J: s
var xPos = 0;! f* `0 A5 c8 S
var yPos = 0;* b2 Y9 h. L1 C! q
var xDir = 'right';
1 {+ @/ _2 ^( _  W- ~3 Jvar yDir = 'down';5 K" C' M' d$ U- p/ l0 ^
var superballRunning = true;+ q5 X, S& |5 x
var tempBallSpeed;) i# {: g. \2 j! t6 k: g) m$ F
var currentBallSrc;* R6 b% J5 m$ C# Q3 v) E" m- w
var newXDir;- J( J5 i4 V/ b7 w9 h
var newYDir;4 J/ f/ W! V. e9 B0 [& z
+ ]6 d) J# K4 s( f/ k  P- U0 x7 n! y2 T. k  Z
function initializeBall() {* u5 I5 b- [6 t4 c
   if (document.all) {
2 |. ?$ X$ d( ]6 X+ D      xMax = document.body.clientWidth
* b0 }' k+ @% A      yMax = document.body.clientHeight
) W: ?1 e/ b: h      document.all("supertext").style.visibility = "visible";- [% y1 M. j3 W5 f, M
      contentWidth=supertext.offsetWidth
  b0 Z  R4 ?! @      contentHeight=supertext.offsetHeight: l. O! |8 {( e# Q$ n
      }7 Q% o+ e6 m) z/ S, p
   else if (document.layers) {/ k" b) E) u8 \) w) f4 x
      xMax = window.innerWidth;
; G( D+ l! y( k      yMax = window.innerHeight;, K) G/ J5 C  L2 Y! s) C# T* q8 A
      contentWidth=document.supertext.document.width
9 A, r# r- u! E* K, l, `7 h# \      contentHeight=document.supertext.document.height
1 C; C( z( `' v$ X( t. i      document.layers["supertext"].visibility = "show";
4 P# c, l* Q# c: ^7 ~# }; {      }% [# n6 F0 V, U. m1 b
   setTimeout('moveBall()',400);# |) g0 {( z7 m
   if (hidetimer!='')" R, {6 Y: x, D1 H7 B% o$ H
   setTimeout("hidetext()",hidetimer)
4 \& f+ o  j9 K$ [! a3 i- v7 R  c  Q   }' b* F, h( z9 d3 K/ T

) `& v4 r- s4 s7 @function moveBall() {
$ C; d1 m( s5 p) I3 ~) t   if (superballRunning == true) {, v4 k! }5 p5 H5 a( M
      calculatePosition();' G- `( H% B8 O4 G7 r$ ]2 J
      if (document.all) {$ Y+ @& N1 e) k0 C6 a' H: V, K
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
- q+ ~: b: q9 x1 N  H3 U7 `         document.all("supertext").style.top = yPos + document.body.scrollTop;
! ~' y+ n9 M' ]- w3 ~: ^         }
& A3 ^3 v- T& Y& |, d# Q$ ]      else if (document.layers) {
: G' T/ Y5 |5 V. Q$ h  ]/ L         document.layers["supertext"].left = xPos + pageXOffset;
  Y' a% B& j* t* h0 F  t: `6 A1 E         document.layers["supertext"].top = yPos + pageYOffset;: @1 }0 k0 M4 @; j# b! G
         }
7 R% \6 l  P, Z1 O      animatetext=setTimeout('moveBall()',20);
! T, Q. c1 K( p2 K# `* y# O      }
. O' @) X2 ~5 Z: t   }
) T$ T" O$ z3 t6 d6 t, j6 Y9 y
. u  B, I7 M% A' [' H& l) Mfunction calculatePosition() {
2 B3 R/ I( P, I- ~+ T. U" @   if (xDir == "right") {
8 {& c3 ?0 Q3 h  E) o      if (xPos > (xMax - contentWidth - BallSpeed)) {
2 X$ r$ E( W8 P# ?! p3 c         xDir = "left";
& a& \9 t7 F$ r: s         }
7 `3 b; }8 c+ m9 ?. ?3 B+ O3 l      }
, s# D: s3 t8 Z   else if (xDir == "left") {
. c8 }0 d; S2 d: Y; ^9 a  i      if (xPos < (0 + BallSpeed)) {
: g: [/ r. Q7 Q# ^& Z: G         xDir = "right";/ o  U6 s5 B& A9 M& B7 ], U, M
         }
1 m8 C1 d8 C$ P2 j$ o; d7 b      }
, f4 ~1 t8 g3 `$ h   if (yDir == "down") {; ^1 d# A! K: |2 B( y
      if (yPos > (yMax - contentHeight - BallSpeed)) {
" R- r0 F; N. v& u( ^5 P) g         yDir = "up";6 u8 T% q# z4 g! Y' ?1 s
         }
: f- \7 O- Q9 X# w      }+ J* b1 P3 Y! i& x9 _6 h0 _+ q3 T
   else if (yDir == "up") {! q/ |% r; C- e6 E$ w3 H! s
      if (yPos < (0 + BallSpeed)) {  K: R" c; Y# V5 F
         yDir = "down";
: }. P. t) h0 g: |1 B) [: B         }
) ?3 I% u7 k( o      }
+ D* Q# l) F& p: v- s6 y   if (xDir == "right") {. [" b9 P' |( G, H1 U" G4 r* s4 c- q
      xPos = xPos + BallSpeed;# y, |# Z; U: p: P/ {' K; e
      }
& Z; V6 d$ B& T$ D   else if (xDir == "left") {+ p" C4 v) J8 C0 I# {( @3 i
      xPos = xPos - BallSpeed;% {8 B' B! u  j9 P) ~0 e: d! Z
      }
0 R7 u5 m. v7 I9 S. g% l1 M8 n   else {% [. X: q* l9 y" t
      xPos = xPos;
* [+ t- l: ~5 p2 |+ T) g      }- k- q# _/ ~" P' z' S6 r
   if (yDir == "down") {2 n- m& I! R4 I
      yPos = yPos + BallSpeed;
9 M* {& E! @; |: e* v      }' m% O8 N: @$ @3 _5 T) k
   else if (yDir == "up") {
- J2 o& i/ }7 |" h      yPos = yPos - BallSpeed;
7 m/ }& v2 C5 c# A      }
; D& A$ B3 Q0 u" ~# I- `   else {) h; @( L' J0 g: z5 u0 ~
      yPos = yPos;
) `) u3 B$ Q5 Y" V/ p      }
0 m: a% L  i. K. r5 W* H, J  b, O* @   }& P5 ]1 v: C* Y6 r
* x( [" C6 N0 H9 u0 f* z% Z- r
function hidetext(){
/ E% T. s) M' Y1 Cif (document.all)
7 a% q2 G7 C% }* F% k9 bsupertext.style.visibility="hidden"
  Z3 I. E( c: A8 V" N0 F, Yelse if (document.layers)
% h! Y5 z! D6 cdocument.supertext.visibility="hide"8 ^) q9 K/ p9 f: ~: u8 U' r% Y
clearTimeout(animatetext)
" \# c  s, p) }4 h/ t3 s+ H0 x}
, p; S" T) U4 \& z4 o/ @" n8 E' }6 H* ^3 i/ Y5 A
if (document.all||document.layers){4 K6 m$ r9 y) U: ^! ?( _
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 }# i3 {5 _7 K$ r% _8 M2 ^window.onload = initializeBall;/ \8 W- I& t$ }0 u. j# l1 ~; t
window.onresize = new Function("window.location.reload()");
9 `8 ?7 x  r, a0 K  S! H}& R3 N+ L4 _& z% V
1 W8 u+ `: n) W2 |; X" @; R
</script>

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