返回列表 发帖

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

<style type="text/css">* _3 d, g, U0 n  I4 t# u+ `6 F; L
#supertext {: {1 i2 R' C$ E$ T8 T1 G
position:absolute;, {; _* f7 j6 G! _3 G2 C& r  U3 O
left:0;( e" |* l5 U/ C" }, `  e; L% s
top:0;
$ O" S1 j0 d$ Q* Ovisibility:hide;1 E$ x* L& z* `; o) w  U- c$ l
visibility:hidden;7 u1 c' N% L! r2 W
}
. N4 s* N" b: U9 M</style>
% b$ T) W+ O7 t6 L( w0 W<script language="JavaScript1.2">9 l" r- [; d, |3 k
<!-- 改变下的字体的大小。颜色-->
8 a2 B6 V4 n  [var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
; q& l) T& n" K. c. |$ [var hidetimer='';' \1 b+ C6 ]4 |- f& F' T; \4 S" s
<!-- 改变下的弹跳速度-->3 s" p9 t" L/ {% t& Y5 M4 ^4 K. _- F. _4 Q
var BallSpeed = 20;* Q6 B& }: z8 V+ D: ?( w
var contentWidth;
  o9 s$ r" p3 L- e& k- G) m9 n" Nvar contentHeight;- ]/ o  `+ b& g/ K
var maxBallSpeed = 50;9 e" n$ @' Y% c+ y7 s0 |$ o

2 c. C8 O/ z- q  W  i+ Y( K% Q0 E9 |6 H+ |
var xMax;3 n( s( z' p9 ~& J) G$ d
var yMax;+ {! r0 Q$ ~' v; m* z7 A0 l, J
var xPos = 0;- D8 A6 o. ?; P2 j/ w
var yPos = 0;
) C( J0 ~& m; H5 @8 X( q9 `var xDir = 'right';) J# ~1 g1 i4 n" h, _0 E  B" T
var yDir = 'down';3 k2 o4 {5 `6 [( s1 G# r" W2 f* M
var superballRunning = true;1 {% Q" P  Y1 ?! F
var tempBallSpeed;- j& ]: H/ W  z5 f
var currentBallSrc;2 t) ^) F/ K/ ?0 N' V9 J$ L
var newXDir;" _0 m/ a) N$ y) o2 ?2 _6 a
var newYDir;
+ j% S4 x) o4 i& s2 z6 ~. h
- Y3 |" C9 k4 tfunction initializeBall() {5 ~) f# W* Y+ c$ z9 O: K
   if (document.all) {9 v6 [5 o/ w( P5 k% J9 F  \' D
      xMax = document.body.clientWidth
- D& Z* V0 `. O/ n2 R# `) K8 l      yMax = document.body.clientHeight
8 ?+ V6 H6 F! o      document.all("supertext").style.visibility = "visible";
- g0 N/ G6 a$ `$ W0 Y$ K& Y, }      contentWidth=supertext.offsetWidth1 X) L, ]1 d" A0 b6 r# ]
      contentHeight=supertext.offsetHeight2 }" ~( B0 n2 }7 ]& C- r0 y# U
      }
  D6 f! c& D, N, Y   else if (document.layers) {
$ f, p2 {8 ]; i0 |; g- B- M      xMax = window.innerWidth;
5 W5 t% `' S/ k0 l      yMax = window.innerHeight;
* @  z+ K* G+ i  ~5 x( t      contentWidth=document.supertext.document.width
+ C9 Y" v* |4 h; m8 t! S; r6 r      contentHeight=document.supertext.document.height
3 e% a& U% g4 O, b) P' p6 Y0 u3 D- E      document.layers["supertext"].visibility = "show";
9 v$ U, b5 G' T% H7 n, N0 D      }+ [- I. @5 b# \
   setTimeout('moveBall()',400);! d# y; a% k8 L7 H) a
   if (hidetimer!='')
( b3 {9 I  j6 t5 A   setTimeout("hidetext()",hidetimer)4 |% P- i2 k, ~; B1 J
   }
% S3 k2 u( e; L$ B/ T- s( c1 j6 K1 M, c+ C! J2 \0 Q( G
function moveBall() {- e# \# D* B9 s
   if (superballRunning == true) {
6 l* W3 x: a8 U/ A* `      calculatePosition();
/ O* l6 j/ U9 b! q0 P9 j) I      if (document.all) {
! O* n4 E' W2 U) F! Y' v# d         document.all("supertext").style.left = xPos + document.body.scrollLeft;
  P5 }( K* f4 s+ C         document.all("supertext").style.top = yPos + document.body.scrollTop;: g% @3 t9 ]& U& G
         }7 K. E, _8 V  V5 T2 Z/ e
      else if (document.layers) {5 a' G  y) l* u5 }* U( k( f/ i1 T. ~- I. E
         document.layers["supertext"].left = xPos + pageXOffset;0 _2 A, J* e) K; m6 B5 v# [2 \0 ]& v2 \
         document.layers["supertext"].top = yPos + pageYOffset;
1 o) U0 r' L- I6 R$ t6 \5 Z         }" `% g, U0 [, p% `
      animatetext=setTimeout('moveBall()',20);
* b. m8 l( g; c7 j0 j      }
7 H4 F) Q* b/ \; [3 S2 m: S   }/ l) x! `' k) v$ N& b7 T- A) S
* \9 z4 U: ]" ~
function calculatePosition() {9 Y' h: T" v) M  k1 o' V) S; p% Y) X
   if (xDir == "right") {  ~/ J- f4 D9 H! u0 P3 D- ~
      if (xPos > (xMax - contentWidth - BallSpeed)) {
9 ]- @6 Y8 ^3 ^: t         xDir = "left";! d) L8 D/ B. }
         }
* ?* n! @4 h! P  _      }; H3 n7 T( o& I9 r
   else if (xDir == "left") {$ A% j0 G( \8 a6 `' w
      if (xPos < (0 + BallSpeed)) {( K+ [) n! V: a3 R) S! ?$ _7 o
         xDir = "right";
2 x, d) D8 s; `! m6 V$ T         }
8 r. R6 k' A% W: |  k. ~      }
. e4 r! j1 A8 u   if (yDir == "down") {% n2 @9 U, b6 t/ w$ P2 e# v
      if (yPos > (yMax - contentHeight - BallSpeed)) {6 f, \' y" e6 G* X! N# y
         yDir = "up";) S  ~% n. ~2 {* r& m0 u6 Q
         }# @$ v  q, i; w# ?
      }: _; t+ V0 ]: A9 g3 j0 a
   else if (yDir == "up") {' C9 n. h5 v% I
      if (yPos < (0 + BallSpeed)) {# V: [0 b) Y" x7 D; k7 l% i( d3 U
         yDir = "down";3 K0 Q- ~' X! ^5 G
         }' ?* p2 a3 G; v
      }0 P: A9 @6 t3 n8 L1 E5 l
   if (xDir == "right") {
  ]& t  M/ w" B: O0 Q* E3 Z      xPos = xPos + BallSpeed;
  k/ [9 [( H/ W4 v      }, f1 e4 x$ r& @/ ^1 Q
   else if (xDir == "left") {  l" `% h" c6 q+ S& N
      xPos = xPos - BallSpeed;3 f1 f4 @& g' p$ X9 Q  N
      }
1 F% o* A0 D# c8 x/ f   else {
9 m5 P# g4 I5 u+ i# [% a. m      xPos = xPos;
) _) v# ?8 Y, e5 a/ v      }, f- G% B, \% B: J
   if (yDir == "down") {% g* q( d5 z1 p: Q0 p+ x! Y* T
      yPos = yPos + BallSpeed;5 H  z: [% I" ?
      }# ?1 a4 a9 ?1 z2 V7 ~/ Q6 V0 O
   else if (yDir == "up") {( a; T/ R" a  Q4 y. c( C6 ~
      yPos = yPos - BallSpeed;; h4 Q! k# R' @$ T7 t' y
      }
5 H# N1 @1 d& k, y' K( q" V) a/ }6 n   else {
8 l* z7 ^% ?- O5 l  b' [+ c7 r: q      yPos = yPos;( T+ ?: H- f+ i: T: b! Y) ~4 }" {
      }
; i- P: ^" ~$ M5 Y4 F: I   }+ ^' s  b+ h# w" ^3 g6 \5 l; _1 h8 }- u

6 |. Q  S9 c, ~: H& h- vfunction hidetext(){
# H9 C# P# Q5 @" G% Zif (document.all), W' l" i$ |* v. ?
supertext.style.visibility="hidden"4 h+ V: e2 [% _: o
else if (document.layers)
, q2 n3 _4 B" u( Y; z- i/ D+ d9 odocument.supertext.visibility="hide"
1 F% k0 {/ S* @3 X& b" lclearTimeout(animatetext)
6 k8 w: H8 s& W9 y' U! f+ ]1 P}
0 L: |1 q* U: I: a$ K2 ~6 x9 o9 H! D6 W) t  H) M8 q
if (document.all||document.layers){
6 \4 @' K- a& H' c6 V, N: pdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
' J$ \) \# }; {( r0 \0 G; d: G- x! pwindow.onload = initializeBall;
) n! {/ b& ?! k0 L' @window.onresize = new Function("window.location.reload()");
, x4 R# N# T, _" X; x}1 I% V& w3 z) x+ U0 `0 Q5 v- K
1 a$ h3 K8 c% @0 S
</script>

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