返回列表 发帖

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

<style type="text/css">
& y; e& ]1 m6 V5 O8 k2 _6 a9 {#supertext {% o4 `) N9 P. o; o* }& n
position:absolute;/ Y, M0 B6 k7 |* {5 @
left:0;
" S  o7 }% f7 `/ |top:0;8 V  h" e: J, ?+ `
visibility:hide;; C6 P! {  c  y) c7 S" T
visibility:hidden;9 f" I+ Z8 h5 l' c, w( i/ n
}8 `) k4 C4 i0 r$ x+ z
</style>3 c1 Z! f3 d# `3 W  K
<script language="JavaScript1.2">
! c& L" a8 l5 @% e, H$ h<!-- 改变下的字体的大小。颜色-->
# u2 c" s+ n& m8 b6 {+ B' dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ m9 g0 Z% p6 J8 ^3 I  l/ w
var hidetimer='';  M' f7 J- i, }$ i: g8 j3 V- Z# E
<!-- 改变下的弹跳速度-->3 ^! N% x; F+ w/ G8 j+ F
var BallSpeed = 20;
  I6 y2 P! N2 O) S" |var contentWidth;
2 E' Y9 y7 Z$ w" z( M6 Yvar contentHeight;+ ]+ a) r" ~& a, N, ^1 r  |+ q+ Q
var maxBallSpeed = 50;
; K0 |  B! \- j# m
# k4 y7 k" V3 S. E/ R) n" C( U+ c+ V5 V8 x. e
var xMax;. ]2 S: v5 D* x+ X, t7 V% f; p
var yMax;
, d& b  o6 l# s  @; `$ lvar xPos = 0;% O6 |/ U$ [  j
var yPos = 0;& L- n* x1 T3 K# g( {1 y$ |& L
var xDir = 'right';
) c, ]7 ~! _$ x( n. D2 zvar yDir = 'down';
2 a1 l/ F( Q7 g) r; s4 M; gvar superballRunning = true;8 |. w3 l4 o- I5 B8 ?: W" n% W9 c
var tempBallSpeed;
0 A8 q1 s$ q- c6 v6 Bvar currentBallSrc;, F( S" }6 g. S- o
var newXDir;  J( N  L3 ]3 j8 m* [7 M  W
var newYDir;
: s7 C6 G, W, N
: w8 l" A% X2 h' W9 E/ b3 g: Gfunction initializeBall() {( Y6 @; @3 M$ V5 ^, C; ^% K
   if (document.all) {8 G* C' Q- r% w
      xMax = document.body.clientWidth
; E& |. q8 M2 H      yMax = document.body.clientHeight/ s% W, V$ C: l$ d
      document.all("supertext").style.visibility = "visible";
% f; B4 v# u* s$ ?/ r      contentWidth=supertext.offsetWidth
% k* o5 t7 {" C2 i$ S: k; I      contentHeight=supertext.offsetHeight! M' v: t5 D! \+ ?3 b! u
      }% [2 `. }; V. ?6 |5 P+ y# N
   else if (document.layers) {, g# p, d) W/ \* H* a
      xMax = window.innerWidth;  q8 F0 c+ i3 p- d! j9 P# p) q
      yMax = window.innerHeight;% w% ]9 n1 o3 j) [: f3 _
      contentWidth=document.supertext.document.width; R0 |' c) [0 M0 [; T- E8 u
      contentHeight=document.supertext.document.height" F4 `! f4 u. R; o  a; y
      document.layers["supertext"].visibility = "show";9 t+ S1 D2 m% M& K7 {. ^
      }
! M. C6 i: N- ?* I   setTimeout('moveBall()',400);
2 E3 [0 W, d( f6 Q, I6 I   if (hidetimer!='')
/ W* {. |0 t0 o% N0 w5 G  v+ B3 B   setTimeout("hidetext()",hidetimer)5 c0 I, y7 U( j$ j  U& a
   }
% s8 |  \( P) Y4 @
. z# w* p# Y' ifunction moveBall() {
2 h2 G! L; D7 }7 _, m; |1 t   if (superballRunning == true) {
* ^9 ]) g5 t. |; t! y$ K; P      calculatePosition();& G0 b" r7 U0 Z; w) k+ X' }% g
      if (document.all) {7 g5 k; q. N8 y1 ?' Q! \
         document.all("supertext").style.left = xPos + document.body.scrollLeft;1 |6 R2 X- ^1 y- M
         document.all("supertext").style.top = yPos + document.body.scrollTop;. ?( E9 P6 K7 ]* b5 [' H  b# Q
         }+ c5 h7 S4 X* ^  F
      else if (document.layers) {
# k# {# P+ m2 \! K% g- ]4 _) g         document.layers["supertext"].left = xPos + pageXOffset;# |- Z5 e( W( W. D/ p& d4 v
         document.layers["supertext"].top = yPos + pageYOffset;0 C; _: Y2 T9 _4 B# L: x7 D& i1 \
         }( G* }; Y$ {! T- c. u3 S
      animatetext=setTimeout('moveBall()',20);
) P3 e: m2 `* h( C      }2 s) g7 \8 {/ s7 }7 f9 [: L; M
   }
% `7 N5 E, ?% `. i0 B0 t
* y! C9 h/ w9 P) wfunction calculatePosition() {
  a  K5 h/ M$ z  ?5 R7 _   if (xDir == "right") {
2 Z# X" R0 u4 j9 H% M      if (xPos > (xMax - contentWidth - BallSpeed)) {
! {0 i. g; g' Y! @$ E         xDir = "left";% s- g* E2 X$ b7 h5 |$ K
         }3 `8 _8 B. N. f; \8 _
      }$ x% y1 F+ w( C' h
   else if (xDir == "left") {  G$ f  _  H! i1 i5 D" Y* _
      if (xPos < (0 + BallSpeed)) {
; p; z- s' h/ M& X* O/ V         xDir = "right";+ O4 h# m8 T# }
         }! I' O5 M: o6 f+ f1 O2 U
      }
8 H+ Y, V4 \8 e1 c   if (yDir == "down") {+ |' {1 F$ [# o+ `$ }( q! Z
      if (yPos > (yMax - contentHeight - BallSpeed)) {: |7 |- N" t# ^- D7 n
         yDir = "up";; X% x. O) L  s5 E, Q0 O2 F
         }  b+ G4 Z! P9 e
      }
1 ~" Q- J5 S" U8 q! `& b   else if (yDir == "up") {% H# Q+ ~+ n8 m9 n4 q
      if (yPos < (0 + BallSpeed)) {1 U: S! N& K" `
         yDir = "down";
! ]7 j8 N2 z! C/ J         }$ b5 P5 U9 l2 h
      }$ {- ]' r5 n7 i7 Z9 F9 S& C+ C% q
   if (xDir == "right") {
) D. u2 M) l7 A+ Q      xPos = xPos + BallSpeed;
' V7 I2 x# E5 w% W; D# {& B      }
% b( D8 }" A: v1 R   else if (xDir == "left") {# P9 e9 n# P6 G0 k% U
      xPos = xPos - BallSpeed;
3 ]( Z3 a7 C; y      }
% d, T+ j! w7 r4 b1 _9 x8 U   else {
1 k  B2 M* l7 p$ c) K; e      xPos = xPos;
' K6 f8 D6 \6 e      }, S# g, a! x3 Y
   if (yDir == "down") {* l+ e9 P" l( I* T  `  d
      yPos = yPos + BallSpeed;8 l) d' E. B; e( Q
      }( P( o8 i* L) U: R' n, G
   else if (yDir == "up") {8 J8 ~3 H4 u2 c# f
      yPos = yPos - BallSpeed;9 F4 a  H: }- a7 J- E
      }
4 w5 u0 r4 b8 @   else {5 l+ q: ^' I8 u7 J" @
      yPos = yPos;9 i" A( |5 g6 m, X' K. k' J
      }. M' d, n5 }: c( ^; J( V" S
   }
. O# N1 {/ o# f  q$ h" A- j, e) u# l7 u, q- h' F7 d
function hidetext(){) b8 H. V0 S6 N* @
if (document.all)
5 X5 K+ T: m' nsupertext.style.visibility="hidden"6 M6 f8 n% x2 P. g) |1 w- P: c$ N
else if (document.layers)
# ]  \3 J# A+ Z9 Ldocument.supertext.visibility="hide"! c% x8 a$ K+ a; k1 ?7 \
clearTimeout(animatetext)* b! n4 e1 a( N8 ?
}. l# U2 }6 a- E* ?

% h. X7 `7 Y, f+ sif (document.all||document.layers){
( A+ ?9 F3 v: w2 a$ g9 ?6 A5 g3 Z4 Wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
, A* ?. P0 w6 D0 X0 vwindow.onload = initializeBall;$ A( y" H* f0 C0 E! {
window.onresize = new Function("window.location.reload()");) t1 W% k3 B& T/ ^  |! }
}( \0 n/ x7 X: S# H' t1 r
# W1 V: k+ C$ M. a+ b# k9 G! m
</script>

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