返回列表 发帖

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

<style type="text/css">
" s0 W  T. `" Q8 k( I! q#supertext {
7 [* F8 S* s8 f, Z/ Y7 p9 Z4 Hposition:absolute;
: ]' k+ e, p7 o4 ?1 Tleft:0;& s: s4 s0 M" }
top:0;
/ y) f/ T2 J! Y, z. S! K, R5 x2 d9 ?+ Kvisibility:hide;; r# i9 Q' L& \( E
visibility:hidden;
5 p! @6 c" R. I% C) o# x0 X, h}% M7 c% L( ^+ u& i4 d; B0 K2 s! G
</style>" z8 u  i6 o2 N/ l* [2 |
<script language="JavaScript1.2">% H/ o7 C2 b! B4 k" e) e* K
<!-- 改变下的字体的大小。颜色-->! x) p! ^' N% @' W8 s( `9 e
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# z( [9 x1 a- S0 U+ {4 x: C
var hidetimer='';
1 o. i  n- E+ i9 v! e<!-- 改变下的弹跳速度-->1 l4 B  J; j$ i( k' }' s. B" s
var BallSpeed = 20;$ R! k, R; X3 ^9 e* A6 t% K/ l
var contentWidth;
0 c" v, h0 l" b5 `% O7 H" e) L7 ~/ S7 |) jvar contentHeight;
7 V. @# P  ?7 \) P) `2 fvar maxBallSpeed = 50;
2 v  o  d0 h. Q+ [' V$ @0 e- J, o
+ L( Q. i: E% q6 w0 H+ j- g
2 C5 j0 S9 b) fvar xMax;
! V) @1 E3 x+ p( Evar yMax;, W% x1 g2 o/ y3 o  I8 ~
var xPos = 0;! @% ^8 D. t- j& E9 G8 v- o8 H6 F
var yPos = 0;
, P( I* g" {& x) b  P/ Tvar xDir = 'right';8 a3 k' h* A# J) o& f% O* {0 g
var yDir = 'down';0 O2 _$ u" a2 c( r/ P
var superballRunning = true;2 A  N& E+ }7 U- J, |' e8 m7 t
var tempBallSpeed;) q9 b/ G3 w! b9 I2 `4 V2 T' o3 u
var currentBallSrc;0 G( c0 L( R' M' x
var newXDir;1 I1 }3 J  v1 a% M$ e
var newYDir;! [/ |2 W0 B/ T: M

' b  ~# i  Q5 ]! }- `9 [% }3 a/ Qfunction initializeBall() {! L5 A1 H2 T: F2 D$ ]3 V" y( B
   if (document.all) {, }; B7 s( y1 K* C( g8 T& j6 M
      xMax = document.body.clientWidth
! e9 [: T) i, T+ p      yMax = document.body.clientHeight. K- m4 I: j4 b; E/ ?" q$ X
      document.all("supertext").style.visibility = "visible";
4 Q1 w# p% x* H6 Q" l      contentWidth=supertext.offsetWidth
8 Y/ E( }% w+ ^      contentHeight=supertext.offsetHeight
  P4 E3 n* J1 P5 j, d: [      }
4 J; Q( b0 j" w/ P$ I   else if (document.layers) {
% W' b+ N, X1 ?  d2 A" d      xMax = window.innerWidth;1 w# ?5 o  J8 c# Y, e
      yMax = window.innerHeight;8 M( T: x2 F) X: y" R
      contentWidth=document.supertext.document.width5 t  w, V; o' F5 _' c
      contentHeight=document.supertext.document.height) S, I- q7 r8 K$ }" x( V
      document.layers["supertext"].visibility = "show";2 l6 \8 I5 `3 t3 u" c
      }
( F, u+ a( Z4 Y9 y+ z1 `   setTimeout('moveBall()',400);
$ r9 Q8 U) T' r  {3 P3 `   if (hidetimer!='')
7 Z9 T" o/ S: e  l   setTimeout("hidetext()",hidetimer)
/ B! |" Y6 h; Y5 s0 h2 H   }
& u) O/ E, M- H0 h) {% H9 @3 v' ?# _
function moveBall() {! R8 A5 l( Z# J7 {  y7 t
   if (superballRunning == true) {
2 z/ Q+ b7 }* Q( O; C/ g      calculatePosition();
. G- ~. `2 b& }8 a; h4 e% _; j      if (document.all) {
* I% i' a9 i' p0 t4 y         document.all("supertext").style.left = xPos + document.body.scrollLeft;# W4 Q# M5 m4 l
         document.all("supertext").style.top = yPos + document.body.scrollTop;( b8 r8 o7 H( F/ s
         }3 D0 A  h& c' I& v7 J
      else if (document.layers) {8 z' e8 Y; _8 @; W# g" T& y: T
         document.layers["supertext"].left = xPos + pageXOffset;
9 a- l! s4 e4 b* }% x" f! X5 S: u         document.layers["supertext"].top = yPos + pageYOffset;
3 Y- g2 t0 q1 V) q2 G& o) }         }
1 ~" e5 H& w3 P      animatetext=setTimeout('moveBall()',20);
+ Y$ Y& s4 m) V( U6 G      }
6 Q! z+ B; z+ R$ Z& H5 b9 f- m   }
1 C0 A$ e* z+ y! ~  p# A# ^% i; y9 O- Q# Q) A" }) a
function calculatePosition() {3 y: f' H8 q  p, ]/ C9 e
   if (xDir == "right") {
% O: s; x7 t. y" x. h      if (xPos > (xMax - contentWidth - BallSpeed)) {& [" ?0 N' f: ~. i6 i$ L
         xDir = "left";
" `4 N' K. l, K+ a+ @         }
1 ~+ c8 i; P$ C, v      }
' j# }: H( e( R3 f0 {9 e% i   else if (xDir == "left") {
0 k* s# f. w! d( e  ?3 G0 b      if (xPos < (0 + BallSpeed)) {) I, M6 O9 W* V+ I2 E) B1 i
         xDir = "right";2 W* l& b1 ?" a9 W
         }3 _3 i  }4 Y8 z; `' _8 E
      }
( T1 I) c# ~7 w1 J& J" b6 @   if (yDir == "down") {
" P  U3 V7 A) z+ w0 W/ f      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ d* }2 Q. J! J9 `' [         yDir = "up";9 D# V0 E- D$ g1 R
         }# Q% n& H6 C- n
      }) q) B5 F" h! E6 w
   else if (yDir == "up") {+ k7 Q& E: w! D7 g7 ^: S
      if (yPos < (0 + BallSpeed)) {
! [; Y, `, w1 s5 N' z         yDir = "down";. t1 G. }1 i$ E6 E+ ?$ ?
         }) ^) L5 o2 v! g8 L. _2 T
      }2 @8 n3 p9 n$ Z/ d$ h' h$ X
   if (xDir == "right") {
* V" V3 {; S) V; f. |4 h' e  X      xPos = xPos + BallSpeed;
/ e, M) o* r, y% h& o( K      }
) l: E. c9 H; t2 i" E   else if (xDir == "left") {
4 A: s) k  ^! ~      xPos = xPos - BallSpeed;
/ [- E2 Z% p0 C* y1 |  Q8 A- g      }
% N2 d" U4 D% f1 w* B  w, i   else {0 j9 i& A1 B9 t* ?  ?' H6 `
      xPos = xPos;7 Q! {0 j/ \! Q1 G! W9 Z. w
      }
# d2 h, L1 x3 S% v: e" |- e4 G   if (yDir == "down") {
4 m4 |# d% [9 b- D( n% T. n! Z      yPos = yPos + BallSpeed;8 A& q  l1 v* _- m
      }
% I3 U) A4 M3 x& |; Y, @2 G  j7 H   else if (yDir == "up") {: M. N* \5 V& m- ~) w4 p) [. s
      yPos = yPos - BallSpeed;: M% O3 s$ C1 \. m  F# W
      }5 K1 u/ |: x5 ^9 m
   else {0 d9 a2 H7 V9 D. ]1 w& T
      yPos = yPos;4 L2 v4 X( s9 J9 F/ d% C
      }. `( i  b3 ~# P9 x7 S6 T( {
   }1 V, l" t# n( V4 n8 ]
# F! e! q/ E- B( f1 T
function hidetext(){! f4 d5 S( S, c: w9 q: F5 m# B' {
if (document.all)  E% G$ ~5 ^6 s6 ?
supertext.style.visibility="hidden"! H, a7 b1 `* Q6 ]
else if (document.layers)" S( P0 w7 M  T
document.supertext.visibility="hide"
5 W4 Z2 j$ z1 D' zclearTimeout(animatetext)  p5 x0 z8 A. D; s' P$ r2 ]
}
7 B9 }2 G' H# G4 j" F- _8 m
+ u" l. X9 s8 S( E8 i# ~( }! M' wif (document.all||document.layers){' J$ P# c7 E5 G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. B# }  O4 E; d/ R4 v( T, ~( S. uwindow.onload = initializeBall;
& d" `3 j- G$ vwindow.onresize = new Function("window.location.reload()");1 h* V; M" j0 ^0 w5 ]
}* r! X( Q5 ?3 v  _2 I
, i! s, ?0 u* ~
</script>

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