返回列表 发帖

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

<style type="text/css">
* n2 ^5 B! Z4 h) W1 R#supertext {
5 l0 s% f4 V# w' R( X8 n# iposition:absolute;! i' R  D8 t7 K$ {3 U6 V
left:0;
( q& R; T% Y6 ~" p1 v! `7 ?$ Mtop:0;
. X3 r, Z" E5 _3 g" L0 u3 H3 E( Qvisibility:hide;7 K8 J, \& V: R( M
visibility:hidden;, q8 K. _7 \: ?; ^' Y$ h9 @- o
}
6 @% j& k2 ?! a& D</style>: `& B- K0 Q0 a4 w# \/ l
<script language="JavaScript1.2">; h0 E& j. X& }4 k( j
<!-- 改变下的字体的大小。颜色-->* c% A! L8 x+ v( [  a4 z
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( o- g" a% c) c* K4 ]3 X2 Z9 evar hidetimer='';; Y1 j; V! W& {
<!-- 改变下的弹跳速度-->
. V& [6 B+ D3 ~) n; qvar BallSpeed = 20;! T# t" m1 Y+ _# u- G
var contentWidth;+ b4 H' n0 |. |
var contentHeight;: u8 [% ^3 q% `7 R7 L& b" D
var maxBallSpeed = 50;
9 D& [, v- E4 s. S% J7 p8 c9 ^
2 \/ D* ~3 }8 o6 s- v# q
var xMax;2 `; |1 B) F9 U7 _% i/ j
var yMax;( K8 q0 L1 K9 k% V( j
var xPos = 0;2 n) A, ]0 H4 u# k" U0 f7 z% i
var yPos = 0;
: y# l7 T6 e- A- g$ H# m. Jvar xDir = 'right';
+ O7 D! L& H$ B) X. ivar yDir = 'down';
& u- \1 J7 P# Z" E2 r& A/ D& C2 Uvar superballRunning = true;. W0 m2 F% x, w8 V. x1 W
var tempBallSpeed;
; B2 M1 ?* z7 Svar currentBallSrc;" W& _: _( N" w7 ^4 C' M
var newXDir;
" A6 c! T* ^0 @0 Y  ?var newYDir;8 B* p  ]+ `0 _$ n9 v3 O/ U3 n

4 {( {; v" p! j) r( H+ B" F; z! s2 Tfunction initializeBall() {. \$ ^1 {& X9 V9 E" S
   if (document.all) {6 w, K% @1 z4 a, Z6 i" T" a0 o6 J3 O
      xMax = document.body.clientWidth
/ V4 I, u  {. Z8 e      yMax = document.body.clientHeight$ o3 T3 m7 k1 e. T1 X" g8 p2 X! v5 J
      document.all("supertext").style.visibility = "visible";
# c% L% X* P1 `      contentWidth=supertext.offsetWidth6 y9 l& w+ D$ `% v8 r3 z: e5 r- |
      contentHeight=supertext.offsetHeight
" b' h/ F7 W, A( Z+ s$ V      }, Q0 j6 ]7 Y, p* s
   else if (document.layers) {7 S& F' F/ A0 L' A+ G0 G6 x* q
      xMax = window.innerWidth;
" t% O4 ^: T+ Z( m      yMax = window.innerHeight;
& }* X' x: X* N! w) W) Z' l$ s: S. T      contentWidth=document.supertext.document.width# p: f9 f9 j( H. J# ^7 y
      contentHeight=document.supertext.document.height
; N3 k6 b( N) ]" j8 X$ y      document.layers["supertext"].visibility = "show";2 x+ B: Z9 Z8 U1 m9 r
      }! a! X! F5 N( s
   setTimeout('moveBall()',400);) @. D9 K" W. s, C
   if (hidetimer!='')9 _9 w* c' t( H7 y5 J
   setTimeout("hidetext()",hidetimer)0 b9 g2 o* x; A; y
   }# A  P1 i8 M8 q% B* O- `5 c$ F/ K* X

+ V1 x# Y0 B' F  O. ]function moveBall() {
- |9 _1 D( {9 o% z$ t) R; X   if (superballRunning == true) {( P; _( G) S: }6 a9 n
      calculatePosition();
1 K" |+ c2 V6 b% i0 p2 F      if (document.all) {
# }7 g) I( Y+ N5 Q; |         document.all("supertext").style.left = xPos + document.body.scrollLeft;
, F  K# B* b- z, s9 @5 B  z& Y         document.all("supertext").style.top = yPos + document.body.scrollTop;
! z: }' P9 m& v: E$ T" b  T         }7 T+ L, H# V, L* Z/ \/ ~
      else if (document.layers) {' p' D, ]6 S3 |- \: q7 s" T
         document.layers["supertext"].left = xPos + pageXOffset;& }9 U  ^9 h" E6 M3 P% O( D
         document.layers["supertext"].top = yPos + pageYOffset;: n( V: G. Q+ [7 b) F
         }% X# o5 ?! t! i9 D" J. [* H
      animatetext=setTimeout('moveBall()',20);
5 v0 M) ^5 X- e' ^      }2 d  f  J& F! I; j- K
   }
7 @2 Z4 M$ Y9 f: Q( P4 Q% d* ]$ q* e8 Q
function calculatePosition() {
& F/ L8 l8 r1 z5 @/ X  y9 E   if (xDir == "right") {( ~" }  m4 _! K) X
      if (xPos > (xMax - contentWidth - BallSpeed)) {
( t" q8 k0 a$ t. d+ K2 A* P8 P         xDir = "left";
. s0 j, U, [3 F! S# f. H% P         }4 V4 g4 J' q1 e2 H, z
      }* U0 q: z5 V, x# C
   else if (xDir == "left") {* Y" T) y, r- s
      if (xPos < (0 + BallSpeed)) {6 v9 H; g6 \+ m- R" B2 Z2 o6 @
         xDir = "right";* }( `7 i7 K/ L. |. N
         }
& P1 a6 `5 [/ h5 s2 R& {* t      }
1 m4 p8 b. C" i/ R   if (yDir == "down") {) g! [; F- j5 z1 U, c& Y
      if (yPos > (yMax - contentHeight - BallSpeed)) {! g: G5 p4 {; u4 [* J
         yDir = "up";
8 r* p* i  ]/ i3 w, I/ r% j         }
7 S3 N0 H" Z' _3 z& N      }# z7 j" i5 j- m6 d& m
   else if (yDir == "up") {
. A4 J- v2 s- |/ t" R3 `      if (yPos < (0 + BallSpeed)) {
. L: R1 X0 Z1 p0 E" m         yDir = "down";: K1 t- t! Z% z  _
         }
" U  }' y7 r, V( F! G7 Z) X" r- F      }7 @+ o5 _6 f0 n; |4 r0 l" M: c
   if (xDir == "right") {' q, C$ {1 X: f9 I: R: L. E
      xPos = xPos + BallSpeed;* ~2 l# B; R: N1 h/ \' P4 _0 s1 f
      }
# z. U2 r& g$ F5 A   else if (xDir == "left") {
- [/ L2 h" w$ L0 X' V2 B; C' \5 r      xPos = xPos - BallSpeed;2 A9 Z. M! f  C/ k
      }" o1 B% g8 N  n' u9 g. a
   else {1 _. x+ H, O4 z, }+ o! u2 G
      xPos = xPos;- F$ ?: [; N3 q  W9 ^2 G
      }
+ W. i8 ?. d% r   if (yDir == "down") {. |$ _8 \  L" s
      yPos = yPos + BallSpeed;) ?# W7 j# y6 B; n
      }
; e+ s7 m9 p0 W! I; t% l# X   else if (yDir == "up") {+ O* Y  B, c) |9 H: p9 s) b) c
      yPos = yPos - BallSpeed;
7 W! e9 D3 P7 [2 a      }# ]. u5 P( }! C
   else {
! P. u8 z* z- q$ P& V7 V      yPos = yPos;. K8 S' O1 R( C. s( X( w
      }
$ b3 ~7 I1 \: X6 e   }
! j+ `# d+ M7 R, J; k0 |8 S$ d4 A
) Z; `& E6 X; Z9 b; {function hidetext(){4 G$ \. z; a6 y& r
if (document.all)9 R; H3 F: h8 k% K& A
supertext.style.visibility="hidden"
$ d. E+ D0 n) {  T9 r7 m/ \else if (document.layers)
. F* y' Q/ P) u- ldocument.supertext.visibility="hide"2 Q* f7 K5 l" B" `) l* A
clearTimeout(animatetext)+ {8 ^, I8 k/ C7 P  _
}: p- c' ]7 s9 J; {
5 j/ ]; F2 a2 G) E3 `5 {. i8 ^
if (document.all||document.layers){* [9 G. N" k( M( N/ u1 {: {
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
, D# R3 [8 `, }( Fwindow.onload = initializeBall;! w) R9 D, R9 ~* ~9 q% U1 N
window.onresize = new Function("window.location.reload()");! l& n- V4 c  ~9 e) \6 D
}
- g; X! `2 e% c" M# ]" j8 O
* V8 X* q4 {, ]  y; y. M9 d1 Z' g</script>

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