返回列表 发帖

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

<style type="text/css">
4 n$ |" P" W. Y- S2 r/ f2 V& F#supertext {
% {( n: {3 }, oposition:absolute;
* B+ k- H9 I# I  `5 p+ Sleft:0;
' @- v  A% V: Dtop:0;
3 ^2 z" L6 b- G: }6 ~& |visibility:hide;: x1 t$ D3 N4 R3 Q
visibility:hidden;
* G, q/ Z. ^2 {$ ?+ S3 }  D}
- U* W5 H: l9 g1 v8 w</style>
2 H5 w) Z+ z3 h  t  D) g<script language="JavaScript1.2">" l4 n5 b# t( _1 e. y1 l2 ^
<!-- 改变下的字体的大小。颜色-->
, E  E! |( q# Bvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'9 K9 |. W  f. L+ H7 ^
var hidetimer='';
" B$ d( G" o) \% r2 n<!-- 改变下的弹跳速度-->
" v% L  p+ @; T. U# ]' r% kvar BallSpeed = 20;4 u) w# E+ o7 _3 G
var contentWidth;  `* t9 E, r9 D" f
var contentHeight;: @3 O. I; w2 h7 A: G( F: O
var maxBallSpeed = 50;& Q0 Z( S8 q' c
  k! ^# |7 U1 d* l8 Z8 w$ `) U

& j& v' M$ Q! ]var xMax;
4 {& h2 M8 }- U7 F  k( T" O( }var yMax;
7 Y$ e4 P$ W7 Q! }" ~3 Ivar xPos = 0;1 a4 z2 @2 c5 h8 ^+ Z- w. t* L
var yPos = 0;
. y/ |( k  Q4 Q% Fvar xDir = 'right';: \" r' D' l( ?" B
var yDir = 'down';
6 V+ c+ o5 d* H( K  Hvar superballRunning = true;- |. S1 Q2 ~( d
var tempBallSpeed;
7 H7 Y0 z* s7 W* Q' a9 Y0 x; P/ zvar currentBallSrc;
( i6 a7 y- Q7 s' e9 fvar newXDir;: B8 x% ?# {- ~% B
var newYDir;: m. L7 F6 T3 p. z2 I" w# U) Q

% @( U5 r# z6 v$ N/ Tfunction initializeBall() {% W" s7 o3 T8 s% K7 R& o( U
   if (document.all) {
  s# g& j0 W8 V7 a* c+ O      xMax = document.body.clientWidth
* P. R# {. p8 }6 N- H' ?      yMax = document.body.clientHeight
5 R( b, z$ l+ I5 U- O4 b8 [$ R8 K      document.all("supertext").style.visibility = "visible";# o9 g5 Q& `1 L1 R' f5 p: q
      contentWidth=supertext.offsetWidth
- b0 k" U4 P1 C, T      contentHeight=supertext.offsetHeight
* W- k# P( k( `3 w4 T: c( {      }- I; g# P, P/ a* Y8 P- j' ^
   else if (document.layers) {6 v" Z. }7 ~5 A
      xMax = window.innerWidth;) r. n' z5 v  k2 L  h" n
      yMax = window.innerHeight;. x2 J* c; S- l  Q5 i9 Q3 t
      contentWidth=document.supertext.document.width
  b: ?! M% Y' {5 N2 z      contentHeight=document.supertext.document.height- y& ?! [2 M0 @2 G+ b0 w
      document.layers["supertext"].visibility = "show";+ ^  o% t! {/ I3 n0 U& G% g& |7 U# m
      }
5 w( H7 \7 r- @4 ~) k( \   setTimeout('moveBall()',400);
# r/ j& f8 R, K- {7 o, S0 i/ m   if (hidetimer!='')/ ]3 I# I. l+ b9 r
   setTimeout("hidetext()",hidetimer)
( P' G, O5 w; }   }3 g9 K) m8 W2 N6 T, E
1 s( c( K9 x) y) N/ ^
function moveBall() {
$ ?4 p6 F) G9 S& P! y   if (superballRunning == true) {5 B8 Q9 m: g4 u1 i2 u& P3 I" ]
      calculatePosition();: B# |$ z) I1 X) @3 A
      if (document.all) {
% q+ M0 R! q+ H  F% P         document.all("supertext").style.left = xPos + document.body.scrollLeft;4 L1 O# S+ s* ~5 s* s6 |
         document.all("supertext").style.top = yPos + document.body.scrollTop;
- b+ e9 \6 e( K; n         }
2 Y( D$ g" g0 g. z' N      else if (document.layers) {
1 m" n& d1 V7 u; R; M: k% g         document.layers["supertext"].left = xPos + pageXOffset;
2 p8 e& O& c* R9 J" X/ @' j- c# `6 u. e$ s         document.layers["supertext"].top = yPos + pageYOffset;
: r- c9 }9 n" P8 n         }
' G; a  {! h9 f6 c5 C4 Y; W4 D$ t# X      animatetext=setTimeout('moveBall()',20);
# O. w! v0 F+ Q) T, R% A, B      }8 W& z( W# W; |; ]; G( C
   }  z+ [: z2 U8 Y. M& f' F8 W& g

$ n! Q5 o8 z1 K0 l+ E2 [1 Tfunction calculatePosition() {
6 F1 @% F1 F4 B" {, H" V   if (xDir == "right") {
3 m. R0 F0 ?/ M7 k9 }* u      if (xPos > (xMax - contentWidth - BallSpeed)) {
3 q7 q, y4 d+ F9 F8 f( K         xDir = "left";
. e, ?2 D$ m$ {) w         }
  W* ~5 L* n: X- B, o# A8 h      }
# x: k! u' {6 q- T+ ]   else if (xDir == "left") {2 S3 G6 f# t# k1 b" W1 }
      if (xPos < (0 + BallSpeed)) {% q; D# G- F, A  w
         xDir = "right";. @' ^3 N: }4 k( \! x, E  O
         }. O# S2 }. b, u" \. I( p
      }0 g1 O; A  n2 r: m* w/ f
   if (yDir == "down") {+ F4 K1 m$ t+ i: z( m) D
      if (yPos > (yMax - contentHeight - BallSpeed)) {
$ F, d2 `0 C" ?8 @5 ^' F& F         yDir = "up";8 \- I2 ?* m! y$ a
         }, C8 u, m7 u- T$ x0 v
      }
* S: B' s! c/ \2 a2 q   else if (yDir == "up") {& ^7 _3 w2 }2 ]: u8 U/ c/ h
      if (yPos < (0 + BallSpeed)) {/ r' l" d( b$ j
         yDir = "down";* w) }! q# I% b; q  C% Y( x4 U
         }! G: I5 H8 Z* e
      }9 A3 v& C/ ^2 ~% D/ x
   if (xDir == "right") {
9 X. z% F0 v6 t1 f9 x" \      xPos = xPos + BallSpeed;0 q; j7 R& @& ?2 U! N
      }
. j( X0 C' l& d" c   else if (xDir == "left") {
0 T3 a+ P, H  x3 o! W) O      xPos = xPos - BallSpeed;
; B- h* p  b- j, V      }
% k, k9 V2 ^8 {* R4 w   else {
* w+ j  q0 R! r6 @& t( d; N      xPos = xPos;" c; W" v$ n' |9 F: k
      }( }( A: s% C0 s4 p+ h* f/ O
   if (yDir == "down") {
! }% h7 }$ o4 _+ A7 t. l      yPos = yPos + BallSpeed;: `( b$ L- v+ I8 u+ G
      }. ?2 U1 q9 |- F5 t, X
   else if (yDir == "up") {. b# J6 H, \1 v' t
      yPos = yPos - BallSpeed;
2 i4 y9 P! \: b      }% K/ y8 t1 ~2 X& D
   else {
- n9 \" z0 l; F7 B: D$ g# m      yPos = yPos;# Y8 O, x/ d; k' h
      }& z# ?: A' k( w8 N7 D8 S/ V* b
   }7 ~9 d4 B% X( h# H3 W1 g

% q% ?) W% Z: M8 g* o/ a9 B" e8 kfunction hidetext(){& m! _- l0 p: i1 Z4 ^* P& A6 V
if (document.all)
! X* a$ k5 h. u0 ?0 t2 w! psupertext.style.visibility="hidden"+ D. a1 c" z! n
else if (document.layers)
  ~. N3 K/ F8 f% jdocument.supertext.visibility="hide"
  f1 _- ^7 n& n7 b' TclearTimeout(animatetext)
! C! F3 L0 ~- i" z* t7 k. H7 h9 G}
8 q+ @6 S8 i5 b2 h8 |
* y% {0 N% Y0 d; \2 H7 n  Aif (document.all||document.layers){
. W1 q3 ~( J3 v% U$ xdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
( F8 T- A" k" o- u! Owindow.onload = initializeBall;. q3 X* H" |/ i3 e& V
window.onresize = new Function("window.location.reload()");) D; V4 Q/ W! f& |) g5 m8 W
}
. R, v' H) \# V2 j3 M4 x: Z+ z' Z
. @7 z* d/ o" D1 I3 V7 ]</script>

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