返回列表 发帖

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

<style type="text/css">
1 L$ u, h) U7 z: G& [#supertext {2 t, C: P$ r! E
position:absolute;
, @) w( p( f6 M/ y7 x8 dleft:0;
3 n+ o" i. {; y3 j6 |3 ftop:0;
& f" T' Z6 f& q! n% kvisibility:hide;
( q4 y- W0 N3 h# f& \3 P* Q$ F5 y1 i9 zvisibility:hidden;
: ?3 z; p- G  a- V/ |7 v}
) ]  }% r0 u  H; ^- n* A5 P' J5 Q2 K' I, t; w</style>
/ p- k4 N1 G& x# K8 E6 D+ a<script language="JavaScript1.2">5 X3 m7 K+ n4 \( j& d( ?
<!-- 改变下的字体的大小。颜色-->. r+ V8 O% X+ ?! c6 Y
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'& j2 Q9 b$ D2 i7 F/ d
var hidetimer='';
5 k* l* i! I6 Z: p$ q3 S' a4 l1 p  f) K<!-- 改变下的弹跳速度-->
: R& q$ W0 N: `; P) dvar BallSpeed = 20;
1 x7 Q( g' F' T2 k4 W7 s4 Q; ^: `var contentWidth;
: n+ K- s8 s& C; D9 C# G6 U9 r+ c' ?$ V! ovar contentHeight;; I( R* _0 ?: u. L7 Q
var maxBallSpeed = 50;
5 g9 S4 {; A. |1 ?- |0 [" v# L9 |2 }4 ]

: K* T3 z4 |- r0 Q) x; \6 |var xMax;
! ]! {' P# T0 Q6 p- z7 l- Gvar yMax;' c) t1 U  Q+ g9 G" j# o: [3 s
var xPos = 0;
. ^; o) k( L" Y9 g+ t# {var yPos = 0;
2 ]- s4 f4 W8 M9 J$ u8 G& Q9 cvar xDir = 'right';$ \$ a0 h- K- ~- I; |' l
var yDir = 'down';
: K$ v  j8 V! q* ~! {. v9 |var superballRunning = true;
2 J' w- t8 Q; }4 W. u" r& Y- O* Ivar tempBallSpeed;
5 D- q" T2 a5 Rvar currentBallSrc;
, A6 P$ \* D, Z. l4 f- @" svar newXDir;
" c6 E3 ]# q/ D/ a# cvar newYDir;
2 V5 i& O  f8 n
4 t& Y$ V+ C( `" f5 G/ y% K' zfunction initializeBall() {$ \. W; K7 Z% C' Q6 F
   if (document.all) {
: o" F* E2 `% P      xMax = document.body.clientWidth
- f9 U2 Q( Q4 N: h- n& A( l      yMax = document.body.clientHeight1 |3 I7 P/ z" q1 \
      document.all("supertext").style.visibility = "visible";7 m7 k* L) c! U# s3 Y: Q
      contentWidth=supertext.offsetWidth1 [8 U6 p" v. F0 {" H$ [7 p
      contentHeight=supertext.offsetHeight  ^/ p# N3 C4 }2 k
      }
& g" |; q$ o: U( K; l4 X   else if (document.layers) {
4 G% g6 W2 ?- r$ t2 h& B      xMax = window.innerWidth;% v2 x3 D2 i8 l. D7 U9 h5 z" V
      yMax = window.innerHeight;
8 M5 J6 H2 E2 \" ]      contentWidth=document.supertext.document.width
( @' B3 ]3 X8 g2 E' `+ Z2 X. H      contentHeight=document.supertext.document.height. ~9 @/ q. \& m! H& t- Q/ |; T7 V3 k
      document.layers["supertext"].visibility = "show";
# h# v* i+ T' J2 ?8 s      }
* [0 Q: ]4 l7 U; T   setTimeout('moveBall()',400);1 O) B' p4 _2 W% L
   if (hidetimer!='')
/ E: v" N$ _7 u) z/ _   setTimeout("hidetext()",hidetimer)
- ~2 Q2 A" K2 E6 T. S' O. j) Y% a   }
" m, R! ~3 Z2 H1 j% J: ?; c- C3 U7 V, P$ [/ C2 x( [" Y4 Y3 ]
function moveBall() {1 H3 |! _6 [* I7 y
   if (superballRunning == true) {6 v% v& M8 j+ v4 a; g2 v  D* p
      calculatePosition();/ n; Y# _* P' ~' W, n* f
      if (document.all) {1 s0 u; z# y0 u1 `# Y
         document.all("supertext").style.left = xPos + document.body.scrollLeft;$ o* y6 z% r/ j$ b( b
         document.all("supertext").style.top = yPos + document.body.scrollTop;
# C  h7 H8 Y% w0 z& S+ A         }
4 O+ e; q7 J; f( j- m5 H; \- u      else if (document.layers) {# p9 T2 j7 c9 |& ?! h
         document.layers["supertext"].left = xPos + pageXOffset;! S& n$ l5 @+ L
         document.layers["supertext"].top = yPos + pageYOffset;- M+ q; K4 A4 e, q0 s' f  s5 i
         }0 @0 H  z4 |5 m# V
      animatetext=setTimeout('moveBall()',20);1 w/ G, F/ p# U( }3 P: }
      }4 t* y* P/ W3 K6 |: J
   }' w. S: I0 G# z% {* [# y/ _- \0 }
& ]" C- G7 p) ]0 O
function calculatePosition() {6 n5 n+ M# O, V& o
   if (xDir == "right") {
) k) |5 O7 h8 Y. ~- Q* [' a4 A      if (xPos > (xMax - contentWidth - BallSpeed)) {9 x, Z, z2 e( L' a
         xDir = "left";8 ]) _, C, [7 e9 N
         }
; Z, I; _$ N6 }; H7 S* T; l      }
+ H; M3 L# w/ b   else if (xDir == "left") {
7 @; Y& v2 V! _      if (xPos < (0 + BallSpeed)) {
! E8 R. j6 T! @! I1 L& ?7 A         xDir = "right";( s. O) b( w4 b1 \8 L4 Y
         }
: M3 y: w4 p, X. s( O: ^      }3 Z+ ~" n, E5 I* e
   if (yDir == "down") {4 z5 x' X" I, q! X2 z7 t+ K/ n. D
      if (yPos > (yMax - contentHeight - BallSpeed)) {6 K* n9 u& P: n9 H0 @
         yDir = "up";5 |/ ^0 L- i4 _" m, v
         }4 Y9 h# H; `* M. c
      }
" F6 x$ [6 Q; r/ A   else if (yDir == "up") {" ^8 T/ q0 g) m; Y1 j
      if (yPos < (0 + BallSpeed)) {
' p, a3 J) M5 s. T- L         yDir = "down";* y& }6 p$ {# o& A" r  W, K) i% L
         }7 P6 c4 m. p; t% |# L9 R& @4 A
      }5 u+ Z8 b% Y+ I( y5 i5 r/ z
   if (xDir == "right") {& [; {+ F& s( ~1 f; a% F, l
      xPos = xPos + BallSpeed;- C' K. Y8 S0 x2 v! h- d, Z
      }+ H; d- b# e/ Y. b9 P' y
   else if (xDir == "left") {
, H; B7 |6 x/ ~6 n/ f      xPos = xPos - BallSpeed;
2 `# R$ @7 P- q      }
3 u; g; w- K9 m% u   else {* a5 r8 a3 {- ?2 Z; {9 i, ]$ y& B
      xPos = xPos;; b. B) |$ W+ m) S3 D8 i7 R
      }7 u: [  M( ~; W+ k
   if (yDir == "down") {- M8 V  p: V& W9 I
      yPos = yPos + BallSpeed;
/ ~( V5 V' `2 A5 A, Z      }0 ]4 T8 r1 M4 O1 C% M. k
   else if (yDir == "up") {
- l# t% z4 v6 C% k$ b+ d      yPos = yPos - BallSpeed;
5 R0 V' s6 g* h# w) J      }
: l8 y% x4 V3 w" J% L5 i. T, ?   else {+ X( c/ y4 L' G/ d% w1 X
      yPos = yPos;
: r) z; i" W% D" L      }3 U1 A* E% C! K8 ?- k& @6 M( t
   }6 Y" h- }# a6 ^
  t/ M' k* W" g$ J& N& Z: |5 P# X5 r
function hidetext(){
1 u3 F1 @' k/ M) ^9 Y: ~5 V7 dif (document.all)
& V+ @( K8 B! |& K0 nsupertext.style.visibility="hidden": l9 R% V" J. W- }" M- l5 k& @2 X
else if (document.layers)- Y9 F6 x. h5 D
document.supertext.visibility="hide"
0 D5 m; Y" Q& ~7 Z: wclearTimeout(animatetext); Z8 R( w$ ?* x
}
9 N, u8 y8 b4 w, d& E9 Z8 b. j9 P1 D  I! f' y
if (document.all||document.layers){( ]; k2 _8 u& ~. B4 ]+ C$ v+ N
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 \/ B  f  M4 X+ q+ w( J+ c
window.onload = initializeBall;  \) r' N+ N2 t4 l3 m5 g; }
window.onresize = new Function("window.location.reload()");5 @% @( [% l$ L" G
}7 `7 j+ N4 M9 @
/ m6 i- p+ L6 ?
</script>

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