获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">
. b- B' L0 T/ G' E- U: I! Q8 u; G#supertext {0 c: t$ T+ N, y$ g! ]
position:absolute;
% a4 ^/ p- ^2 J0 `  {) |left:0;
1 K) L( ?3 o. s/ c" g5 Ntop:0;
7 q" l2 s: I( B8 \% q. J$ Hvisibility:hide;+ {* O5 A* |# B5 u  f6 ?
visibility:hidden;: N/ R! }( `8 F+ A" v7 K) Q
}
0 @- q# O: y  n2 f</style>
) ^( l7 Y7 p& O+ N7 c1 u<script language="JavaScript1.2">
+ `: E% F  T* B' g2 h  S3 L<!-- 改变下的字体的大小。颜色-->* M9 H7 ^8 l  y: e3 l+ g& T5 c
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
8 h6 ^' J. D6 r6 k* lvar hidetimer='';
5 a( m  l% ]: l" K<!-- 改变下的弹跳速度-->5 P) Q1 z" C( G* q6 @
var BallSpeed = 20;  Q! K/ \# j0 R6 k7 W* i7 X
var contentWidth;6 X/ l6 A0 I2 c! z
var contentHeight;
% X' `8 |" `) L6 Ivar maxBallSpeed = 50;
2 I" z5 B. v; h' I( j; g% I8 r8 a# m* u# J
) `! Y9 i; ]  I  z% J/ `4 ]8 c
var xMax;
3 M' o, Z8 @& _% \2 v1 g, `var yMax;" q; d; R- X% \9 ^5 h
var xPos = 0;9 ^8 _) L3 Q" a7 e! u( m' f
var yPos = 0;
, e* n6 e, F  _0 M6 M+ bvar xDir = 'right';8 Q3 U/ h8 Z  r/ u
var yDir = 'down';
' c# F1 D( _, U% i8 i% c3 H3 y$ _1 Zvar superballRunning = true;
- s6 E6 @" ?) G7 rvar tempBallSpeed;$ t1 l5 G+ E4 m3 x# B
var currentBallSrc;
7 |5 M+ A  F7 vvar newXDir;
; I7 U9 |" m( J9 ?var newYDir;2 ]7 l& N. m2 N6 L: E* F( |- N
/ n0 ?- v  [- b' k1 u! ]1 }+ ]
function initializeBall() {, E3 p' P" C+ L; V. s
   if (document.all) {
9 T, }6 w1 V/ ~4 ~' i      xMax = document.body.clientWidth
; n! d9 r3 b9 a% C+ t      yMax = document.body.clientHeight
! i& Z7 G: Q2 _% ~5 ]1 A+ J      document.all("supertext").style.visibility = "visible";2 P* w, W  q- B' j& `
      contentWidth=supertext.offsetWidth
$ h! w; Q8 _6 e4 K" c. K      contentHeight=supertext.offsetHeight' W6 x- X) [4 {$ f, z* W# ?! N
      }; q, g$ N; t( W
   else if (document.layers) {
' n  M4 N' Y5 X, {      xMax = window.innerWidth;' P4 o  e0 g" A+ j
      yMax = window.innerHeight;
4 d$ q: Q/ d8 Q  t8 g  l      contentWidth=document.supertext.document.width' t2 t0 ^; q& c3 y9 Q7 d3 c
      contentHeight=document.supertext.document.height
1 S' N8 \1 S7 \      document.layers["supertext"].visibility = "show";
6 p/ |1 n) x3 p( u6 `      }
1 Z  m( q: I+ Z2 D6 M   setTimeout('moveBall()',400);
7 A5 G3 J( U1 @2 Q" G   if (hidetimer!='')4 L* B+ S, f% R
   setTimeout("hidetext()",hidetimer)
! \9 Z7 b5 m: ]7 X   }
$ n; _* F' b& f, Z9 L% o: C
# u( b+ H* ^  c# `8 ~function moveBall() {* p/ b  |) G( s3 |
   if (superballRunning == true) {
, `# [; i* A3 O4 E9 |* |, W+ m      calculatePosition();# D% Z( i6 y" V) Q! r
      if (document.all) {
% Y- Y8 c6 C. o  b# S         document.all("supertext").style.left = xPos + document.body.scrollLeft;! V9 R8 N- ^, I* f" q% w2 t) {
         document.all("supertext").style.top = yPos + document.body.scrollTop;8 M9 x% s* y: }5 y
         }
" ]# r4 ~; D# A; r6 D      else if (document.layers) {/ Z' V/ W9 ?1 f
         document.layers["supertext"].left = xPos + pageXOffset;
7 F/ p1 f6 ~& e+ S' Q: Y* \/ r* Q         document.layers["supertext"].top = yPos + pageYOffset;
/ E2 Z9 t* s3 m! t3 ~* H4 }         }3 t$ N6 W  f* e% Q
      animatetext=setTimeout('moveBall()',20);
( U3 V  R$ ]+ V. B9 b* ?9 v      }' d! t2 [- f: Q! m
   }% c/ D& s( [1 @- B
9 ?0 D. X: d9 D7 t1 ^
function calculatePosition() {
1 l) t6 P( S$ D2 C- q   if (xDir == "right") {/ {7 o% ~" C# w8 n. R. j/ |
      if (xPos > (xMax - contentWidth - BallSpeed)) {: h. p. B; R! P! k  m: s" k- U
         xDir = "left";
! g* T9 ?: O$ ?# E7 e         }  N: s; x/ i! h4 t# `8 ~( o
      }# d7 U; |. K1 a/ P( T, i5 M
   else if (xDir == "left") {: J8 T: J! U. A5 V+ T9 R; i
      if (xPos < (0 + BallSpeed)) {
. b- S/ L6 G/ M4 @* R+ q         xDir = "right";
' ], k/ I# V1 s& G# O: ^8 N         }
* Z) N( [7 |& A. D2 d& W2 J+ ^5 l      }/ m* E7 U$ |, n) ~( `( c% s
   if (yDir == "down") {
$ e# N4 c' s3 D) b- ^      if (yPos > (yMax - contentHeight - BallSpeed)) {2 r; o, B7 p  e/ w: q
         yDir = "up";, o% F3 d" x: y6 r* I0 v7 L
         }
# w1 j+ F9 r. H: t) k3 m: M4 B/ d      }
/ h& b' ^8 S" @   else if (yDir == "up") {
$ \- O  a4 o# K. G) V' M7 O8 E      if (yPos < (0 + BallSpeed)) {
. \) d2 r: Y- z+ a9 l2 n4 H$ X0 C         yDir = "down";- N! L: Y0 z' `! \- ]) I
         }" g! a9 q" T4 s* l# [" k
      }
+ G- {/ K# O  Z- T   if (xDir == "right") {6 x7 }  ~" O  `4 v( F& }
      xPos = xPos + BallSpeed;( i" ~/ N  E& Y' f$ s
      }) i/ O4 \3 o2 Q. x  q  a: w
   else if (xDir == "left") {
& g! d7 z: s& k- R0 ]% }  L      xPos = xPos - BallSpeed;3 Q9 s9 y+ z; T' Z, o
      }
: O# s2 Y, J( I$ s1 j   else {
& t4 N& k5 p9 i3 ~" ~, P3 z      xPos = xPos;
" B; [( f( r+ T9 ?  a      }# v" I! N2 H4 F" U4 m% l& m7 [; t
   if (yDir == "down") {, K" t' q3 N6 a5 C
      yPos = yPos + BallSpeed;
4 `$ e" H/ O1 j      }
6 i/ ]9 N# y7 T( Q7 R0 U; v   else if (yDir == "up") {6 f! D# N9 T* T- s- d3 h
      yPos = yPos - BallSpeed;
3 d4 D# A! ^8 o. W  A- G5 J; \      }% |4 V2 w+ ^: D3 w0 l" v  K- p1 ^
   else {* e8 M, M( Z- A! G
      yPos = yPos;
  A$ c6 d0 _! U. p+ Z/ X1 h% ]      }
  ^% D$ D# j$ V) A7 d! T6 r   }
" K% C, E, [6 S6 [, E  s) ?2 ~" {7 O" [3 h3 d- |  C* M' A
function hidetext(){
; e/ _$ X: c0 f8 Qif (document.all)
0 V' C' d* D5 B  }5 [4 J/ Esupertext.style.visibility="hidden"
6 y+ X- R- R  \! aelse if (document.layers)
0 \1 W7 C: r7 J4 p1 P7 D& ]: R+ Ydocument.supertext.visibility="hide"1 F' J  k* f9 s
clearTimeout(animatetext). {. r: v. @* C2 `
}
1 f* D8 z9 `8 I" s9 C# H
/ B, e" H* p, t# P( b6 B; M5 Q3 E& zif (document.all||document.layers){
8 O; Y! c" w% C: R; v# Y& Zdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'): u0 D$ J% _  y* E
window.onload = initializeBall;
  Q. x  P/ K1 fwindow.onresize = new Function("window.location.reload()");( P* v* n* {4 |- S
}5 K& a3 ~# v% q+ q3 ~; Q
6 C9 h& j9 e* L
</script>

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