返回列表 发帖

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

<style type="text/css">
8 \. u2 R, W- r7 B7 u0 o#supertext {" |- X5 A8 ^5 Q. ^- E. N
position:absolute;
& Q+ ?- o8 {  v4 Oleft:0;
7 O+ M& Y4 F" i4 Ptop:0;/ D- _2 a) ~: L, O+ G7 _
visibility:hide;% h; x8 C2 p& }2 u
visibility:hidden;
8 _3 U% R3 \% R* H4 V, j}
; ]) Y& `( J) h; w1 i</style>. r& Y, J3 S0 G+ c9 r) P
<script language="JavaScript1.2">" f: }! X3 T0 U2 Q
<!-- 改变下的字体的大小。颜色-->
, P& B+ x3 N: ]( \' G# o4 Jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 X7 j' u: g: H: l, j6 y# {( J8 Ivar hidetimer='';& f( g3 |8 D9 ]: a5 G  m
<!-- 改变下的弹跳速度-->8 q* w4 \1 t% |! S1 o$ M+ a
var BallSpeed = 20;
% C' c8 b, f& j5 L: j) qvar contentWidth;
$ r# N( T. @1 k( o2 ^- u: s2 i( svar contentHeight;7 U/ k2 A! a& X5 M8 _5 G
var maxBallSpeed = 50;
! K4 G9 M: y0 `; `% K% E; E5 ~  w
1 R" r3 L' K0 N/ B6 Y. z
var xMax;: [! \; g/ y/ Z0 M8 s+ a
var yMax;3 e5 z7 |  }4 t: N
var xPos = 0;
6 I& z7 \4 a. Svar yPos = 0;; Y, T+ J0 \) N. E$ m3 s
var xDir = 'right';
  T& B" y5 D$ K) q9 ivar yDir = 'down';
8 f$ D$ L, m( x7 Q6 l1 Cvar superballRunning = true;" P/ u$ w9 l& A
var tempBallSpeed;
, h& A$ m, U+ a4 dvar currentBallSrc;; \: t5 p! B1 L/ q+ d
var newXDir;- M( C2 G' F& J1 _+ K3 c& s
var newYDir;
  p5 n4 K. E' V- q
. ?* [6 c: [# X6 O  P2 W& vfunction initializeBall() {0 c5 U" z, ~# S* o* T2 b. v
   if (document.all) {
( P6 g) \, R% J      xMax = document.body.clientWidth
, |" B2 v+ g8 }& M/ [0 a      yMax = document.body.clientHeight
4 K$ |+ t9 N% U- x5 X      document.all("supertext").style.visibility = "visible";
7 T' f3 B2 @( h      contentWidth=supertext.offsetWidth
! X7 r* n' U; P5 p6 `# r      contentHeight=supertext.offsetHeight) S  Z0 k8 m" a
      }
! z/ V" b) ]4 Q3 I' r; l, G   else if (document.layers) {
) c  ]( @% t9 W$ [  B% z: o, t      xMax = window.innerWidth;$ T8 m) t5 T  @
      yMax = window.innerHeight;' g, K& T8 J+ |1 V' L3 R7 O
      contentWidth=document.supertext.document.width
% E: ]7 c1 n" S" D& |      contentHeight=document.supertext.document.height# {+ y$ n% n+ R8 z
      document.layers["supertext"].visibility = "show";
0 n& r# N7 I  t8 w$ |* q0 _: e      }
' @$ M4 g" l% Y* W. S1 x/ |. ]   setTimeout('moveBall()',400);+ l3 i0 Q( A# X3 |
   if (hidetimer!='')
4 L. t, d: d/ q, s3 f% ^   setTimeout("hidetext()",hidetimer): h5 C; E. r+ l" ?: X9 ]
   }
1 T1 x  A2 z0 j0 N7 N- a1 W) z* `& d$ N; s" @% E3 X9 p
function moveBall() {
- ?( a) Y. w& {3 m; A" W+ W   if (superballRunning == true) {
/ w, B- x/ m9 w      calculatePosition();( H6 u; c' G, k2 L& d
      if (document.all) {
2 J% A/ E0 ~, B" N4 K7 o         document.all("supertext").style.left = xPos + document.body.scrollLeft;
, O+ E. X5 r3 t) {$ ^. C         document.all("supertext").style.top = yPos + document.body.scrollTop;# |8 [: a: r0 J/ k2 S
         }
$ A2 }9 q: f+ p- c, G0 r      else if (document.layers) {
$ ]* X0 Y; L- N) Z( ?' j& G         document.layers["supertext"].left = xPos + pageXOffset;5 e3 F8 c' y: I8 e
         document.layers["supertext"].top = yPos + pageYOffset;
  w3 i& t2 U8 _         }
' L. o  h; v) [      animatetext=setTimeout('moveBall()',20);
6 A" x- S' r0 z4 n! L$ d6 I      }7 N* k: x3 S- s& Z6 q8 E/ B
   }+ k" B6 c' x9 s: f# s1 \

3 V/ R" k. n+ P! I6 ~$ i: }$ Nfunction calculatePosition() {
# X3 w% g+ U! N1 ~; r& l( z/ c   if (xDir == "right") {
7 _0 p( r& t+ `  V% `# G5 i7 }      if (xPos > (xMax - contentWidth - BallSpeed)) {
) p# _9 {" Z- m+ ^         xDir = "left";. s$ s0 |- n( x5 Z: V( L
         }
" L: W7 z% `# _+ ]: v; B3 A      }" x$ b% t* O8 f* g9 e
   else if (xDir == "left") {
8 J/ Y9 U; U: C  l( M( k. q      if (xPos < (0 + BallSpeed)) {% |$ g  [6 t0 V6 f) K7 \
         xDir = "right";8 h: B5 C7 G5 X
         }
9 s9 ^* {) \8 V# Y- r6 W      }- o% P' M! @# ~. J4 {
   if (yDir == "down") {! f: T+ M( A+ c+ N. ^% [' \! s
      if (yPos > (yMax - contentHeight - BallSpeed)) {) G) }# _! \+ ^. s' Q2 W- S
         yDir = "up";, Z" \3 Q* N  |* U, P# L4 _7 i) S2 b
         }
4 w: `& `' t* V! n% n1 M      }& k6 ^5 y! H: D# ]1 Q5 r
   else if (yDir == "up") {1 G5 x3 I5 X* W+ F* {7 }# \) q! Z8 V& u
      if (yPos < (0 + BallSpeed)) {5 W+ P) G. m8 t, X5 n% K, j: @: I
         yDir = "down";
1 g5 x4 @, h0 P0 `         }
4 ?2 E6 |' r/ i& Z1 \      }* r) G9 @. g9 a$ ~% W% n
   if (xDir == "right") {6 d3 l1 @: U$ A$ `) q- z. R5 D# V, N
      xPos = xPos + BallSpeed;
8 K2 ?3 ^& d; h: c      }
& V# `/ L/ d& X' d4 R4 d   else if (xDir == "left") {8 e3 L& l( }1 d7 b. S, L" l" Y
      xPos = xPos - BallSpeed;% T; o6 e# l" E. L- T6 C
      }
7 F4 G1 Y) J8 m- g+ }% h6 E  R3 L   else {6 _3 \+ B+ ]3 g( u$ x' n
      xPos = xPos;
  z+ r5 m- Q1 ^' v      }5 o/ V( L: d( a3 G+ m0 [
   if (yDir == "down") {9 J# j' R& S0 G+ S1 e7 h) @
      yPos = yPos + BallSpeed;3 y) X" ^6 e, [& f9 [4 I; o/ X
      }
  B' Z- H6 X4 @   else if (yDir == "up") {0 u4 `; P+ V2 {  M3 Q
      yPos = yPos - BallSpeed;* R% j5 e4 }2 k
      }$ R* L/ H6 W8 m8 o; @
   else {1 e  [/ E( P+ w# F, E8 [6 c
      yPos = yPos;' @! o, r2 M4 C$ C2 w& U
      }. h$ a/ C, }/ J0 r! s
   }
2 j; @0 i+ f% i4 }8 ?1 z2 \- z; t) L/ A7 c. h. P6 ^0 v; y6 Z
function hidetext(){, K  I; B* c3 Y4 f) j
if (document.all)- }8 n( p' H! I. Q* z, a
supertext.style.visibility="hidden"! _5 _+ M; G3 S/ B
else if (document.layers)# q8 r3 Z! h+ v' @$ J
document.supertext.visibility="hide"
* r- ^, y! `! Q4 ?# a$ a2 _- yclearTimeout(animatetext)
  c% |4 {; L3 t$ o& y9 d* w}/ d2 f3 q# ~5 R

& I! c4 z& k. C4 hif (document.all||document.layers){' E7 G7 q* J. E! Y1 J, G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" n9 l8 K5 O% R+ B% r) s  E0 Cwindow.onload = initializeBall;+ t4 Z, ~; K& {: `' N
window.onresize = new Function("window.location.reload()");  d4 _- E  ~! g1 x# p. L! [/ i' t
}
0 k2 \4 j; z% E: L( V: s$ ~. @1 Z' x" o7 k5 Z3 ?) X$ r
</script>

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