返回列表 发帖

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

<style type="text/css">
9 Q' k- G/ ?2 B#supertext {
" Y, T: C5 Y: u% ^6 j) Y& B( G2 qposition:absolute;
* W1 _. R$ i! f' m7 F, t0 i$ jleft:0;7 L/ t' C& l4 s. Q" Q( q/ a, r
top:0;. q5 t# x  w6 G
visibility:hide;
, |0 n# ^0 [1 {6 {( ~visibility:hidden;8 }0 P* K" x9 u) b+ ?; l
}& g! _7 T5 s7 ~3 J, Z4 @6 ]
</style>
; J+ W$ g1 E) o2 i8 d. }<script language="JavaScript1.2">5 G! I; V3 H) C: k- b
<!-- 改变下的字体的大小。颜色-->
- e; _8 L8 w: i6 i) B( c" c& ~var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'5 X  K3 T: }9 M  n/ e
var hidetimer='';: e: W' y% J/ g9 f/ p
<!-- 改变下的弹跳速度-->
9 d% |0 E: O2 _0 X2 Cvar BallSpeed = 20;8 r' C9 j+ \7 Y; ~, P9 e
var contentWidth;4 h. M3 U* G9 t( E: d3 |. R
var contentHeight;
2 V6 Q' R. Y  s4 O5 R' h; T: L6 w6 {( rvar maxBallSpeed = 50;( @3 d2 H) x2 V+ G* T

0 C- b& H7 }; V& u3 Q' c  t% ?+ U& Y3 H4 a9 i# b# i
var xMax;
' ^! O' {( w. U, Y5 Gvar yMax;5 `, U$ Y( A4 K
var xPos = 0;
* V- }/ d0 g, ]7 x. U6 _var yPos = 0;& O: P) B5 y0 o& I: D. J4 G! ?- Q
var xDir = 'right';
  \6 k1 _1 x" m/ R9 W8 Hvar yDir = 'down';
/ O& N& F& t% l/ s4 V+ p4 \4 vvar superballRunning = true;: ]8 `/ [* Z' g% M) R" J- w& t
var tempBallSpeed;5 r& C; f% v" D0 H
var currentBallSrc;/ Z: O( U+ n  I1 K2 S( K! Y0 d
var newXDir;3 n0 q! L* J( r
var newYDir;, O: z' i2 s! d' O

. b# u( r# l0 `2 ^1 I! lfunction initializeBall() {8 P& ^' a$ V' n4 S' q
   if (document.all) {
* G& ~& l$ G" \- w8 Q1 E* P      xMax = document.body.clientWidth
) q' {9 k0 V* N      yMax = document.body.clientHeight) |* h# u% w2 W& {  c
      document.all("supertext").style.visibility = "visible";
, j' L! K  `( o! Y/ x. \! J6 Z) N      contentWidth=supertext.offsetWidth
, k) [5 g! @& a* t/ u9 A1 z      contentHeight=supertext.offsetHeight' o/ _/ n( o" ]( H1 ^
      }
; |, U/ I. o, L0 @" J+ F   else if (document.layers) {
  T8 \7 S% K& E$ y1 u& t      xMax = window.innerWidth;) T( h- J$ u9 m0 a9 }3 I
      yMax = window.innerHeight;
+ f1 `8 q8 e" M" M' m7 I$ W      contentWidth=document.supertext.document.width
- P4 o1 x$ T' G3 B$ g      contentHeight=document.supertext.document.height
3 z. t: P8 s. n% A2 l1 t. M5 l- l, K      document.layers["supertext"].visibility = "show";
1 G& u+ z$ ~7 s) ?      }. h& ?' ?/ g$ w
   setTimeout('moveBall()',400);
" `3 F! ]. u- o  u4 }; m  P   if (hidetimer!='')6 a7 {3 j; D4 I* O( x
   setTimeout("hidetext()",hidetimer)
5 b5 f: x2 M/ F! {) a   }5 \8 b' d6 a4 {, R( |3 Q( i

5 ~$ }0 G" A7 B/ k" ?6 tfunction moveBall() {6 D# [  t) L2 P! T- |* [; e3 b! |: U
   if (superballRunning == true) {
, V( ^, l3 {2 ~: h! Z, S      calculatePosition();
, s/ }7 A& {5 g3 E- a, J  C* e      if (document.all) {
8 `" K+ w" g0 |8 S, X  \         document.all("supertext").style.left = xPos + document.body.scrollLeft;! j2 z6 A" K5 U
         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 f) K, E* c. S6 r, {         }
8 x8 c  c. a: R- k: M1 X9 [% A      else if (document.layers) {7 U8 y& _8 o( W6 Q# R/ s; I- n
         document.layers["supertext"].left = xPos + pageXOffset;
  F# [, E- @7 X* N: B         document.layers["supertext"].top = yPos + pageYOffset;1 N: s( q% ]' w% |% e. x
         }
: T$ p- u7 t# X# I) A6 _      animatetext=setTimeout('moveBall()',20);
& ^4 U/ A& ?7 F2 @+ W2 H+ D  W  Q7 l      }+ Z9 y/ F3 k+ y; R! y
   }4 f9 q0 R5 G4 q- J' ~  X

+ e; e8 T+ {) J- wfunction calculatePosition() {$ _( r# b; }" ]' @
   if (xDir == "right") {. f2 R& o& l4 a
      if (xPos > (xMax - contentWidth - BallSpeed)) {
: K2 X7 O1 S+ i- l" b         xDir = "left";: k& Q4 p0 Q# S; R# g0 O3 s' U
         }
& m, c" Y! K7 C      }' @8 i+ G' s8 S# s) `+ B
   else if (xDir == "left") {% @: t7 ~; ]1 p! x' B" n
      if (xPos < (0 + BallSpeed)) {0 o1 t9 C/ q, C7 }. u9 h' {% t  p+ c
         xDir = "right";# {+ u' D" t0 Q5 I' A
         }6 x) I& ^3 g) c
      }
9 h, d* z: b, d- d1 o& _   if (yDir == "down") {
% ~& }, X2 E- K( O1 [1 V      if (yPos > (yMax - contentHeight - BallSpeed)) {; W5 {' \# L9 a) u
         yDir = "up";
4 O9 {6 K+ G: s) j/ ^, ~4 k- F( H) p         }
5 Q6 h% @5 c% d1 I      }* o- ]; Z' l' H1 T
   else if (yDir == "up") {
4 S% l; b) e$ H: W% E      if (yPos < (0 + BallSpeed)) {$ x8 f  c+ W' L( k& Z1 y
         yDir = "down";$ b$ f+ U6 `- O2 \; u1 Y1 o
         }( Z- K. e( r& d2 R. o: W0 ?) P
      }; J9 x6 D* t% h. E3 E
   if (xDir == "right") {" V+ ^# m+ z  g
      xPos = xPos + BallSpeed;( ^. e; q9 Y8 a; x; \9 [
      }
& o4 `% V( l& Z. }" L( J/ A0 O5 T   else if (xDir == "left") {( ^% }9 e+ g9 p: z+ [
      xPos = xPos - BallSpeed;
. o7 |% u* P- `( S; D3 D7 j      }
: I: q1 L- {5 N! |9 _   else {6 h0 Y* @) M- @
      xPos = xPos;
) Q( ^& {* ~1 p7 {( w$ \9 P( o      }3 G/ m' G, ?1 n% y. V& }: L( V- [) k
   if (yDir == "down") {
7 k% t- V: c  F% s3 z      yPos = yPos + BallSpeed;, w4 n' d6 {* W! S7 K
      }8 s4 C2 q1 k5 ~
   else if (yDir == "up") {6 M8 x5 f, j) o
      yPos = yPos - BallSpeed;
; G7 W7 ]8 m, Z, |& L- A0 v5 B      }
+ ?+ d  |; h- {: W   else {
$ R6 T% b# s/ V  d      yPos = yPos;4 a  ]( }7 d( {% m
      }4 d3 U8 p3 s9 x+ t
   }. F, Z: i8 n  C/ u- k! M6 p. s0 ?
0 s& o( _$ E+ J/ D' O! q
function hidetext(){0 x) v. F7 V' P8 R. t
if (document.all)5 J( r) w& X1 f3 H2 r" w
supertext.style.visibility="hidden"
' v' b( f5 ^* @; Aelse if (document.layers)+ W: P3 s" y4 `, J
document.supertext.visibility="hide"
3 p: A; w* \1 _clearTimeout(animatetext), B7 g. N: T  m* K+ Y
}
% D* f2 t8 M6 E  ~9 Q
, ~: w% u+ P4 ^, oif (document.all||document.layers){9 ^; k6 ~' D& a1 n8 y! P! W! R+ o
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 |& B) u0 M4 p* Y, L! B$ A' R/ b- e6 T
window.onload = initializeBall;0 T0 G: N% M, [( b
window.onresize = new Function("window.location.reload()");
2 g' B0 [# @1 {% \4 y/ C. y}
- d6 n' O  ]5 ~& P- d/ D2 d' ?+ |" W8 I0 S' Q
</script>

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