返回列表 发帖

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

<style type="text/css">- B! V+ E1 C) Z* E/ J
#supertext {
$ V: }& K% J3 Z# z, a$ K. ]  s* Eposition:absolute;/ W& s. ^* X& e" R0 K
left:0;2 X" W9 j+ v! U( n! t$ S
top:0;
" A: J* J. c# c% y5 n4 ^. nvisibility:hide;3 \0 D# M  x5 {% x/ _) a: q
visibility:hidden;
  j7 V8 m6 Y% n1 u$ U}
1 ~* H8 `0 w& ?* T& s- i</style>
2 [# L3 U7 B. ?2 _5 s* c& @7 u/ t<script language="JavaScript1.2">
) B* T5 u6 ?' p: u1 ^<!-- 改变下的字体的大小。颜色-->; D' I1 D5 U  T# r
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. s9 ]3 H# M! }1 G& J. U% i$ Xvar hidetimer='';
8 K- P+ j5 Q9 i8 T  I/ M0 }. z<!-- 改变下的弹跳速度-->
, a, V/ j3 o: V+ J8 J( W' Z/ U9 evar BallSpeed = 20;6 |2 g" D% F# U+ X7 s# i# P& g* k
var contentWidth;0 A% ~" B5 z+ q
var contentHeight;3 I9 V4 T% V, p& o
var maxBallSpeed = 50;% ^  u3 Q1 \7 U# i& f1 L% C

8 q6 k) v& X' y4 a% O
* L* A: y1 s1 [5 Q/ ]* ?var xMax;5 {' r# K* L* g# w/ M
var yMax;
0 Y/ Z; x% n6 {. [% dvar xPos = 0;- Z6 V& T3 p9 y5 F2 A0 w1 h
var yPos = 0;
8 |" B0 J; L9 s0 svar xDir = 'right';3 L& @! D9 M4 F) n5 |- k+ _$ L; K
var yDir = 'down';. H4 K6 O9 [5 C  T0 _) A
var superballRunning = true;
: Q7 `5 W  ~' s( [0 kvar tempBallSpeed;3 j) V: g8 k2 }9 H4 q3 W$ j5 |
var currentBallSrc;! J; V- b5 ^4 }) h7 }
var newXDir;
' M4 m  {; t) S# n0 K5 Yvar newYDir;
$ c- C* C% L5 ?3 R/ R( U* R. S% M: N( z
function initializeBall() {
% N( k& Z% @  d( N* |   if (document.all) {
& s; R9 K! o; g& t4 Q      xMax = document.body.clientWidth
, S- O# D3 G0 x      yMax = document.body.clientHeight
/ X4 L8 o' b4 ~- a  [9 b  |7 p      document.all("supertext").style.visibility = "visible";
3 L+ i/ O$ |# e      contentWidth=supertext.offsetWidth) A7 n5 R& }$ G1 I. X( S5 S. L
      contentHeight=supertext.offsetHeight9 N# d" r, g7 {
      }
$ U+ v2 `, s) ^1 `) K* a( O   else if (document.layers) {
7 y- H& B( s4 y      xMax = window.innerWidth;
. N4 _, x% m+ e% `2 I      yMax = window.innerHeight;0 }* _5 |- q6 z2 p8 R! @1 K
      contentWidth=document.supertext.document.width- m/ t6 C, _5 \: P; c. t2 X# t
      contentHeight=document.supertext.document.height
! _' p% S6 t2 `7 W' K3 z- K      document.layers["supertext"].visibility = "show";
2 ?/ h7 P% H2 S9 H* U; R      }* K. [% |- o; M4 T- u8 Y
   setTimeout('moveBall()',400);
6 C6 I- \! j, e* Y, G! ]   if (hidetimer!='')+ [9 k& ~  t' v$ I; c
   setTimeout("hidetext()",hidetimer)+ S/ D) _0 j! H) C. b5 T
   }
- A: k7 F# l0 T8 K1 ?3 }' U; p- Z( v
function moveBall() {
& J1 Z0 @8 }9 {   if (superballRunning == true) {0 G" h$ E3 b' O- t
      calculatePosition();: P( G& N) o8 I6 d2 L
      if (document.all) {
5 e7 D2 R7 M7 n/ n' i! V         document.all("supertext").style.left = xPos + document.body.scrollLeft;
9 E. T! h! @8 v, D% a: o' k" s) g         document.all("supertext").style.top = yPos + document.body.scrollTop;
5 w' A( d1 h, h5 m+ A2 X' p         }6 _; \+ ^4 h) ?$ O# f+ F# ?
      else if (document.layers) {8 Z* A; K1 j) C; E
         document.layers["supertext"].left = xPos + pageXOffset;
( z8 K) P0 w0 ?, x         document.layers["supertext"].top = yPos + pageYOffset;# o( r0 }4 l1 j$ {" t
         }+ I2 s/ Y0 M9 |; J% w2 z9 N
      animatetext=setTimeout('moveBall()',20);
- n& h( G, p  ~# b4 P3 p8 p- Y1 K2 O      }
, _0 I4 @0 D& c   }
' p. n4 V* Y$ A  J$ ^! r* U9 u; n( y4 d: ]1 ~  U
function calculatePosition() {; B" u8 W5 H: s; z% L. ]
   if (xDir == "right") {
8 {& e! S" V" v; ]; I2 {0 t. s- \      if (xPos > (xMax - contentWidth - BallSpeed)) {
; h" }8 p9 t8 o" ]% }% J5 U/ \         xDir = "left";3 I* d# }- Q9 k& m/ k8 d
         }0 Q- S5 h. a8 T; K% i/ [/ U0 o
      }
+ y' W: u. X+ a) {- c- L0 H0 b  M. S   else if (xDir == "left") {- Z1 E" a) ^+ }% N+ y
      if (xPos < (0 + BallSpeed)) {
3 @' u7 g# ~' Y: E8 ]7 H         xDir = "right";
/ W% ~7 ~" J2 Z, N( q7 x         }. M9 p( ]9 G1 e7 C+ a8 r$ Z
      }
$ F( U  M/ T3 G. _# h  G0 n   if (yDir == "down") {
9 K5 a1 e& M. i      if (yPos > (yMax - contentHeight - BallSpeed)) {
  P) I# C) N' {/ X7 @$ ]" e/ z! f! ~         yDir = "up";
, x" S! M+ H$ ^9 u5 F0 Y& ]         }
4 ?! C. U) Z& {4 P5 \      }3 a8 B4 G8 _) b* R9 N6 g) E
   else if (yDir == "up") {  Y; |; s3 m' v5 A7 o  j4 E
      if (yPos < (0 + BallSpeed)) {
  t6 s% z7 w) S1 M$ k. B8 W: c' G* T         yDir = "down";( {* Q" ~# G: n* z
         }+ O; I% ^9 J4 A
      }
4 o. L, o  k& S5 p- S7 }   if (xDir == "right") {+ E) W7 H0 S3 R. M
      xPos = xPos + BallSpeed;
: o9 h5 |$ i* P; J8 Q" V      }! G; ~  e5 ~+ g( v3 I  M7 h, @5 Z
   else if (xDir == "left") {  X, G5 O) w. p" Z
      xPos = xPos - BallSpeed;
) ?, `, u. ^7 \. L- U7 q1 x# N      }
6 Z! A) a; h# ]   else {
4 z9 h( }9 S# E9 g  ?$ R% m% i9 q      xPos = xPos;
: V$ s- P* T# I      }* g: u1 }% O; z1 E
   if (yDir == "down") {3 U  F; T: N# z1 c/ Y. F
      yPos = yPos + BallSpeed;$ a, W8 ^) \4 k3 O6 T
      }4 @  v0 `+ E; e1 g; y: X0 I# d
   else if (yDir == "up") {: f' J4 y8 p0 V; L9 K- l; F; d
      yPos = yPos - BallSpeed;- Z0 G" c( y8 y- V0 u
      }
" a+ \: |' ?3 w   else {3 l& U. O! e/ g0 Y0 Y3 x$ N
      yPos = yPos;
' Z& T5 a" D4 O* B      }+ Z8 L8 M# m! b3 S, F# L
   }
, A. ^% u' y" C7 G  j
" Z' Z+ U. H- @. gfunction hidetext(){
' F. B; s5 f4 O0 ~if (document.all)6 c( W- W1 M/ l0 U  w
supertext.style.visibility="hidden"  c2 v& `1 \4 _7 I7 _7 l8 x
else if (document.layers)
& ?4 l4 k/ i) l: ]8 }7 {4 W8 Wdocument.supertext.visibility="hide"* Z4 G5 _0 R) ?3 w  t. d
clearTimeout(animatetext)
2 `  c$ p2 r2 q8 b+ ~}* R0 j; p4 e+ \9 _% U% R
: h7 t% N! ]! V4 T5 [) {
if (document.all||document.layers){
0 n  M% P4 Z" fdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 k# c, Y4 k4 @5 }1 b- q+ e0 S5 E
window.onload = initializeBall;
" r9 }$ a7 w& lwindow.onresize = new Function("window.location.reload()");) f2 L6 \1 g; T
}
! Q0 R5 @9 \- X! ?2 C; \0 s; U5 a0 n5 ^4 ?2 b
</script>

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