返回列表 发帖

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

<style type="text/css">( s5 ^* k2 s3 |" x! \7 S+ u: p
#supertext {
. b6 b* U  r$ P- x0 Gposition:absolute;, \: @$ F* @2 a* J
left:0;) W) n& U' ?( \5 S5 A
top:0;. q7 C, h  k+ h: h: Q! a
visibility:hide;7 u' N: H4 L6 [$ s
visibility:hidden;+ I/ K) k/ J. L3 N0 [4 H5 Y
}# i% o4 Y) k7 w
</style>
& ~4 v* L. b: t/ G, ]<script language="JavaScript1.2">
4 I  N9 v$ C9 v1 r' @* Y" o, l1 |<!-- 改变下的字体的大小。颜色-->
8 p$ y- y3 H$ @& Tvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'( s/ B. Q; v; f# v' x' c
var hidetimer='';
6 s0 ^9 M& }3 C, f+ f3 \<!-- 改变下的弹跳速度-->& x5 O) a) B5 f# Y. M* {- G7 C  M
var BallSpeed = 20;# Q( Y% R. y8 o8 c# k
var contentWidth;
. {6 C* k: t; b4 Kvar contentHeight;+ i# a' d- h3 R4 z( L0 C' g! \
var maxBallSpeed = 50;
5 k8 q+ H" K" f; U: U& q$ x; ?  o  ?9 ^- w' l
! C) n  ]0 T8 G/ L; F( x! m( H8 [0 O# b
var xMax;
0 H: c/ K" ^$ ]: evar yMax;6 V' d( \9 P# }# t0 G' q' l5 s/ n
var xPos = 0;
  w$ W! u" D( d' d( ^var yPos = 0;
; c8 G% n6 V& W3 d/ @  p6 ?var xDir = 'right';
1 I' G8 \1 z/ e$ Z+ p. c, j* t8 Jvar yDir = 'down';# b' n; \; K" s$ [
var superballRunning = true;& V" q- e+ S& h
var tempBallSpeed;" L3 b! p6 x# ?
var currentBallSrc;0 Y: a: y2 i' _9 ?5 C" j4 O
var newXDir;
+ g0 B+ ~& M" e/ r! [7 \var newYDir;* [1 W! _# ]  r  ?: w

) p6 d% i# Y9 k  o6 S) Lfunction initializeBall() {# N7 Y1 j1 f6 W% g# ?
   if (document.all) {
, s/ b! X, W0 _% X      xMax = document.body.clientWidth
; J6 [- L  r4 J      yMax = document.body.clientHeight1 p3 e" i3 q/ p1 _* T  m
      document.all("supertext").style.visibility = "visible";, r. P/ [$ Z7 O7 P2 Q4 j6 w# C; S
      contentWidth=supertext.offsetWidth2 m8 t7 C" _: j9 K+ G1 J
      contentHeight=supertext.offsetHeight/ t( O6 v: z. o. X
      }
& C4 n" S& M( N   else if (document.layers) {  X+ n9 h2 ?4 @- r0 s5 \' n0 N
      xMax = window.innerWidth;
: U/ N  W& J( W; h      yMax = window.innerHeight;. Z. R  U) g1 b. m! Q0 Y8 o5 v
      contentWidth=document.supertext.document.width; a( Z" k- h3 [" l2 h. J$ c. k$ C
      contentHeight=document.supertext.document.height% C, a2 g/ u$ H# ]
      document.layers["supertext"].visibility = "show";6 D4 F7 C. b* r/ B
      }
8 R, D! O9 O) S8 R( H   setTimeout('moveBall()',400);
# K; W; \0 q* U0 s3 H" l5 J   if (hidetimer!='')5 T$ x5 n. Z& J- s
   setTimeout("hidetext()",hidetimer)6 r6 m: b6 w. L1 _3 t( [
   }9 O# X0 D4 L9 Z- [5 L- V3 [

7 h3 R) ?! X/ F! s" m0 a  {* ufunction moveBall() {. [+ K' [$ Q: X% ?
   if (superballRunning == true) {( T, n: A$ P+ l
      calculatePosition();& B- _: x) g- e/ M) }- @
      if (document.all) {$ h: {4 i4 [7 q' A
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
! B7 w% F: W" s9 ?         document.all("supertext").style.top = yPos + document.body.scrollTop;  w8 w( `& b$ L, z; l7 J, U% c
         }
$ y1 ?/ Y8 J7 P/ {2 a, `+ }* I      else if (document.layers) {
3 x! {1 n. [5 b+ o" P. t         document.layers["supertext"].left = xPos + pageXOffset;
/ C+ |: m# _! q% J( G         document.layers["supertext"].top = yPos + pageYOffset;
% ?9 E4 X/ w2 ^* |. G/ Y4 w" D         }
6 }1 c$ L3 H1 h4 R      animatetext=setTimeout('moveBall()',20);
+ b, _7 }0 C% j: }9 I6 G% x      }
! E) c) @5 q/ H   }# v8 d. S% U: s# }9 g1 W1 s
+ q6 N+ p4 g. j4 p: \8 A, j
function calculatePosition() {
7 F1 n" j$ Q: b* c+ `* H   if (xDir == "right") {9 q- B& h5 c* c
      if (xPos > (xMax - contentWidth - BallSpeed)) {; J" Q! I( |5 j+ s6 ~# j- n% I# L1 `. f
         xDir = "left";
- T- X/ S7 O. ^& l( V         }
) G4 G: _5 U# O% o0 P! A      }2 T, K' b0 O* a
   else if (xDir == "left") {* l% |2 P* R2 U( D: [( Z3 J
      if (xPos < (0 + BallSpeed)) {
6 ?# C- W0 \$ _4 K5 `( O3 E         xDir = "right";% O. Z; [) w4 i) L) ^
         }
1 V8 T) i+ C$ \# e% ]      }: f* M) R" v% D7 S
   if (yDir == "down") {. n1 O! M! Y# |2 k% A8 H/ V4 X
      if (yPos > (yMax - contentHeight - BallSpeed)) {
; `. m: [4 b7 L( V3 G4 v1 I# e         yDir = "up";/ y  e- v$ k4 s# ]# [4 h
         }
+ D  M& L4 m9 e9 b! y) b2 O      }
; x+ [. D' R. r4 b; h) ~" T9 f0 a' V   else if (yDir == "up") {: m3 M3 a* Y/ I; x
      if (yPos < (0 + BallSpeed)) {
: }' J: R# Q& ^" w9 ?         yDir = "down";: d! A8 y# Q3 D2 l5 V# Z% ]
         }8 N2 z! X/ x3 [4 V. N7 I0 c8 B. A" I/ g
      }: N7 K5 a; p6 K( q7 x& D  W
   if (xDir == "right") {  k' y! ~; @$ N( x  r( d
      xPos = xPos + BallSpeed;# h" h2 N# l9 u
      }
3 H6 k* ?, t' G- j   else if (xDir == "left") {/ K- L9 W3 I( s* b" {( l1 o6 G7 L
      xPos = xPos - BallSpeed;/ k8 @0 k+ S7 a' x# |
      }" S# x8 d- P/ Y% C
   else {: U5 D* J' |- R; b1 Y
      xPos = xPos;
) `! y! z& Y* f2 H" R      }
  G& M2 f- a' w( T, e% q   if (yDir == "down") {  ~- s# F# [2 V+ [. i
      yPos = yPos + BallSpeed;4 L+ s  D) K  ~8 p8 D$ O
      }5 A/ B: }# g4 N8 z4 p, K' D2 J
   else if (yDir == "up") {! l* P2 N- p* y! q' l7 A
      yPos = yPos - BallSpeed;& e" m( [$ K) ~2 n$ H7 i
      }3 e- n7 D. D2 l$ c
   else {: Y$ u' h# }$ A8 ]" z2 e6 r- t5 [
      yPos = yPos;2 Y. j/ w  ~, v& H
      }: {* k" B' V; m' Y: @3 a2 c( H/ [
   }
( r: \: G$ y" b+ H; @* o/ q$ D8 `& T- F2 C) E
function hidetext(){' x% n* {+ U- _) N% r) F. x
if (document.all)
6 C, m3 Z( I" s7 s1 bsupertext.style.visibility="hidden". d5 c9 c& p/ a6 u
else if (document.layers)
. E( ], L' N$ i6 ?3 ~2 P2 J9 edocument.supertext.visibility="hide"- I3 T; j) b9 b( z
clearTimeout(animatetext)
' {+ \3 P, }: R& f% u}
9 k7 u" `5 H2 Q: F7 A8 x( ?$ u8 |2 Y" A& p
if (document.all||document.layers){4 V" g3 [. C8 \& L
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 e1 [' ?0 h4 }& X4 {$ a: l( L
window.onload = initializeBall;3 a4 t$ ~2 m8 P! _: ?8 Y. v: C
window.onresize = new Function("window.location.reload()");: C, V2 n+ p' w6 j
}5 I: C4 A  F0 I9 B! B7 q, Z

& Y. b# N$ C6 G. Z- A6 i* D8 w</script>

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