返回列表 发帖

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

<style type="text/css">: z- g) b, U6 C" m/ p
#supertext {
4 F' e1 ]0 t7 W, z) h# X7 Vposition:absolute;* S$ Y6 U( Z- P6 d+ c( V
left:0;
+ r% c( J( C. X5 @& \top:0;5 v! u; s/ a$ L4 y
visibility:hide;
+ C& n# ~4 t- z( I$ evisibility:hidden;
# p: a, D* ?" F8 E7 n) D}( w3 N; K  c' I2 M+ f2 Q' j
</style>+ R3 \/ I7 [8 Q  e5 ^- }
<script language="JavaScript1.2">
. z( E4 e$ a0 ~5 z7 W) T( P; z<!-- 改变下的字体的大小。颜色-->1 a* {/ O* X* a9 k. l7 ~* r' ?
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 S4 u, y6 h# j, Xvar hidetimer='';4 @; d* b0 w$ D
<!-- 改变下的弹跳速度-->) W' O" [9 p& I( n" A5 J2 i9 v' k
var BallSpeed = 20;
& z# g$ ~2 ?1 dvar contentWidth;
& g* I3 e4 G# U& f7 i& j# vvar contentHeight;
  Y8 S; l5 s2 V7 N4 l/ t7 gvar maxBallSpeed = 50;6 I9 q( l( y0 U* Y# Y) w2 t
; O, [9 ?  V3 [% F8 M
5 c) M$ ]% P0 S" p/ H+ o  s. V
var xMax;
, f$ |* O$ I% xvar yMax;
8 h5 x, F: U" C9 {var xPos = 0;
0 p/ D) [/ @- [var yPos = 0;
: a1 R" h- A- Y5 d  W0 hvar xDir = 'right';2 Y( H+ Q6 o7 }" I
var yDir = 'down';
& Y* E) P" q; n6 Jvar superballRunning = true;
2 j1 K' F' K1 B1 w+ @0 J) G8 Q( hvar tempBallSpeed;
9 t4 w6 R" b- `$ Y; f7 V+ Bvar currentBallSrc;: W* @# b% I) y, {0 G) x: V. M
var newXDir;- @" h" \; O" Q9 Z" ?1 Y2 V
var newYDir;4 U7 t2 C9 }1 Q4 B

+ E  n' S  L1 F5 C8 A0 c1 c" jfunction initializeBall() {' Z1 u0 \7 X3 ?7 I6 Q- ~1 I4 S; u; u
   if (document.all) {$ N) |2 @# z+ g* b
      xMax = document.body.clientWidth, [9 Y+ k* v+ \9 W( U( P! {
      yMax = document.body.clientHeight
0 q+ c, n; \2 F  [& p: l% ~      document.all("supertext").style.visibility = "visible";
( Q! |1 M* V4 n, [      contentWidth=supertext.offsetWidth* L- \) n5 R4 w
      contentHeight=supertext.offsetHeight
: e# z& u9 v1 C/ ~  G      }
5 K9 {' v) S0 U6 g1 L   else if (document.layers) {, _, [. l6 n6 l
      xMax = window.innerWidth;" V7 b) X  w3 G) A
      yMax = window.innerHeight;$ M, z) S6 c5 @  K6 z
      contentWidth=document.supertext.document.width
3 }" {$ o0 i. W& E      contentHeight=document.supertext.document.height
! S, |" b" ?, H: N! @# v      document.layers["supertext"].visibility = "show";
7 c6 X+ o- o+ p  r      }
4 n' e4 [/ X3 x( t; ~; y  p   setTimeout('moveBall()',400);0 \. ~& C4 L7 d% ^% T8 v
   if (hidetimer!='')
3 g5 O3 O8 V5 W! ?- Q   setTimeout("hidetext()",hidetimer)
/ e* Z- V  b" Q! j0 `   }6 k# j9 _5 }$ L: B4 N7 A1 D
5 _0 m+ o! F/ i3 v) K$ M  y4 z
function moveBall() {+ }! A* O8 `( `
   if (superballRunning == true) {, B4 W* C) Z2 N
      calculatePosition();* O8 f+ G) K, W( n+ a! _  ~) ^  y
      if (document.all) {
5 C# \8 v7 }! G' B         document.all("supertext").style.left = xPos + document.body.scrollLeft;. I& v' e, Q! R4 u' l6 q# [6 W( u
         document.all("supertext").style.top = yPos + document.body.scrollTop;+ M! g6 n( F6 ~
         }
( }4 l1 N% h# \! z% G( g) a6 A      else if (document.layers) {, c" R1 T2 |  l! \! w
         document.layers["supertext"].left = xPos + pageXOffset;- K% X  d) g, w
         document.layers["supertext"].top = yPos + pageYOffset;8 q' @/ G: H& E& u
         }7 |  [$ G, D; W  h6 J- l2 n
      animatetext=setTimeout('moveBall()',20);: b0 t9 M; L0 Q* {( n
      }! [7 u/ L+ e+ n& P' h. @2 b9 `
   }$ e; {6 g. B3 d2 U
& @. ^$ X8 c2 h4 l! L0 R
function calculatePosition() {
; l; j; h$ u, v6 M# t' S   if (xDir == "right") {7 Z8 a5 ], E5 u( {  Y9 N
      if (xPos > (xMax - contentWidth - BallSpeed)) {- L% k1 h/ |' O4 o
         xDir = "left";8 P" b1 E3 a+ z7 j8 J" N" H: R
         }. a* W; _  C0 ~: ]3 k
      }
8 D" F" c# J% O/ u* r' s   else if (xDir == "left") {
" ~- X# F/ _* e& Y      if (xPos < (0 + BallSpeed)) {- N! \6 j0 g+ g
         xDir = "right";
3 |7 G( m  A0 ]+ i/ U2 l4 X" R         }
- H' t$ V* d& m7 z, x      }
1 F+ _( |2 @1 y$ M+ E   if (yDir == "down") {
6 A% ^) n7 ^8 K      if (yPos > (yMax - contentHeight - BallSpeed)) {
* j7 U: c; @# h) `% `) T3 h6 c         yDir = "up";; ?4 _" H! N8 ^! a( [/ v% R+ L5 i
         }
# k' I/ A5 ~8 t9 E8 V7 m      }
3 k. r( `: V. B5 X% v3 P$ V   else if (yDir == "up") {
/ c. `  ?5 ^  t3 O. z9 X      if (yPos < (0 + BallSpeed)) {
4 y! \1 h  O2 x! b         yDir = "down";$ J9 Q, A4 R" i% w  s
         }
0 z( b+ I" S; i" h9 g      }
9 }. G4 s, }3 I   if (xDir == "right") {
% i) r* y9 K6 H- v! S# F      xPos = xPos + BallSpeed;' M; o9 U/ t* [9 j/ U$ F5 t5 U
      }
9 s/ o6 \2 {: L3 H) o   else if (xDir == "left") {
! j- }7 Q+ s' s- c( Z* S& Z( V2 Q      xPos = xPos - BallSpeed;8 x9 a) h3 c) {, z; b; Q& ]' k: l9 |
      }  T, O5 V' m2 O2 t8 V, t+ B9 W# S
   else {
% ]* t& l+ Q  z      xPos = xPos;
3 O6 I1 d$ ~! Y; M8 t      }
+ F' [* H/ L3 G$ I* F. |) z# {) S$ j   if (yDir == "down") {" ?, ]4 W' _1 m, t" W- v) S
      yPos = yPos + BallSpeed;3 ]& h, w+ C; _8 Y9 U4 f( F
      }
( r+ x" j% R1 L0 V& s0 ^7 x6 y   else if (yDir == "up") {
4 @; i* O" a  I& s6 J      yPos = yPos - BallSpeed;
9 o  H9 X" Q& A$ J6 o4 X# l$ w      }
) u* G5 K% X3 x& o6 C   else {) Z! w" D* f0 Y, ]+ Y
      yPos = yPos;
* V" H1 ?  w7 q4 f" H. Q: y& Z      }  d8 o+ _; |  `5 ^' u
   }6 n; q2 n0 r" P* J0 L% D
# y- X' t6 k4 b" ?5 J7 ?
function hidetext(){  R9 b; g4 s9 q% Z# ~
if (document.all); T1 g- U# I5 w& B
supertext.style.visibility="hidden"! \$ w9 a! G* ~1 O
else if (document.layers)
( O: P9 z! K% ~& h# b' o: T+ G7 }document.supertext.visibility="hide"
5 S/ B) G# t; d2 _, X% QclearTimeout(animatetext)
: q5 G% L* T" ^4 e}
3 d6 S! r* f: w0 w0 k1 V
. a4 y1 u5 ~0 @2 [1 a) m& X* sif (document.all||document.layers){  y/ t5 O. y; g8 N
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')# C8 P0 n- z" i& D5 J& G. T
window.onload = initializeBall;+ w9 S5 {5 u" w+ g
window.onresize = new Function("window.location.reload()");
6 X8 p! m3 a, O, O; M1 I4 {5 j}
5 \. W) o+ y2 [: o5 p1 ^3 O4 ~- }
</script>

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