返回列表 发帖

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

<style type="text/css">
6 T% _& K/ h2 S- a#supertext {
0 c  u3 ?! a: g* o; @* Wposition:absolute;, C  O+ T/ ~" v6 h, @4 B4 m
left:0;
9 `3 \" i9 X8 }4 I5 Ktop:0;! j! ?! X" ?9 c) u1 l7 G4 p, H1 N
visibility:hide;8 g8 T- e& p4 {6 F9 O
visibility:hidden;
- z1 v4 P' b+ [6 e" {& v}) L# O) A% H. F, a! f, ?0 ]: W
</style>
# ~/ h& e9 W3 h. y4 q: R  I% C<script language="JavaScript1.2">
0 b5 m+ ?# J4 p9 u: }- i<!-- 改变下的字体的大小。颜色-->, I. Y* `8 e8 N
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. G) t, `. ^4 [% q4 {, I
var hidetimer='';& J4 L& ~- V& x5 H, B# q( O
<!-- 改变下的弹跳速度-->7 o3 S7 Q% _- C/ _+ J6 C4 t8 ~' \2 _
var BallSpeed = 20;
6 F5 s) R0 ^8 E1 f6 a5 l( M' vvar contentWidth;
7 \/ C. E$ c5 y  cvar contentHeight;
# ~& z4 z3 k9 y. P6 Kvar maxBallSpeed = 50;
* v1 c5 b4 G$ c+ [8 j+ N
/ E9 X8 q# n6 H/ Q6 m/ I9 o, n7 }3 ]# M7 z! `
var xMax;# i8 S1 G/ t6 b0 z" Q
var yMax;
" ]" A: Z. C4 ~  M$ X: Xvar xPos = 0;( D2 m7 H2 v% d5 n( C
var yPos = 0;: T3 O* a% y1 t# Y- T5 C
var xDir = 'right';; [; Q% Y+ ~. b' t( R( T
var yDir = 'down';+ B8 A4 i) u. D; |* }& @! B
var superballRunning = true;7 l4 L* `& u0 g5 S3 Y+ Q3 ]
var tempBallSpeed;
" q- y0 |7 C5 w- m1 ]1 T; Qvar currentBallSrc;+ ]8 P. [6 _4 D1 r1 j! |4 O0 `$ Z
var newXDir;
, I! ?8 o; @, j; G1 Yvar newYDir;
7 E  l1 p# S6 }) j2 ~4 C; ^) u% ~( [% [% k" y4 m+ p' b
function initializeBall() {
8 t$ S9 M, N9 J4 P   if (document.all) {
, v8 w( R# ^* A8 s. }. Z      xMax = document.body.clientWidth
% [" q9 d$ {8 e) H      yMax = document.body.clientHeight
* C) a% v) I* A+ s2 z      document.all("supertext").style.visibility = "visible";$ `* C4 I' C; ?; b0 R
      contentWidth=supertext.offsetWidth
5 A) B$ D! H* G" m8 z) R0 |      contentHeight=supertext.offsetHeight$ |3 ]4 K$ A3 ~; z- t) g- d
      }6 u) e# k) q2 ]; O  O. T" T' |/ T8 A
   else if (document.layers) {
( r9 w. P9 S) [/ C! e( {/ M      xMax = window.innerWidth;5 T1 p2 Z7 b# A0 P2 @
      yMax = window.innerHeight;
1 g, g. C7 y, p( E  B* z2 f2 k/ Q      contentWidth=document.supertext.document.width) c; [3 S  w; S3 K  j; a# Z0 M
      contentHeight=document.supertext.document.height3 t9 Y9 k& m% B! ^  I/ C2 V3 N& {
      document.layers["supertext"].visibility = "show";
% g" b6 _+ }6 M, f9 b      }. z6 g% k4 E, V- y
   setTimeout('moveBall()',400);) B' z1 X& {( D% V- k
   if (hidetimer!='')
. e0 M. }$ _" x* L" n; {   setTimeout("hidetext()",hidetimer)- \0 P/ q. {" m, @' A) |  g
   }
; C! i7 y" h+ y1 a( P/ ?- ?2 v$ `" z
function moveBall() {
* g) t* k7 d3 T: ?  Z   if (superballRunning == true) {& x" X" r3 S% y
      calculatePosition();
: X' l  L9 u- |1 B      if (document.all) {
' x) S0 t1 a8 P- {         document.all("supertext").style.left = xPos + document.body.scrollLeft;* T5 t& a0 P1 F) t6 s0 P4 c9 ^) w% ^
         document.all("supertext").style.top = yPos + document.body.scrollTop;
. U3 _7 s7 A* n# W2 `% h$ S         }
# M) B5 z/ P4 m      else if (document.layers) {1 s, x7 `, a( p. i
         document.layers["supertext"].left = xPos + pageXOffset;% E; Y, @+ @* H5 h/ v
         document.layers["supertext"].top = yPos + pageYOffset;- F. o' J9 n; F# ?, ~: i: h' Q
         }
  U7 z- H4 c9 V' V& Q% x      animatetext=setTimeout('moveBall()',20);
: A' [- q0 P! F* |      }0 l$ V9 x; ~' D1 W" b* Y6 W8 `6 j% p
   }
' F$ H4 M) `5 ~; F: k9 S# o% {$ J/ C- L- o  R
function calculatePosition() {
2 W2 w3 K5 z& Z   if (xDir == "right") {; f5 r4 [1 B0 t! g/ I3 s) r
      if (xPos > (xMax - contentWidth - BallSpeed)) {
! L; c$ {6 r2 x2 E$ o0 l         xDir = "left";1 s( T! |% x8 u0 L
         }8 _" R* H) v0 u; o3 b1 t
      }( w# i, L# D& j# V$ C! j
   else if (xDir == "left") {! H8 @/ ?& p. @/ E* O
      if (xPos < (0 + BallSpeed)) {
2 v, H0 C- C7 J         xDir = "right";& Q9 j2 S; C# c+ c
         }
) m- u, q0 j3 H      }8 ?% x% C1 w1 }8 k3 f9 ]- g; I
   if (yDir == "down") {+ F' a' a, D/ F2 P4 ^) N6 c
      if (yPos > (yMax - contentHeight - BallSpeed)) {. y* K+ g5 D! i; C7 O
         yDir = "up";
- z! B! s' F$ R         }! g: L; [+ u% k* N( M' K  q
      }
  ]! g9 ~* G7 S& u# l8 x   else if (yDir == "up") {  O7 l* o* v1 U# l* ^' K8 T" p
      if (yPos < (0 + BallSpeed)) {
8 k% C+ `, V% z, C1 R1 c  y         yDir = "down";/ |. w' g% D3 G2 x; l
         }1 F3 A( k/ o8 P" H& d& \' @% H
      }
, u" R0 H+ k( j& m* v   if (xDir == "right") {' D! F! m4 H; y% Y
      xPos = xPos + BallSpeed;& y4 w9 y# V. {) \
      }( Q, T2 N1 v# D8 g' H2 G
   else if (xDir == "left") {
  }; i6 t# l( L% P) B  r8 ?      xPos = xPos - BallSpeed;- t  Z; {8 y% N2 r
      }
" q* Y  ?2 Z, I4 B. g6 {. K+ k   else {
6 c2 y+ `+ R7 P# Y/ Q  T2 f      xPos = xPos;
6 H9 _; l) Z7 T. m+ D" e& M      }  X+ ^' r: Z6 C6 c9 @$ L
   if (yDir == "down") {
2 a0 e8 E) b7 |" \. S7 J      yPos = yPos + BallSpeed;
6 O4 ]5 g+ C0 F/ i5 G* }      }- p9 U6 [- _2 Z3 \) U% z8 w! F) l3 ?
   else if (yDir == "up") {
1 o  c; x+ O3 t8 O; P3 ^      yPos = yPos - BallSpeed;
; F& M/ D- n8 n1 W7 T1 T      }
- [, t; L5 l! C   else {5 N0 R: |" _; Q8 M* k& q& d8 m
      yPos = yPos;+ H8 z% V4 c4 C3 F
      }
( o: A' l/ ~  p5 M   }
8 u7 |9 M% N" W6 Z4 K
2 |+ ~  |. W8 n  e% Rfunction hidetext(){
* h) `( ^3 t" I9 W! g- \2 u# Gif (document.all). D1 j8 Z6 L9 M, D' ]1 ^  Q
supertext.style.visibility="hidden"3 j0 e  F1 u5 n
else if (document.layers)5 i% D9 V5 k3 I0 o5 s
document.supertext.visibility="hide"
5 q$ `# _; h# Z1 \- Y/ J0 PclearTimeout(animatetext)
% W- U  ]8 ?, n( R}/ _8 t; q' c, A" o  m& J( A
( @9 i0 e9 K/ I- N  E* b
if (document.all||document.layers){
. t. d9 x/ j0 ?) B9 A& n/ o& mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
, g9 R& l& W$ Cwindow.onload = initializeBall;$ ~- S& l& Q7 W
window.onresize = new Function("window.location.reload()");
1 R% M# |- @! R* B}
9 ?+ J8 ^; l( l& `" O8 I, p: _
" l+ I! Z/ n8 B4 J</script>

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