返回列表 发帖

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

<style type="text/css">8 U' Z. T2 g/ _0 i* `/ [: S
#supertext {# E/ q6 `# W3 _/ l4 G3 d
position:absolute;
4 T0 _; @7 J- S, xleft:0;) ^8 u2 V. ?' I' l% P. u
top:0;" h' {' f; r- R2 \1 ?8 |
visibility:hide;1 h, y6 b* v! n! }  @; C# q7 g
visibility:hidden;
7 h: O# H) V3 S9 D. `}
' G" ]* |0 ~: W  D  _</style>! d: T* F# ~4 e+ h2 H6 O' Y
<script language="JavaScript1.2">7 @6 ]% H# b  b1 M
<!-- 改变下的字体的大小。颜色-->3 ]4 j$ _4 M; T" c/ L% T+ ?1 s
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 b6 k# P4 h5 j  `$ U  H1 H, Y
var hidetimer='';0 B; U- m1 x6 }! w5 ^; G  r. \
<!-- 改变下的弹跳速度-->
. m7 @. L/ K7 S# L" Xvar BallSpeed = 20;
& b2 `' j7 v* X5 K8 Wvar contentWidth;
: g- L8 _# p4 yvar contentHeight;
& [/ D+ D+ s8 }! m" y( @var maxBallSpeed = 50;
0 m* T+ n4 X& u# |3 i
) W( G+ D9 n9 y3 S6 c
' @- k- I  `% n6 r1 Evar xMax;
1 V3 ?8 J$ Z% lvar yMax;. q6 ?, v/ @# S' l5 Y
var xPos = 0;2 V4 _3 L1 T/ X$ {' L5 g. f% `
var yPos = 0;
/ c- {& X( u9 k1 H/ ~var xDir = 'right';, A/ @$ x& ?$ n/ N! [1 B4 U6 d
var yDir = 'down';6 f5 a% I2 D' \" H& a
var superballRunning = true;
, F- `# q6 f. x: w4 D% ]% A) z/ dvar tempBallSpeed;9 j2 d# t$ O! \7 B; {# e- n7 n
var currentBallSrc;: b, T. q! ]: k2 }, u: a+ n
var newXDir;
* l" a1 X! @1 f0 B5 Pvar newYDir;, ^# u. n0 R' b5 O" P. M
) K8 G) a0 c6 D7 J8 f- D7 R, [: I
function initializeBall() {, D" g- v0 {% z$ `6 ?
   if (document.all) {/ A/ V2 {& Y3 k/ {, z( g
      xMax = document.body.clientWidth
/ n, A/ ?% \) @6 b4 Q      yMax = document.body.clientHeight) M$ y) X& n. K9 `, |/ v
      document.all("supertext").style.visibility = "visible";1 @+ b; C+ E& b( I; X
      contentWidth=supertext.offsetWidth
+ Z- E/ u: e, b4 o) U2 t4 R' z      contentHeight=supertext.offsetHeight/ I- T  K& }1 x, K, ]; O; ~
      }
$ h' j: d8 Y+ Q) n( {   else if (document.layers) {
' k- W. W5 {4 K* Z4 w4 W      xMax = window.innerWidth;( o0 f) E) v% R9 a
      yMax = window.innerHeight;
) F1 t  q4 u; [( f% O2 G, w      contentWidth=document.supertext.document.width8 \- F6 C; W6 O: F" [+ O# G
      contentHeight=document.supertext.document.height
1 \4 f$ D7 e6 E$ G5 o" i      document.layers["supertext"].visibility = "show";
0 W0 _# t$ g( `- B7 T. j$ s      }$ N8 t/ B2 ]+ S& l& C, N5 \
   setTimeout('moveBall()',400);3 b  Z7 M5 c6 i6 X2 V
   if (hidetimer!='')
. U: l6 e' K" ~  n   setTimeout("hidetext()",hidetimer)
3 Z- K2 X9 d! ~- ?+ `   }
/ @$ |# Y$ B! W' o" q$ ?2 ~: ^/ U
7 L4 L2 y7 v; s9 _/ rfunction moveBall() {
9 f) s: F+ c) [, G$ C& ]   if (superballRunning == true) {- I: `6 k5 G8 q' s% g/ S2 A  k
      calculatePosition();
2 W: {) }. k) \% F      if (document.all) {: F- X0 ]3 j6 T# G
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
- U/ U; z2 D7 m7 j% f6 c; s         document.all("supertext").style.top = yPos + document.body.scrollTop;
8 O1 ~# P; l! u4 I& I, ]+ R         }
& o% ]2 l) b4 o+ [5 V# m      else if (document.layers) {* R  V  t: G5 |! v3 V7 s7 Z% K
         document.layers["supertext"].left = xPos + pageXOffset;
' g" Q: M" U& Z. Q+ p, @9 N; v         document.layers["supertext"].top = yPos + pageYOffset;3 ~3 u( M" x: q7 U
         }* t! }- V4 S2 r9 T) H
      animatetext=setTimeout('moveBall()',20);
1 U/ E9 ]$ \3 Y& c      }# _! R2 {) x1 M6 ~; y, Q; {
   }8 A6 `' \2 \- X

' |5 W* ^6 D- }/ R  tfunction calculatePosition() {
" @1 _6 Q7 o6 p- a/ r; T3 g$ a   if (xDir == "right") {0 ~* R. s; G0 T3 U6 P% a+ W7 b
      if (xPos > (xMax - contentWidth - BallSpeed)) {
, y* H, g6 W! z( t1 c! p' B         xDir = "left";$ F* `3 ^% r- u
         }3 S+ s8 `* p1 z- ]6 V" n. t0 A
      }
8 ?! j2 r: Y# p( _* D   else if (xDir == "left") {% }9 N, N0 |9 a9 c7 \1 I
      if (xPos < (0 + BallSpeed)) {, a' |3 k' ^7 E% [) l
         xDir = "right";
5 `; y9 C0 l1 P/ I* ^         }
% q" |8 M3 X  f7 a* D; \% A      }2 i8 F7 G: {+ w4 l6 Y4 S1 c0 G2 _
   if (yDir == "down") {8 Y4 |/ {5 q, g) H
      if (yPos > (yMax - contentHeight - BallSpeed)) {. D! A* a, y1 u1 f1 M8 A: U  w
         yDir = "up";  d* X1 O" q; k( {* @
         }( P  q  V1 l9 ~8 U5 }1 _
      }
. U. g& y+ y$ d: h; J: H! {; ~) F   else if (yDir == "up") {
. d2 U9 m! s, `( A, B      if (yPos < (0 + BallSpeed)) {
! @1 P$ v/ F2 ?! z; j) q( }         yDir = "down";, m0 H/ @& p! e9 F/ P2 w
         }
: B/ G) T  t2 S! T" Y      }, y8 S2 X4 `- y* c6 B
   if (xDir == "right") {* a2 ~$ l' Q8 J/ g3 M8 }1 R
      xPos = xPos + BallSpeed;
, ^9 I& |8 ~0 d% @8 x      }+ L. E: a0 A5 R' }
   else if (xDir == "left") {
1 _$ p8 s6 c2 s  N      xPos = xPos - BallSpeed;" Y7 N1 l& ~2 E
      }
# l7 q- [( ?& }! B; _. r   else {
8 W2 p8 a. H, {0 |5 P( s      xPos = xPos;
) s; w) L" U2 ^# q      }
  ~0 H7 `& J) Q6 ?% J8 D   if (yDir == "down") {
) Q8 X) v5 u9 ]4 B) T- S9 F      yPos = yPos + BallSpeed;
$ E$ P8 p5 E* s) x) L      }6 _+ M$ V; q' t
   else if (yDir == "up") {; X  g( c6 Q  j0 J3 j
      yPos = yPos - BallSpeed;
6 g, B) ^% A2 H5 W1 u/ Q( ]      }
2 t( x9 n* [3 ~2 l   else {; h* l8 a- {$ f9 T, Q& b
      yPos = yPos;* U5 @: O& x. y* @! E- `7 v
      }8 {. u# q# ~* A( F' ]2 n) w2 q# d
   }( J3 \$ O3 i  K& x; ^
& W- C* [) g: z& w  X: ~7 n* S! ?% X
function hidetext(){5 y5 j; _4 R2 F$ A
if (document.all)  A  d6 m- B* h& o8 W
supertext.style.visibility="hidden"7 t) {/ Z. n2 F7 o% L  f$ s) V
else if (document.layers). T: O0 W# ^; R- g( l* U+ \7 ~
document.supertext.visibility="hide"
8 s7 S8 \% I5 r; B$ M* E2 g3 T2 z0 NclearTimeout(animatetext)
; V9 y" Z5 Y8 G+ @1 K2 P}
' f3 M: [! U8 s& U2 E9 H! {% \2 D  s' u& u' T
if (document.all||document.layers){% q' f# X3 ?3 }3 `9 ?
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 [" g3 t( X2 |# F0 Ewindow.onload = initializeBall;
0 N' i4 ~' C& U* cwindow.onresize = new Function("window.location.reload()");
; w4 m0 o$ R0 N) [  p6 _+ a}
- J7 b2 C; `. z- V3 W, G8 f! ^& v
" C; ~* a; M; L& F. C. U! }0 t</script>

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