返回列表 发帖

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

<style type="text/css">& l. g  P/ e( n8 a1 Y3 g' a
#supertext {
, c. |; V: ~! A" R# S2 V: }$ @position:absolute;% U# L, ]8 K3 i% W7 ]3 w
left:0;
. H7 Q$ j+ c1 v8 g# a' ntop:0;$ e6 n9 H9 E- X6 o& b( A( `& U% W
visibility:hide;; z9 E! D# `0 t& c+ u- k4 ~8 E
visibility:hidden;( x- M- o. O$ u! K5 e. z- G. _9 ~
}
% f" O& G  L) }</style>
/ G" c) g  M& K<script language="JavaScript1.2">
% L+ K% R5 D1 E/ u* X0 @* S<!-- 改变下的字体的大小。颜色-->
. M. a! f- F: s9 D- W; nvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ f7 X1 p' R7 K! ]+ k, Y4 H
var hidetimer='';. |, J! U5 M# U2 c* W
<!-- 改变下的弹跳速度-->
% S( l- W: v/ E5 f7 I" tvar BallSpeed = 20;
7 ]/ Y+ O9 C/ a# H4 T! hvar contentWidth;
: F. y4 Z7 P/ U1 e7 g  f. bvar contentHeight;3 R9 p$ M3 v4 y6 d: ~0 v. ^" J
var maxBallSpeed = 50;7 k% ]4 ^$ f) ^+ X$ e4 b$ j
; ]3 Z: u: d! I( I

0 R# C( H) ~, y. T* dvar xMax;6 E  O$ U4 w& l
var yMax;7 G0 ~4 y. J# V8 ], Q- A# D" x# q
var xPos = 0;7 n: Y) Z- f1 `: T$ |1 Y
var yPos = 0;* o2 A) [/ c7 A  P% }) j' [
var xDir = 'right';
) \8 ~  x  }1 E5 {( hvar yDir = 'down';8 k  o5 b+ d! @0 W0 t5 q8 ~! T
var superballRunning = true;
5 H1 k1 ?: u- {$ @5 zvar tempBallSpeed;, J" s7 W. a, _* U7 C
var currentBallSrc;
7 E: O: R) M3 i$ M8 _: |var newXDir;3 X) V9 j5 h" }. f9 q( `
var newYDir;
2 |2 ]/ Y. {3 f6 V0 y
" w1 n  a" H! m) M; Ifunction initializeBall() {4 }  {1 H6 F/ t4 a
   if (document.all) {
4 Y( X% U2 N3 y" ?) A3 Z3 l      xMax = document.body.clientWidth
  Z) w5 ^( [* f4 y      yMax = document.body.clientHeight' K7 a; j: l& B7 \% t% P
      document.all("supertext").style.visibility = "visible";' F4 b: R  w5 q
      contentWidth=supertext.offsetWidth# o9 X9 q+ [: ~5 J5 c
      contentHeight=supertext.offsetHeight
/ C0 M$ n" D7 G( u      }% P* ?; V  k) \  X
   else if (document.layers) {
( ~" L& a: W6 E# q/ @( _      xMax = window.innerWidth;
1 a  z6 q8 r) G      yMax = window.innerHeight;! x9 u+ t) Z; k' b( f
      contentWidth=document.supertext.document.width, v$ f, }1 z  K& [
      contentHeight=document.supertext.document.height" u$ A5 }& Q% E1 e
      document.layers["supertext"].visibility = "show";
* J2 |/ |. f; f3 @" {7 w3 L- u      }5 x, o* S( N, z/ v. B+ v
   setTimeout('moveBall()',400);3 @$ B3 x+ ?7 h8 @
   if (hidetimer!='')
5 H; T% W! O$ c3 R4 c   setTimeout("hidetext()",hidetimer)7 ]7 T2 \5 \/ A. H' L, g
   }) h2 q3 K& t$ ]* ^

; n6 v0 M" U" i$ S' ]3 `function moveBall() {
1 |9 t* r( j2 Y9 v   if (superballRunning == true) {' `, Q1 S5 ~  _4 K, |: Q
      calculatePosition();& j  J: {3 R3 u* d) D- I
      if (document.all) {
% \" t, ^( k1 Q2 V( S1 x$ q         document.all("supertext").style.left = xPos + document.body.scrollLeft;
0 a6 m0 p3 w/ C; t         document.all("supertext").style.top = yPos + document.body.scrollTop;/ A, |* |4 o$ x* V
         }
, b; e/ G! a1 f6 I* \& F" B      else if (document.layers) {) e9 J7 @; i4 a
         document.layers["supertext"].left = xPos + pageXOffset;
) u9 m7 X' X4 [/ j" t) O         document.layers["supertext"].top = yPos + pageYOffset;
1 h# ?3 l0 [0 z7 N         }" C( l5 a2 ~. U. Z
      animatetext=setTimeout('moveBall()',20);
6 T1 V6 N6 L" M  m$ C# s! M      }  D5 w6 A3 ]$ L# r2 s3 a
   }9 a  u$ C; l0 C

8 m& W) a6 K$ E. _function calculatePosition() {$ M* S, G& j4 i6 C( |8 h+ k
   if (xDir == "right") {
- @. ]- I, F  @1 Q7 }      if (xPos > (xMax - contentWidth - BallSpeed)) {) }$ w8 b2 p  e; ]7 a, h& I+ |0 h( w
         xDir = "left";
) F/ E" T+ o$ v) C& W. K1 ~' f         }
% A( D- C+ D5 J; R; u" z8 u      }
  I' w  C+ t' b. m, I% q& Y/ e   else if (xDir == "left") {
; ?6 ]/ }9 S' r; t      if (xPos < (0 + BallSpeed)) {
6 C" ?" M; E/ f. f; K         xDir = "right";
0 }# O0 K; P! T* ~  j  v         }
: ]9 E# j$ |+ U( c* f      }! ^0 @- @( Y! U, Q
   if (yDir == "down") {
. t* V2 D- U0 j7 f+ ]' Y      if (yPos > (yMax - contentHeight - BallSpeed)) {! A% b! b. ~6 w6 J6 A4 a
         yDir = "up";, D: u( N; t9 P- n8 u
         }" _" X8 B# e: Z! O( g
      }$ g, R) c5 L) W& J, v
   else if (yDir == "up") {
, u# }& A+ p& ~9 G1 u* G      if (yPos < (0 + BallSpeed)) {4 L( r% {; V$ A$ j0 u+ ?1 q$ f4 w
         yDir = "down";
  f& n& K, h, y# C4 O         }7 `* p7 K, ?2 z/ Z8 j
      }6 f  @$ p; B$ s+ m7 J* S) V
   if (xDir == "right") {
0 `3 @8 w# R; L! p5 g, ^      xPos = xPos + BallSpeed;
  p% T1 g* _# I( e; z      }: b) z8 ?$ A7 x% b9 N1 o+ r) V
   else if (xDir == "left") {
' u* w% Z5 U4 a1 b  ]6 L      xPos = xPos - BallSpeed;( R2 K6 \* |+ i
      }. w" V; {9 j- k4 A4 V" c
   else {
) _& e+ _1 H; y7 ~. M) t      xPos = xPos;0 q+ k+ [8 r1 Y& U. V0 K
      }; n$ g. Q- B" n/ r4 W) o
   if (yDir == "down") {/ y$ v$ U/ p8 g/ D, g2 Y; v
      yPos = yPos + BallSpeed;+ }  W: G0 ^0 c. o
      }
; t% ?  E; V& l; b+ u   else if (yDir == "up") {* i& I& V  e$ K: o# _4 `9 [
      yPos = yPos - BallSpeed;
) k6 B. s4 ^, {, W& O% w) `      }
& I+ a" p/ L  F8 }4 h+ d& Y# g6 u   else {1 r( o, K+ m1 f; C: p9 m
      yPos = yPos;1 y( S& q3 \% \
      }, @& d6 F2 E, \7 O( L8 s9 s
   }9 g0 e' |/ y0 S# ~
" @- f3 ]& A3 u3 t" H" U9 R2 {
function hidetext(){
  V0 ^3 ~7 A* e% T) k1 Wif (document.all)
; z' [# A6 j1 g+ _2 [supertext.style.visibility="hidden"3 g5 j8 p2 p, l& [
else if (document.layers)- S5 R# @  W! A8 k$ q3 O
document.supertext.visibility="hide"( L9 b% ?9 K; h. F9 S3 d
clearTimeout(animatetext)# |" {# K3 w4 ?& N( k$ y/ M
}
+ w0 |* y9 z4 ~9 z6 s- g4 q- C) P
& [6 H. [, ^# A9 w1 Z- S2 J0 lif (document.all||document.layers){
- l; w1 |9 n7 E: N- S7 s& ^document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; p; R. b5 s7 G6 g  r2 mwindow.onload = initializeBall;/ E; c1 W3 H' ?0 u* s9 S- r5 S/ l
window.onresize = new Function("window.location.reload()");' Q7 N3 R# F( X! A/ l
}
# C+ o' a2 U/ W4 b% U3 t6 K, y' Y! ?+ g' `0 h
</script>

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