返回列表 发帖

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

<style type="text/css">' P5 C, S5 W- W" h- h7 _
#supertext {7 d$ e7 @4 j  m' N- J
position:absolute;4 C; R5 X' g- g- j: c, G7 S
left:0;
- @* ]/ X, m3 ?top:0;
( |; V4 j0 Z8 c$ V8 n+ b$ s2 `+ tvisibility:hide;9 U) ~- z8 l7 S5 n) }" g5 d
visibility:hidden;: G3 \8 w: A, b# x0 N( V- D
}2 v% `/ P! s2 i2 H
</style>5 C& f% R  S, c* \
<script language="JavaScript1.2">  h+ s7 S6 ~- ]* E0 ?0 C/ Z
<!-- 改变下的字体的大小。颜色-->* ]2 Z6 {. I# F) {" g
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# u6 Z0 W! R2 n$ M: S8 M) G% n
var hidetimer='';
1 ]- ?$ O3 z1 t* p' h<!-- 改变下的弹跳速度-->. k2 _8 J3 h% {2 C$ v
var BallSpeed = 20;
* J4 F' _1 ]8 P' bvar contentWidth;
" x5 C: e! g6 v2 a  Jvar contentHeight;& Z" r3 Z- T5 g: U, H. K: A
var maxBallSpeed = 50;4 y2 h8 _  |: U( S$ m* E9 ~& z) ^- o

- V( R2 |9 t+ i$ N1 s6 R1 J' Q- i! f; r: v8 F
var xMax;
. e+ a* _1 d3 z6 B6 avar yMax;
  U9 }9 T" I1 m8 R5 d! dvar xPos = 0;
6 w' r) U# t* Yvar yPos = 0;
$ ~& a& }0 F, Y( Gvar xDir = 'right';
( q* \; d9 i/ L- t  d; cvar yDir = 'down';$ \& }* ~' i( l* [1 q: V  ^: F
var superballRunning = true;+ u# R9 B; ~$ `. U5 k  Y- c. m  F7 V
var tempBallSpeed;, Q4 R, v  h9 t3 v. I" E
var currentBallSrc;! q& i- K( X7 f- p
var newXDir;
3 j# [' }/ a$ w0 \0 I6 K5 k, S0 vvar newYDir;' n7 F7 c0 V& _: E
: R# l+ t5 A0 z* I$ `# N, H
function initializeBall() {
0 {' G: R" S2 }6 A$ T. K: ?% r: w   if (document.all) {
+ G  b* e3 C9 q. O" Z4 B2 D/ F      xMax = document.body.clientWidth
/ S8 o! o3 F# G2 a( D      yMax = document.body.clientHeight
) o% `  j* @  [8 `2 b7 M% |% [$ t      document.all("supertext").style.visibility = "visible";
2 x  r$ F8 j: Y; G/ t! _' o9 G& h0 C  P      contentWidth=supertext.offsetWidth: {1 L5 P( x9 b1 Z  f/ r5 W5 N& {
      contentHeight=supertext.offsetHeight% x! q/ z( z4 h, ~+ Y
      }
( c3 }5 h5 S1 @1 t   else if (document.layers) {$ s0 l' T, t. a1 B/ k4 t0 P! o* o
      xMax = window.innerWidth;( s4 b" ]1 m/ m% O; i
      yMax = window.innerHeight;6 w$ D( r& E$ L! [
      contentWidth=document.supertext.document.width  o1 v  l7 O$ {; ?7 C. r& Y
      contentHeight=document.supertext.document.height
5 t$ M2 [" e2 o$ x% W; n      document.layers["supertext"].visibility = "show";+ Y0 T! r/ I8 F/ ~) t# e
      }5 g$ G" H* r/ ?  ~  S
   setTimeout('moveBall()',400);& q# l& l/ {" c5 n& Z
   if (hidetimer!='')
( r8 |: R: b: a' B% k+ x   setTimeout("hidetext()",hidetimer)2 q5 `' D- d4 Z1 f5 d: P4 p  N' b6 a
   }! \: R: H8 N. U& j7 {9 U1 D

9 l. c6 ]0 Z3 [" Y5 M9 Sfunction moveBall() {
, A8 _( w/ B7 p' j% Z   if (superballRunning == true) {
, @7 u* B' E( m' U$ ?      calculatePosition();
8 h/ Q& o0 k( r( Z+ h3 K      if (document.all) {
5 i3 N2 c$ n6 o" G$ u; A         document.all("supertext").style.left = xPos + document.body.scrollLeft;8 g, v% E* B) B6 w  y6 F7 I6 O# @
         document.all("supertext").style.top = yPos + document.body.scrollTop;
6 g2 Z% k% c7 r% d         }* P' u4 ]+ p  ~5 T1 e( ^/ V* J
      else if (document.layers) {- f# \. J3 i" x5 F
         document.layers["supertext"].left = xPos + pageXOffset;
( ?& D  ~* E4 m1 j7 x4 A         document.layers["supertext"].top = yPos + pageYOffset;
, B! A0 @/ E' ^! b  _9 z; y         }
4 v+ ~. C8 o, Z/ k  S: [' E! g      animatetext=setTimeout('moveBall()',20);
' V: m- A- x( A3 c8 K, y3 p      }/ D  ~, O1 a8 e4 g* K# M0 ?
   }
) \7 F( _- k; K) ~+ O9 G( P4 y2 g  ]4 s2 @; u
function calculatePosition() {
7 D7 w( }7 i# w   if (xDir == "right") {1 F( R0 b8 U$ Q3 Y/ o
      if (xPos > (xMax - contentWidth - BallSpeed)) {5 h+ B8 C2 c1 U0 W" x, v
         xDir = "left";
" x- S8 K3 @$ m% N# M7 V         }
6 e2 p7 i" y' c% \      }
$ f% u8 k  W, m) D5 O   else if (xDir == "left") {* z0 e( D9 N0 E, O
      if (xPos < (0 + BallSpeed)) {
- f2 Q) J5 a- E1 U         xDir = "right";" m1 k: c* W& }
         }
6 d& r4 p- C' _2 ?+ Y/ S& n      }
- Z0 `  I) R3 ^- y4 w9 ]" B   if (yDir == "down") {5 i$ R; O% z3 T( M4 C
      if (yPos > (yMax - contentHeight - BallSpeed)) {4 d6 R2 L. e6 S. K
         yDir = "up";4 ~2 T7 d- A3 \: N" x) T( _: h
         }
/ n# i! Z$ {6 w' l      }+ ?( V5 A# |# q5 K
   else if (yDir == "up") {; T: D: G& r5 y4 e! C
      if (yPos < (0 + BallSpeed)) {8 _1 e5 K, _/ r
         yDir = "down";. @2 g/ Q1 }& L$ q
         }8 c6 d5 v; X. `9 a  o
      }
9 u4 l3 b) |9 l5 _4 m# |: F! @   if (xDir == "right") {
" x! O- E4 s. ~8 n8 z      xPos = xPos + BallSpeed;; M! c! k8 T; g: g  a
      }+ f3 x6 o9 D7 n& u! t8 B8 C8 x
   else if (xDir == "left") {$ q' G/ e0 e1 Q# Q5 V
      xPos = xPos - BallSpeed;5 |2 v, ]# @& i4 r( t; r' h
      }
! @0 v# _6 e! X$ ~3 I   else {
; j0 j6 _) ]$ `5 u3 A3 c& d! h      xPos = xPos;
; x  l0 s& x: f+ }: ^2 X! d- i+ {      }  C( K) W* ]( Y
   if (yDir == "down") {
" V4 m* P, q! g4 t( ?9 ?1 E      yPos = yPos + BallSpeed;
9 a1 Z' M( I' |1 t* f7 n      }  p  `3 M: H4 p/ i5 N
   else if (yDir == "up") {. ]2 i" {' F$ D
      yPos = yPos - BallSpeed;7 a5 X8 x1 F! Q8 G0 s: ]2 [9 U
      }9 G9 q$ \9 z& i
   else {
2 y3 W; k) N. f, U3 c) G4 w      yPos = yPos;. W! x3 q) U2 l+ e
      }3 P  S  y% [. b# B7 B
   }. F& P/ d; N6 S3 p. t' w+ q% j# n6 I

; f( E3 X! R8 O7 c8 [6 L" Bfunction hidetext(){
$ g/ V4 K4 U9 R- oif (document.all); V' @' x; Y+ g  b) Q
supertext.style.visibility="hidden"5 T  l- d: A* f3 [7 c  m1 u
else if (document.layers)
$ b: ?; @7 l4 g( |' Ddocument.supertext.visibility="hide"
$ C( J0 C$ ]+ X  X: {, H  XclearTimeout(animatetext)- b2 m; E6 t4 v* D
}
6 }0 A* d% [! n. f  [% p
9 d! C+ k' K; K7 `4 u0 qif (document.all||document.layers){& I  J) Z% l3 n1 p, F# C
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ e& b9 i. t( @! g  }
window.onload = initializeBall;7 g2 g  O! [+ }
window.onresize = new Function("window.location.reload()");  w+ [4 u5 D, W. s4 V6 y$ j) p- e
}
. v+ f, u4 F. U3 |- U' L5 A9 d% x% }$ m* E- f) h! v& p9 V6 E% e
</script>

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