返回列表 发帖

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

<style type="text/css">% e9 ^3 N3 ~& t
#supertext {
- m4 a: R: D7 Wposition:absolute;
" L( V% I! i( M5 D: \: o  _- Z5 }5 Q+ s5 pleft:0;( }/ N$ y1 I7 R" y$ s  [$ E# I. |
top:0;% y3 b% p# X! E. G
visibility:hide;' o) W4 d5 M; P9 }5 @
visibility:hidden;  B8 q& a2 B' h- {! K! y
}
" \7 G  l9 ?. X3 C* G' v</style>
0 |- ]* H' p8 Q' r+ g& e; A<script language="JavaScript1.2">, L5 _9 G( g: L
<!-- 改变下的字体的大小。颜色-->* Y* ^; i, r- Z3 T4 Y
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 B# {; O* _+ lvar hidetimer='';8 _7 u* k/ D' j2 D
<!-- 改变下的弹跳速度-->
2 n( G6 s" Q# \var BallSpeed = 20;0 Z/ E* D0 C; L6 Y7 \% u
var contentWidth;
8 g" q/ D8 n+ Jvar contentHeight;9 i2 D; `" L7 T, }) ^7 E3 r
var maxBallSpeed = 50;6 ^7 s2 P1 T1 j0 g9 O
) n4 x. a3 D- o$ u3 k# @% I  o

1 a% ]0 S  ]2 x% m; q* K# o. [var xMax;5 W" f' F2 y: K% O
var yMax;
  V1 i$ o" T! B, `8 }, xvar xPos = 0;
, M9 f; S  f: Q! @var yPos = 0;
0 S5 p$ o/ j$ \var xDir = 'right';
0 j7 A1 H' U- o# m  r  H! Evar yDir = 'down';
9 H3 Z. _  ?- W9 lvar superballRunning = true;6 |- R$ R  g) r: A" h" c0 v: o6 ^. e
var tempBallSpeed;
6 d6 _, k& Q+ L- s9 l+ E1 G+ T( hvar currentBallSrc;' Q" I" H5 @- j
var newXDir;
4 K7 q* G  d4 bvar newYDir;
. l  N7 [7 r% n% D! w% e6 @" s+ C4 P7 ^
function initializeBall() {- l( C- Y  g: E: t
   if (document.all) {
6 x6 A7 T  T0 r( s      xMax = document.body.clientWidth1 S6 s7 c8 u4 L1 L
      yMax = document.body.clientHeight
) U: Z1 K5 a$ s7 V8 B) a      document.all("supertext").style.visibility = "visible";) q& D9 |% Z& S; f) v5 C4 I. {
      contentWidth=supertext.offsetWidth% Z. d6 j+ a7 n; H" Q
      contentHeight=supertext.offsetHeight
1 s. M. t) q( D) {, W3 d. [, a, `      }
+ U3 M' N* D" N/ g  S. Q   else if (document.layers) {' [' X2 e( F, a: x8 C/ Y( _
      xMax = window.innerWidth;" p' m5 ~: {* W+ l; R7 E& Q
      yMax = window.innerHeight;. L% J- F% I" ~+ m
      contentWidth=document.supertext.document.width
& \6 H1 ?  M" {* m. h      contentHeight=document.supertext.document.height
5 O/ T1 S  S% J2 y      document.layers["supertext"].visibility = "show";
& I$ j2 D9 f: o3 L* t& X      }* d1 v5 z7 g, p
   setTimeout('moveBall()',400);" H9 W' I+ s" w4 m
   if (hidetimer!='')! v/ n  A' X( E/ [' q! p
   setTimeout("hidetext()",hidetimer)1 Q7 S) P, D- C9 j1 y2 ~( J- _! g: Y
   }
1 }' T/ |1 D4 v( u
2 [, o5 y: D, W; ]$ T) Rfunction moveBall() {# R8 _! X- z9 }; o$ ?: W) z
   if (superballRunning == true) {
3 w7 U4 B1 L1 j( A0 [      calculatePosition();. v6 ]$ p- D) Q9 v4 l# `
      if (document.all) {
7 r: z; W* E- W1 T$ ^8 z2 U         document.all("supertext").style.left = xPos + document.body.scrollLeft;6 V' R3 F1 z3 D+ u3 C# `0 C) [- I
         document.all("supertext").style.top = yPos + document.body.scrollTop;$ I' m5 n- s' D1 h( ]# V
         }
0 i0 ]4 e0 K+ K9 z7 V      else if (document.layers) {
+ t  |& k& A* D& s, G         document.layers["supertext"].left = xPos + pageXOffset;
, \; g0 t6 _. p- a  S* t( {         document.layers["supertext"].top = yPos + pageYOffset;
* c! S4 m- v0 `3 R/ p1 d) T) |$ u         }
% Q8 }: r) H2 ?2 i! S7 a      animatetext=setTimeout('moveBall()',20);
8 ~, H/ z5 d# A/ `: s      }
& O$ x) C6 z0 A6 }# F   }
0 b. K1 U6 u! h5 b, u4 z8 x& E8 G) M/ U
function calculatePosition() {
- C' J1 K5 N! G) l& L/ s& P- X   if (xDir == "right") {
& J& u/ _2 C- n0 t# {: ~4 V. q0 A( u      if (xPos > (xMax - contentWidth - BallSpeed)) {$ m. W/ j4 c4 [9 q& y* u
         xDir = "left";
4 u! b) o( x4 W         }
- q+ v; Q& ^% D7 {3 @/ U      }. f9 w( R! ]2 \9 g3 E  G
   else if (xDir == "left") {! |1 H! h+ g1 W- J9 F
      if (xPos < (0 + BallSpeed)) {
) d  ?# l1 I: Z9 z- t3 y         xDir = "right";
! V8 ~) T* x: B9 M         }
/ A8 ]+ c1 d# x, H2 r: ~      }5 Y1 H' z, D) f8 p
   if (yDir == "down") {
& }; N4 c( J  B1 `. w. q% a      if (yPos > (yMax - contentHeight - BallSpeed)) {0 w& N- E$ Z; U+ T- \6 I
         yDir = "up";* _! b4 @0 r0 o( s9 W
         }
$ ]" J5 {' C. q" Q      }
  r8 e, a( b! M; z   else if (yDir == "up") {& I: S5 {) j5 g
      if (yPos < (0 + BallSpeed)) {8 t8 }/ I) s( S  U: P2 B$ p: H
         yDir = "down";
  x/ }$ ?' c2 w5 _         }
1 O% n0 N' {/ M$ F! k4 O  _      }
( |6 }% a/ w  S/ P) K# j   if (xDir == "right") {# K8 G+ V: U* q/ b! [& N
      xPos = xPos + BallSpeed;
$ f( w& r: b; J$ n' x& n8 {8 z% N      }  Z! `$ Y8 a8 j5 O6 {
   else if (xDir == "left") {
2 b3 Z) z$ D; r4 T. n' T; t, z      xPos = xPos - BallSpeed;$ j) Q! |- ]; N; G
      }
9 r& r3 Q2 H3 [   else {0 ]4 N3 ]! T. B; r5 p. Z, t
      xPos = xPos;! Q/ f( @2 u5 u! U6 B' U# p
      }" c4 E4 D9 f1 x8 e4 Y/ A9 G. H3 A
   if (yDir == "down") {9 M. p. s7 n2 @
      yPos = yPos + BallSpeed;
# [2 {. R; S  @: G/ @      }
& K( g, U& x; w' Y4 h/ I. m# p   else if (yDir == "up") {
) A  ^& I) z7 l3 n" w. l" [5 K* v      yPos = yPos - BallSpeed;; x& r+ B1 b, x. A9 {) G) Q5 d! q
      }
( X$ `- P" Q3 M7 x   else {
) {2 t; Z6 u3 ^' I      yPos = yPos;7 s9 u3 a- C, U7 p
      }4 N; q0 u( f( f0 ^( R$ k4 W$ g
   }
3 j9 f- o+ ~7 N6 t
/ G8 _% l2 c* Q# L% Zfunction hidetext(){4 G/ @: R# x7 ^( X& Q5 b
if (document.all)) X4 v3 ?+ H$ z7 t* i% K
supertext.style.visibility="hidden"4 a- `4 _) Q) a6 M8 D4 a/ H
else if (document.layers)
3 U: q. T( x7 M& Y; m" c; gdocument.supertext.visibility="hide"
0 L' o3 f5 K2 g! x% x" k. |clearTimeout(animatetext)3 V1 S% r$ m# {/ Z. m! L( h; V! I. m
}  T# L8 R. k" L+ i1 R4 G% G6 t

1 H/ U# m) j; {  kif (document.all||document.layers){9 m: O" Q/ G8 w. n
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 o$ x. I" M; e6 q$ o# S% h3 {% K  y
window.onload = initializeBall;
6 m$ p3 l3 h9 T' c4 gwindow.onresize = new Function("window.location.reload()");; K! i9 U% v% Z- d8 g7 z) Y
}* f( U( W! H6 y

6 C. @6 y3 G% z1 e# E</script>

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