返回列表 发帖

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

<style type="text/css">* e0 t. e7 M5 ]5 V; l' ]
#supertext {
3 \/ c  W0 l/ x8 Gposition:absolute;
0 V0 {; f: H  V8 {" ^' vleft:0;
+ G! ^" a0 K" a# d0 e+ |top:0;% _* ^7 Q* {2 g( V0 j8 w" B
visibility:hide;4 T. N) ?  P6 m: x4 N. z% b- U
visibility:hidden;
' a4 t; t  {; O, o6 }( e  Q. M}
5 N9 r5 t( b% u" N% U</style>
; d/ l8 p$ U% q' |+ r9 ^7 p<script language="JavaScript1.2">+ d/ x3 q" q$ I
<!-- 改变下的字体的大小。颜色-->
1 H( I+ K! f/ f! `9 Pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 A3 ?0 c1 q! _6 i/ ^$ c, _6 {5 Yvar hidetimer='';7 q- W4 }% Q$ T1 D- T4 |
<!-- 改变下的弹跳速度-->
8 f1 c& n+ Z# t; o6 N! I, Nvar BallSpeed = 20;
3 B3 z0 i- R" R& ^3 Yvar contentWidth;  g7 Y; o& D  @& }
var contentHeight;
9 }& R8 |  J9 d! j# T0 Y6 D3 bvar maxBallSpeed = 50;
9 T5 M( ~2 B$ v+ i
+ t4 J2 |# H. {0 K! t  {
0 ?" I6 t$ m0 f% N& L/ }var xMax;+ U6 H- j; m# a+ Q% e( `
var yMax;0 A7 Y& x- Y' h+ l7 z; w$ o& X' t
var xPos = 0;
" I. T# N8 h) K! n* I8 tvar yPos = 0;, S2 n. F+ C' J# X# n" V( H
var xDir = 'right';
, v) V. w7 V4 ~& ?, V. @  y4 s' o% Vvar yDir = 'down';9 H0 m! x3 P+ \
var superballRunning = true;
8 f$ m8 y) W- e% [var tempBallSpeed;  G9 F" Y7 D  k5 n
var currentBallSrc;9 h& _7 ~- U& W& Z; E
var newXDir;
1 R; e. M9 h( D$ y8 y0 Rvar newYDir;
: d# l4 Z! i* |, n  H+ M. g9 Z5 O4 F/ d. e
function initializeBall() {7 Q0 |( e% N6 @) a/ P' }9 B+ u
   if (document.all) {
' w" W; l" d1 i2 M8 x8 P$ x      xMax = document.body.clientWidth- S$ S+ D! X8 P, _
      yMax = document.body.clientHeight- D" Z: V$ @  |6 I* j7 v
      document.all("supertext").style.visibility = "visible";
6 V8 |7 q; t* D' q, u) P. o      contentWidth=supertext.offsetWidth
3 L$ @9 u; Q; Y$ ^' W' b      contentHeight=supertext.offsetHeight
1 T3 F" O& ~8 s$ s5 T      }7 M. w0 ]* z5 F& ^
   else if (document.layers) {
2 @) w2 E8 t4 _* c+ u5 a      xMax = window.innerWidth;2 }# t" M: d) }
      yMax = window.innerHeight;* y, s7 ^1 p0 i5 M
      contentWidth=document.supertext.document.width
& w+ H3 b: Z7 _      contentHeight=document.supertext.document.height2 g. E# w* o: w# M& H, b  n
      document.layers["supertext"].visibility = "show";
8 B) f! V( q8 ^% u      }- V; f7 [1 e$ j
   setTimeout('moveBall()',400);# x! `8 l: p4 E( }
   if (hidetimer!='')
  |! l% |( E* `# y. V6 e6 K4 T; B4 ]   setTimeout("hidetext()",hidetimer)
; {) S& A2 u* a" G. M   }
/ [9 s; H& Y; k7 U( q: ]# S9 Q4 c- o/ U
function moveBall() {
1 X2 Y+ p  e; k4 T/ [* H   if (superballRunning == true) {) M* A  K: b. v" C0 R7 _6 M
      calculatePosition();
3 V2 N2 G+ M! K& ^& q      if (document.all) {
* Z# X" U" m3 t         document.all("supertext").style.left = xPos + document.body.scrollLeft;) A3 Y- z. O# ?! C' [2 L  m
         document.all("supertext").style.top = yPos + document.body.scrollTop;
# I7 n" U1 F" h; p         }1 P9 B5 h* u) `' O. Q8 m
      else if (document.layers) {; U* R' H8 y# W8 v1 g
         document.layers["supertext"].left = xPos + pageXOffset;
$ E4 [1 }# }5 B7 i* n" i8 l         document.layers["supertext"].top = yPos + pageYOffset;2 i/ b* [  s/ U; E1 f" E
         }; \7 F3 x& j' [+ K* G& k1 e$ R
      animatetext=setTimeout('moveBall()',20);8 [6 _$ R3 X5 {! b* e4 u6 Z
      }
( s9 f6 B. i0 O   }' b! s* ?& V7 U5 ?
- v. Q# }8 j( R2 ^
function calculatePosition() {
+ t5 e) a# l1 \   if (xDir == "right") {
# M! ]; r) p8 ]' N1 G/ w+ h# C2 l      if (xPos > (xMax - contentWidth - BallSpeed)) {
4 b8 R" p" R$ K# u         xDir = "left";4 ^/ z! j2 T0 h0 J- k
         }
3 l) c& h, h3 i; h# ^      }
  e2 E) V1 x2 D   else if (xDir == "left") {2 E. w8 l" M; `. }: `
      if (xPos < (0 + BallSpeed)) {; n3 t8 w9 U" I; N. `" e
         xDir = "right";' i% q# E, B$ l
         }
6 d8 X2 `" y% F' `. f7 R! s      }, p. D( V% O) P
   if (yDir == "down") {* H" V5 q0 p8 U7 x- X& D
      if (yPos > (yMax - contentHeight - BallSpeed)) {
4 N2 m/ U# S. R# f- ?& J( i         yDir = "up";
6 |, R5 H  N5 x) w8 b2 C/ c         }+ j0 Y  z( m* \' M5 W# ^
      }
& D3 x! _3 o% ?   else if (yDir == "up") {+ e' [" Z. t  _; D: ?7 A) M
      if (yPos < (0 + BallSpeed)) {5 o" y6 l0 z* h/ y% @, i
         yDir = "down";
' q) ~( i9 M$ \% X2 z         }
" a9 o( o) K. e0 l! O8 _. `      }
: G: z3 a* K2 v5 k   if (xDir == "right") {, P! ~4 |  S( o9 D
      xPos = xPos + BallSpeed;
+ G% `3 Z% b+ G5 Z3 s! p      }
" t! @  @, o+ U( ^& [) A7 B1 I5 |   else if (xDir == "left") {6 y, D+ I" y- D: N
      xPos = xPos - BallSpeed;
1 I0 B3 H& m% C      }. ?# Q# G7 E, E! h! D
   else {
: p/ h2 l! f0 D4 t      xPos = xPos;
' B+ L5 j5 m2 R4 F* m0 r      }
: k! R+ ]; [! T  K   if (yDir == "down") {
* H' Y' i, X$ R3 n0 ]      yPos = yPos + BallSpeed;
2 \7 l8 K0 E7 [' c* l/ I! H& `      }
3 ^& i. ?0 j  h7 u- d- I; R7 {7 F   else if (yDir == "up") {
+ p9 ]6 ^$ B+ q- f, r      yPos = yPos - BallSpeed;) v4 x; F1 n. h# l7 P7 [' y
      }4 e: A" {8 X% Q4 s# N7 u
   else {
" ?% M) s1 S# }5 n4 w( K      yPos = yPos;, R9 x0 y7 a! F+ |& M
      }
7 u0 [. W/ r, e+ h   }1 |+ N' ^) Y: C  [4 k, S0 F' N4 K6 A

; G) ]: a; Y$ d1 E8 B/ w: Wfunction hidetext(){
  A% G$ G& o  F5 o: u( Bif (document.all)
# @( t  M4 K; Usupertext.style.visibility="hidden"
; E9 A. V; x8 Q+ oelse if (document.layers)
" t5 g& t* y4 J' c; v( V: ldocument.supertext.visibility="hide"
' d5 H6 n* t2 N- ?8 x4 f7 `% o& SclearTimeout(animatetext)
6 @+ z3 ^1 `" _: N( Z" }}  m: ^8 l* Z9 k# m7 R

9 t- w4 I6 l! v  ?if (document.all||document.layers){9 F, z/ m! [- v& F- w
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')  H' g+ [3 v: O- U, N. r: U
window.onload = initializeBall;/ E0 ]  Z* A$ ^. Z
window.onresize = new Function("window.location.reload()");" W: ]1 c2 ^0 o0 ]3 ]5 n
}
5 U$ k9 f5 k6 r) y
1 @- y9 W6 ~/ M0 e</script>

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