返回列表 发帖

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

<style type="text/css">3 a7 O9 r' J3 D
#supertext {
: }4 @! C/ x3 g$ P# k8 U$ n4 Aposition:absolute;
. X( }0 e8 ?; _3 T! P: Mleft:0;6 q. Z4 h& p5 X2 L: S1 s
top:0;
1 {3 z4 O& R( C( J! kvisibility:hide;
8 W; |5 t5 F9 \6 n4 Hvisibility:hidden;
6 v! ]- ^6 J# `0 Q  f}
+ J9 T! e* a- c8 D, C</style>& C, c. ~( n. e* c  f! a. O4 P
<script language="JavaScript1.2">8 ^/ ~9 }* |$ b4 a' O2 q
<!-- 改变下的字体的大小。颜色-->
8 j4 E, _# n6 v$ Q. J! f2 Zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 P: B7 p# E9 k/ d
var hidetimer='';
/ W, f0 @/ o4 u3 {2 C2 J9 R0 n3 p<!-- 改变下的弹跳速度-->& N# D' w' g6 P
var BallSpeed = 20;
. E; R. d5 X$ F4 l: tvar contentWidth;) }4 D3 N8 ]: e
var contentHeight;& ]7 t  m7 G7 v1 m1 H4 t% D
var maxBallSpeed = 50;
1 f( L/ D3 H0 G/ B; {' g% Z
, M" p  `0 y1 @4 O
6 W8 r$ W$ F) W9 v* L% Zvar xMax;8 _" [# ~" s, F* _3 N' o
var yMax;
! C7 U, o$ Q$ n! Nvar xPos = 0;
; o! b6 w+ o4 B4 \, {' j7 w- ^# Evar yPos = 0;
4 ~' M  Z# `% S" t* K; L8 Svar xDir = 'right';  x' \* j; O  \$ k& J' P
var yDir = 'down';
7 W" D& W% m2 `2 _6 S: Q* p1 S1 xvar superballRunning = true;
; q1 S. J! Y: ]  ]var tempBallSpeed;
" s" d8 H/ G6 K  B, K# V. |var currentBallSrc;
8 Y8 ^6 p; {& w2 jvar newXDir;
: |: q' S6 H3 d: M4 s$ Zvar newYDir;  G) \+ \* C1 I# C" P

) L  E$ n1 V( Y: t% ~function initializeBall() {) n, L% Z& y3 f# Q
   if (document.all) {* A& L, ^) S# C# k( z5 F
      xMax = document.body.clientWidth
9 m1 Z8 s$ W1 r6 l! S5 ?7 v      yMax = document.body.clientHeight2 Q3 r5 e4 ?4 z4 n  f& p" J8 R
      document.all("supertext").style.visibility = "visible";: E- x, E9 `" A$ L
      contentWidth=supertext.offsetWidth# j* d7 O/ r! a; D0 {7 r
      contentHeight=supertext.offsetHeight
( ~$ e# o. t! s/ H# d      }
# \/ j! Y" @& k9 @: V% o% O) f   else if (document.layers) {/ w0 W+ j, L; y  P7 @1 D( U
      xMax = window.innerWidth;( P) c0 f% M) ~$ J- L1 {
      yMax = window.innerHeight;
9 W+ c6 m7 D+ N& r; z      contentWidth=document.supertext.document.width( l( s: V3 n: S+ e! v) C3 N# f. V
      contentHeight=document.supertext.document.height
+ V% L" N2 V5 h" z9 ]      document.layers["supertext"].visibility = "show";- _% @% j$ [9 [
      }
' ]; l6 [% s8 y1 |- H  G   setTimeout('moveBall()',400);, g9 }# X5 \% w8 b+ b
   if (hidetimer!='')0 |- e+ D2 m+ i# K7 O" }" K- [
   setTimeout("hidetext()",hidetimer)! H* S3 T8 }3 M: P( _* {
   }
, T: L9 ?: v) g( b: Q5 a' ]/ M: N* Q: ^5 }
function moveBall() {9 M; n; D$ y3 g5 J7 A5 L) ?& S
   if (superballRunning == true) {
4 U- M" K7 \" t* |+ u- p5 X* K      calculatePosition();9 ~' K$ Y# x# r( N( m$ B4 x
      if (document.all) {8 ]: n0 J% C( ?1 p
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
* G3 D# h+ ]+ |/ `+ U         document.all("supertext").style.top = yPos + document.body.scrollTop;' ]7 T" o8 a' c$ G' Z. K
         }4 |( T- W" {4 l3 Z% \
      else if (document.layers) {$ }. B+ S/ a/ r! s0 M. }) C
         document.layers["supertext"].left = xPos + pageXOffset;/ W8 f4 j1 G' v1 x1 x& Q5 s% c
         document.layers["supertext"].top = yPos + pageYOffset;' H$ H9 X4 {$ F$ F9 g0 B  S& _
         }+ F* @; e1 I4 O; q  j$ X
      animatetext=setTimeout('moveBall()',20);
# s( v# Y; Z9 [3 w3 c6 W      }
  y2 B" g% ?: P  N   }
; ?" X$ M4 G, d2 d" O
, q' X+ z' E6 x4 ~, Z6 b+ O5 Ofunction calculatePosition() {6 k8 }% T( Y' B$ X/ z+ l( A* J; i
   if (xDir == "right") {
: [/ t/ H. d7 Y, ^* s8 w$ P( Z      if (xPos > (xMax - contentWidth - BallSpeed)) {
9 k2 @+ A. A7 m; b7 U# w         xDir = "left";
, {8 L" M; b) W         }
9 G0 T, q8 S$ i4 w" b3 p' D      }7 ]' U$ e. E5 v9 z+ F
   else if (xDir == "left") {
) \/ P! z, t- [3 D' q      if (xPos < (0 + BallSpeed)) {
+ Q8 |% t* E0 m; w: Q, U" _1 a         xDir = "right";
; r4 P0 c, O/ C" B; a         }8 P" `3 \: h$ T5 |* c
      }
/ R; U# ]# y/ }" h) N! w  V   if (yDir == "down") {
& B$ F, s  i% J: C      if (yPos > (yMax - contentHeight - BallSpeed)) {* V" s  y3 j" t3 d' O. _2 x
         yDir = "up";' w4 U- ~) _9 r' z. v
         }
) k! H  V3 k9 x; `; V* y. _      }! p6 r- E" g8 P# `# V% A0 K  H) D9 L
   else if (yDir == "up") {2 }5 D0 ?$ g6 R% t. G. D
      if (yPos < (0 + BallSpeed)) {/ ^4 _, g$ m; ~+ p, z3 a
         yDir = "down";
3 `2 A: `, ^  B1 V. z8 {         }
' E# f( M( |: ^      }3 ]. h9 Q8 W# B; s+ x& h  [/ _
   if (xDir == "right") {- \' {( D1 i& x: ^$ h
      xPos = xPos + BallSpeed;5 n) l- W1 Y) d' y# a( H
      }: Q4 x7 T5 V1 F; H- V/ b$ [( M
   else if (xDir == "left") {
3 r& z% W7 h# k* d      xPos = xPos - BallSpeed;
( K% x' ^; g+ h6 H& l! Q6 w      }5 c, V3 ]4 O2 o# @0 z% T2 L
   else {
7 ^( b- t7 }/ e" Y7 [* ]5 R8 N% J7 b      xPos = xPos;- H( O7 F7 q: _8 L
      }8 g: E0 v7 k' b; ~
   if (yDir == "down") {4 H' v& {8 a$ |& E2 M. q9 @
      yPos = yPos + BallSpeed;3 _7 g  s1 Y# [! x7 C( q$ `) V' N6 B
      }* C! n2 X5 y: R0 F! Q) x
   else if (yDir == "up") {
& c2 z! y; _" y) z- j      yPos = yPos - BallSpeed;
" K" D& l3 C7 v: w# F( l      }# [  E6 `' ^7 C' C
   else {2 s. a6 ]+ p8 l1 R( D( c1 k
      yPos = yPos;
/ Y* P+ @+ l; q. }* D9 |2 _      }3 P% ]9 L, ]. k
   }
% W& a, u& Z9 j4 c% `$ H/ R
7 {' ]$ N5 M' G+ l, Efunction hidetext(){2 I3 |0 ?4 I' V! B: f
if (document.all)
& L, u( i1 B( ^0 Wsupertext.style.visibility="hidden"
2 ^1 H+ s8 K, j5 C2 ^6 |1 pelse if (document.layers)
# R5 q7 s$ l# i- t/ Jdocument.supertext.visibility="hide"7 R0 X& m2 t  B9 U) j0 u
clearTimeout(animatetext)
; ]+ j5 r+ m; R7 a: t) r( W}
# c( v1 [- I3 s: {' c$ ~# k& W
! Z5 }/ N, V% hif (document.all||document.layers){! H' P3 _0 [& W6 e6 x5 A
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 m4 r$ L. u& N  Y/ i7 q, l
window.onload = initializeBall;
1 A% |* k8 V* ~* Fwindow.onresize = new Function("window.location.reload()");
! q( t0 Y* \& X}, c% S" V7 {1 C0 c5 i& B
, n9 x0 P4 K8 G2 P$ }/ E7 {
</script>

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