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

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

<style type="text/css">9 I: Y: Z& Y5 o4 [4 ]" ^
#supertext {# {) y8 `. m1 p  a3 J2 g
position:absolute;
6 K/ @+ p9 l% H  Eleft:0;3 C7 c/ x5 _6 e
top:0;
0 Q' @6 P: D* P0 h4 h8 Xvisibility:hide;
# q/ w9 C! g7 ~9 h7 \- A: U0 m) @visibility:hidden;* M  @( x5 |# S' d1 J) B
}
- g6 |/ r2 N: F) W</style>6 z5 R3 \; f4 ]/ |) z
<script language="JavaScript1.2">
4 X& f* X5 g2 ^+ B<!-- 改变下的字体的大小。颜色-->  D. D* S/ E7 P" a( n, s: n) H
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
3 n' ~7 a2 N. ]. q7 [7 Qvar hidetimer='';: m$ F1 R2 L$ Q2 N* C" _9 Z
<!-- 改变下的弹跳速度-->0 G4 t3 \! x; \8 O8 o2 ]5 \' h# E
var BallSpeed = 20;
1 J- H6 l' D3 j) nvar contentWidth;1 H# [: B# K$ r1 X" q+ K
var contentHeight;
% B, i) t& N% }8 T# s: @$ i# T6 evar maxBallSpeed = 50;; I5 J4 `0 R% ~$ [9 g* w
7 `+ y3 L( H: |) J

% A6 f  U( R; K' Rvar xMax;
8 \+ E  @/ k: |9 k# Pvar yMax;; |! D7 G6 x, ?* B
var xPos = 0;. B  A5 Q+ w6 R. s) C
var yPos = 0;
0 J  F5 x6 e- _var xDir = 'right';; L3 K0 ~: g9 m3 z7 |
var yDir = 'down';! I+ c, h$ v  e/ |5 x/ O
var superballRunning = true;$ k& j& v1 r2 x
var tempBallSpeed;- O$ u4 w' y, k$ S! V
var currentBallSrc;; q5 v$ z2 o9 F' B4 U# {9 y
var newXDir;3 h3 g% c' F$ u) [+ z
var newYDir;  Z. J8 u9 `% n$ u1 B6 B

- j- [$ ]' A4 s/ t6 `function initializeBall() {/ |4 C2 o& _; L7 G8 b
   if (document.all) {
: N  Y( v! i& t1 Q6 K      xMax = document.body.clientWidth
  `! q# ?  H9 p      yMax = document.body.clientHeight- [7 V& |, d7 g. b4 [) T
      document.all("supertext").style.visibility = "visible";% h5 m, G6 W5 i4 s" k% W
      contentWidth=supertext.offsetWidth
' c7 x2 g( g- A      contentHeight=supertext.offsetHeight
( E: M) u5 c/ K) R$ U1 K! }      }
, C+ |7 W: C/ m4 A1 @; k   else if (document.layers) {
( F- B# w6 _8 n      xMax = window.innerWidth;
7 w. N6 i+ h, G2 @' u# y- F      yMax = window.innerHeight;/ Z8 v3 @2 X3 X( Q! A. V  s+ ]
      contentWidth=document.supertext.document.width
( B7 k: p- ~& o2 W# K, u      contentHeight=document.supertext.document.height/ u8 ~: j6 P2 {* Z4 r
      document.layers["supertext"].visibility = "show";
% ~( W+ G6 A3 x* O6 `' }1 q      }
, M, y& v/ P8 w  b* t8 ^   setTimeout('moveBall()',400);1 U. t& [# y( v( Y8 Q" `- `! `0 X  R" a
   if (hidetimer!='')
% R3 _. k& C; e' s% J$ a   setTimeout("hidetext()",hidetimer)
  e( F1 A& Y: d   }
0 t8 d5 V# }1 s" ]
$ g( p) g7 O% D- L, u% Ffunction moveBall() {4 g6 ^8 s, m! }% p& d. k" C; j  K
   if (superballRunning == true) {
2 q" ?* p6 P6 I- u  v      calculatePosition();) z" k2 }8 N8 N3 c/ l9 X$ y! H' y
      if (document.all) {
  w1 W( M# _4 C% Z2 Z         document.all("supertext").style.left = xPos + document.body.scrollLeft;
) `+ g1 ~1 u' j" d# p         document.all("supertext").style.top = yPos + document.body.scrollTop;
$ v( K4 Y9 @* e& T4 X- V         }
* {4 A9 H% f; |' x2 m4 L9 y4 A      else if (document.layers) {; f- V: d3 k( N& k& _
         document.layers["supertext"].left = xPos + pageXOffset;# A0 e3 u& a; s0 H
         document.layers["supertext"].top = yPos + pageYOffset;
4 J5 U! m" u$ \' f1 z         }$ z# c/ S+ n; t( m5 H
      animatetext=setTimeout('moveBall()',20);4 E! x# ^  c' B8 q  N& A& I
      }5 p1 J3 S) W8 w  s5 I
   }
6 V3 Z4 O: b; E: ^. G; q2 h; _- b5 D$ R& V7 g8 _3 D6 `# Z
function calculatePosition() {4 W  |3 {1 l% C- G4 R' l# Y
   if (xDir == "right") {3 q; w- v7 w8 B# K7 G6 r
      if (xPos > (xMax - contentWidth - BallSpeed)) {
7 a3 X$ p; ?3 D( F9 w, A0 \9 E$ A7 H         xDir = "left";
# ]! p1 ^! w$ y5 k1 i: G( Z         }
: E; ]' s* W* j      }
4 p9 b' m0 r. x7 k, x   else if (xDir == "left") {
% T/ s3 l, y# q$ q+ r5 g( h4 X      if (xPos < (0 + BallSpeed)) {% M1 g, d8 f. U
         xDir = "right";) ?- R0 B) Q5 m
         }
. {. F2 w2 l. X7 R8 U$ W/ A3 b+ g      }
% l1 p% _/ `- R) l! w" k; ?+ `" [   if (yDir == "down") {" K7 _/ h; f6 J0 m: J$ v7 _
      if (yPos > (yMax - contentHeight - BallSpeed)) {
; T% u& P2 ?5 u         yDir = "up";( d- |6 i6 ^3 @; j7 U: G6 }
         }$ e) Q/ W* h. S5 L
      }
8 C, B6 D/ P- ~/ l3 ^   else if (yDir == "up") {
2 J: X1 W! T; m+ F/ m2 s! J& M      if (yPos < (0 + BallSpeed)) {
( A% `4 L7 Y7 e" q% s; ~         yDir = "down";: j3 E& a, v( }5 L
         }5 D* p. o0 d4 f, }* G! C
      }
% C( m) r  }- r   if (xDir == "right") {
: w% v: b1 `3 I0 A      xPos = xPos + BallSpeed;
2 u. ^' \8 s. Z      }/ H0 k5 ~6 ]( u: u' M
   else if (xDir == "left") {
- W4 w, q+ Z5 K& ]$ y      xPos = xPos - BallSpeed;6 }: y9 j3 A: D$ o' ?5 s. w
      }
) S/ @9 M2 d* \5 A   else {
' G  h  P: ?; C+ ]4 T: J      xPos = xPos;# G% V) F5 s3 D
      }
7 {* O8 x- d0 ^) h: m   if (yDir == "down") {) S) @+ C6 g6 `6 H
      yPos = yPos + BallSpeed;5 U+ |* c. ]4 y6 r* A+ }
      }: h6 m' u" O% L! \0 J8 c& b, ^
   else if (yDir == "up") {; c  ^0 t' H% j& I, s
      yPos = yPos - BallSpeed;+ I2 Y' }+ m& u2 c* l  d: q
      }, ^& d4 G/ J  F( N4 _7 K
   else {: u5 ?* K4 [6 S* s+ ~0 N% {. \
      yPos = yPos;
( D7 M( X6 {# n) q7 S) F- E      }( Y. Z0 }4 ?: P5 V8 |
   }
7 r( ?2 v1 p; Q2 u  y% s
" s1 S9 V! Z* D  ]function hidetext(){
* }# A, }* |! y0 I, C7 H- z$ mif (document.all). T4 r8 @) ?, d  h1 ?+ Q! T) q' a2 ~$ i
supertext.style.visibility="hidden"& ~% R. t; S- o0 l
else if (document.layers)
& N; _6 l- D4 r+ R1 Idocument.supertext.visibility="hide"8 K6 L1 i8 l6 }! u+ S5 P
clearTimeout(animatetext)
) W+ d8 U/ V- z3 U}
2 v: U. k( b0 P( w
/ A; D/ S& g( y& ~if (document.all||document.layers){9 q, c9 ?( H! c3 j' `5 k
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. B( T# J2 e  Vwindow.onload = initializeBall;/ z" N  f3 x- D8 M0 N
window.onresize = new Function("window.location.reload()");* U) W7 M( B4 a2 Y4 X! [
}9 C  u! `: e# F) R4 q* @) H, _

1 R/ Q( X: n1 [' h' @$ x+ V</script>

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