返回列表 发帖

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

<style type="text/css">
; Y& X# ]* d% T( [; m3 Q4 J, k$ p( P#supertext {
1 d7 P. R6 U/ @3 q. G7 y0 }position:absolute;1 a4 t/ v& V  q# }( k
left:0;5 w: w4 x6 V: K% \4 R8 n- E" N
top:0;
' F  k( u% ^5 @( h4 W) ?. ~! c0 Wvisibility:hide;
) e4 K( ?3 T5 ^4 x. Rvisibility:hidden;
8 S. }7 Y" R8 W* j3 M" h  H2 ~}
- u) I, _9 L" u% Y6 ]</style># I7 k: R! A5 @& m/ }1 l
<script language="JavaScript1.2">
: U1 ?. `3 o% G3 |3 w5 C, |<!-- 改变下的字体的大小。颜色-->5 u3 k9 l$ x: {6 a+ L
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 O! J7 l$ B3 B1 \% C& J: h2 ]var hidetimer='';
3 {/ m3 b0 D9 C4 b<!-- 改变下的弹跳速度-->/ L  l3 F5 M* g  V/ d
var BallSpeed = 20;- l- u/ g! c1 M  l6 X
var contentWidth;
. n+ _  l: @1 kvar contentHeight;% C* {/ y2 V. [5 g2 F) @6 V
var maxBallSpeed = 50;; @& l8 C6 p( K  h6 Y/ _" n1 o
, X  S2 f9 [% }: n1 H* X

7 W8 [/ I& `5 _% [- Q; m+ h# {( ^4 g+ Lvar xMax;
; w  `. x4 K8 }4 C% S. |' N) V6 F& ?var yMax;) J" K/ W: `8 n" y7 j1 A9 a
var xPos = 0;% V% K) L! f! u# o2 n( K0 Z
var yPos = 0;
( D2 S  B+ b! w! h, j& j' a- i# Mvar xDir = 'right';
" A! f4 @, s1 Kvar yDir = 'down';
9 ?1 ^0 n% u9 tvar superballRunning = true;1 L8 B7 [+ C' V; U
var tempBallSpeed;" i9 p" h. T" `( W! z2 y
var currentBallSrc;
% m0 I# p+ A9 L' Zvar newXDir;
) R! J1 \! h& ?8 Z5 xvar newYDir;, W# k/ `& |, H# \

6 x" ]! x* y2 e. X( v% q- n9 H+ Wfunction initializeBall() {
! h( ~5 \$ z2 O7 |; H) c   if (document.all) {
1 a9 D7 `/ c4 |; R4 m1 k; D      xMax = document.body.clientWidth% V. O& r: c4 a1 a+ D/ \; J8 \
      yMax = document.body.clientHeight
+ e: R" r' P0 @" b2 B      document.all("supertext").style.visibility = "visible";
1 |9 z4 A7 m" ?- S4 Z      contentWidth=supertext.offsetWidth1 d' m( b+ \- V4 `
      contentHeight=supertext.offsetHeight
' ^* ^) j( V7 U6 u7 L" J( @      }
' \/ o' [6 E0 l4 P   else if (document.layers) {
1 m- g# k, h9 W% c% k; l      xMax = window.innerWidth;
3 M% x3 X3 G; h& B& E: g      yMax = window.innerHeight;; [, S2 r7 Q5 ^5 g: _- I  r, B
      contentWidth=document.supertext.document.width4 r1 j8 G) e3 v& {
      contentHeight=document.supertext.document.height
' _. c1 x) O! W' |1 E8 V; l      document.layers["supertext"].visibility = "show";- f: [7 ]4 Q+ n- N. L* C
      }
( n" z7 V; U9 d& Q+ ^   setTimeout('moveBall()',400);# M/ e5 \. f! i! x; q
   if (hidetimer!='')
) M) u5 C) Y* A   setTimeout("hidetext()",hidetimer)
$ H+ \$ r% I; V' H3 q   }
% a) P; E1 Z+ Y1 |2 s6 @# P2 f" E4 Y8 r, W" V6 T8 F
function moveBall() {- S4 i! `, m: o! v
   if (superballRunning == true) {" ^1 \6 N1 t$ O, L
      calculatePosition();4 t7 D( H) _; d! l5 b
      if (document.all) {+ c+ }# \8 M2 y. h6 }& S+ r1 A
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. t9 d  e1 w5 |& J- z         document.all("supertext").style.top = yPos + document.body.scrollTop;
' q) d2 [- ]4 m3 E7 O" _         }
% N8 g5 g9 d* ]: T      else if (document.layers) {# [5 K9 @/ @0 P* }! O9 q. C) f
         document.layers["supertext"].left = xPos + pageXOffset;
" L; z+ ~" F5 o+ ~+ M# N1 ?         document.layers["supertext"].top = yPos + pageYOffset;- F7 Y9 _) i9 O, |$ A5 A
         }6 ~, e$ C* {$ w; p- T6 w0 p
      animatetext=setTimeout('moveBall()',20);! x" {2 k$ _9 h9 b0 J9 ]' }) w
      }* r. e! q8 s- R! s$ X! J
   }
0 e/ s: i" c( f0 A/ Z& A# b6 f7 A0 F4 J4 ~$ L9 a' I: @: D
function calculatePosition() {
! r) Z: B4 i& |  k7 a   if (xDir == "right") {8 q( L- F3 m3 P* V- e- r
      if (xPos > (xMax - contentWidth - BallSpeed)) {% J$ q  |4 \7 n5 p
         xDir = "left";
, z$ i: V# e% {$ o4 b" M) ~( J         }7 f) E- J3 i! M6 _6 F1 U
      }
6 E+ K+ K% K- v* M' a( u% k   else if (xDir == "left") {
. C( _! {! N* l9 r9 O( T/ {5 q" u      if (xPos < (0 + BallSpeed)) {
, f+ M# p2 E' E. k8 K! x7 h         xDir = "right";9 O/ e# e6 H, D: e+ m2 @
         }. U3 k# e" q! c/ ]# X
      }
/ ?0 ]$ }" @* B) i; I   if (yDir == "down") {. T6 z. {7 i2 ~1 e
      if (yPos > (yMax - contentHeight - BallSpeed)) {9 N3 N5 X) t. b" M
         yDir = "up";: i$ v. p# t$ z% }; |
         }
7 P$ t, [, o6 ^9 n0 O" S      }2 H! X5 q: e8 d# Y
   else if (yDir == "up") {: R+ X! S8 k. v- Y3 i$ G
      if (yPos < (0 + BallSpeed)) {% j. `5 e+ z. Z  K) s& _
         yDir = "down";
" _6 D$ k- c, B( R         }
4 u4 n+ B7 s8 ]      }
6 y/ i+ L; v0 }: s   if (xDir == "right") {
% t9 D1 L- Y1 y& P      xPos = xPos + BallSpeed;+ v: ^6 u# _( e! Z8 {% H$ C- c* B
      }+ k4 l2 x! g; x' T2 S* c& ], v
   else if (xDir == "left") {* [* @3 O& l. h) z6 R( E
      xPos = xPos - BallSpeed;9 S7 x2 ]: ?; v9 A$ a& `( Z% M
      }
' z; {3 q. H9 E8 y7 T. O   else {. c2 X& Q7 X" R9 f
      xPos = xPos;( q7 \5 r; s+ T3 a
      }
' J- u+ R; ^; L( J% {! |! a8 j   if (yDir == "down") {" P6 `" j7 x3 [1 j- I4 \  r; B
      yPos = yPos + BallSpeed;
7 }8 C, v# k1 h" [. `      }
3 f# i$ x; \6 |- q& @   else if (yDir == "up") {" p: U8 ~, S5 C7 F5 y! B! D% r- n
      yPos = yPos - BallSpeed;
% d: t' o, G: f+ H$ P" Z/ E      }9 A( \/ q: X  s# C
   else {
, k- v# P) u% C" f      yPos = yPos;
8 _6 S3 t* q+ c2 T$ ]      }
' |# u" J! h. X   }4 |  M& D' J+ v$ o
7 ], t# _( d; z
function hidetext(){$ K8 X# D) ]/ G
if (document.all)9 D) v- _1 e' I9 C) `; ^, U
supertext.style.visibility="hidden"1 a6 w" U# S) F9 t
else if (document.layers)  d1 l$ l5 Z9 X" y+ `/ y0 v
document.supertext.visibility="hide"
( Y* M6 ^2 H  S( x$ CclearTimeout(animatetext)  J/ C0 _; Q; h, N
}( X" U+ T6 R3 Y$ \4 v
9 Q$ D5 v2 A7 D0 d
if (document.all||document.layers){+ I3 e; S; y! V# v5 v$ X2 X2 T
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" \9 s& J; P! r3 _0 pwindow.onload = initializeBall;: V% @, N0 o1 e0 n9 E# w" ]! n
window.onresize = new Function("window.location.reload()");
' ^! @: L  z2 |) V* r}- g; o% J4 U/ a3 X8 d5 e' f

7 @. O: U6 s/ o</script>

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