返回列表 发帖

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

<style type="text/css">
" m$ n' L% d% O+ O. s8 I6 P4 G, D#supertext {% v! n) h% L+ L, c9 }8 ?
position:absolute;
( z. C: V) ]' u1 V% l; Nleft:0;1 ?/ |# v* R) K$ j6 G
top:0;+ z* w3 N5 i" n: c, W$ N
visibility:hide;
% P% a/ H2 N. R2 |! Q& T/ {visibility:hidden;1 \4 Y2 u% Q* X/ S  M& u  b7 d7 a
}
3 v9 E  e8 J. h! v* p</style>
& L: Z: f% p. }; h<script language="JavaScript1.2">
1 J6 B5 Z, S6 h$ b1 B6 _0 [5 F<!-- 改变下的字体的大小。颜色-->6 b) x; |4 E9 U1 I% v
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': P7 I2 B3 ?, Q: Y) c" F+ t$ x
var hidetimer='';
2 b: L# m6 `4 S! h  p<!-- 改变下的弹跳速度-->
) p5 x9 [. T8 i: kvar BallSpeed = 20;: M& g: u; t( V) D8 o
var contentWidth;' H) W( `+ c- r3 t6 c
var contentHeight;; ~/ n' g% F# l" W
var maxBallSpeed = 50;9 [3 T8 F2 K2 J4 U& t

( ?9 R: S- A" c/ ^( G. s2 r" S4 ?/ ~
( k' R2 W: p. w. Svar xMax;9 {8 E$ S% t/ I  m
var yMax;+ J1 x5 N  l, `4 Z2 K( M
var xPos = 0;# O  Q" e, `6 I" q
var yPos = 0;
# h1 b2 a4 Z( W9 n. x" Rvar xDir = 'right';0 W0 U* h9 O% m
var yDir = 'down';# @4 |+ h& e, j* e; ]
var superballRunning = true;
6 w& j$ ~1 k5 q4 b0 b6 V/ H5 lvar tempBallSpeed;3 I% a" A; ]) {) Y( A
var currentBallSrc;
7 A; f2 \% O3 v; N/ Vvar newXDir;/ Z- F* _, q. Z5 Z
var newYDir;+ a1 z0 F  W+ p9 O, B1 Q- r  X' \& F
4 ~( ~+ w% \4 o
function initializeBall() {5 a8 r, y5 D. x
   if (document.all) {6 T" ~3 g0 Y/ u/ ?6 U# d$ M6 c6 }
      xMax = document.body.clientWidth; [" e9 D  I1 [' w
      yMax = document.body.clientHeight
5 Y+ r+ Q$ h) Q4 f      document.all("supertext").style.visibility = "visible";
0 L. Y1 Z2 t$ @, @& ^, d      contentWidth=supertext.offsetWidth
9 Q1 g$ b9 U% \$ k& m      contentHeight=supertext.offsetHeight
: F: K0 `- o& z8 b# j1 n8 {      }/ P9 K3 t1 \* C& S& e' K; B+ W# J
   else if (document.layers) {
. J- w+ {2 b, v: m      xMax = window.innerWidth;
( e, H9 L/ M* M  t1 }5 z- E2 p      yMax = window.innerHeight;
9 S" a- S  c$ S7 D8 M8 B" N      contentWidth=document.supertext.document.width
& |; Q. ^9 A1 U9 y      contentHeight=document.supertext.document.height1 B$ e7 |2 \! G* G, I) ~+ h. r- h
      document.layers["supertext"].visibility = "show";
' W% E1 H! j8 i# S3 P9 ~% q      }
9 P5 v" I/ W$ Q; V" e   setTimeout('moveBall()',400);
! V! F6 b% f1 Y7 t& V   if (hidetimer!='')
- W5 E/ Z4 J% O8 ?) ^   setTimeout("hidetext()",hidetimer)/ V, ?; x3 c' {: a4 S" j0 a
   }  ?% j: g  C3 t- B( e$ J8 m
* A) \+ v) Q( U- w( i1 O1 Q0 n7 z6 L+ `
function moveBall() {) c& y$ `8 q( m' @+ ?$ S0 |( e
   if (superballRunning == true) {
* \% ^0 I2 ^  u& s/ i) S, ~3 _      calculatePosition();
  T3 d% D. C; s, S- |      if (document.all) {
# X# h; T# ~! `- [8 n: _         document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 \  d( b. m, C) s; \  T- k         document.all("supertext").style.top = yPos + document.body.scrollTop;
# s9 p8 m) }! ^* v         }
. e$ y: g1 v  @      else if (document.layers) {
5 c+ t; l6 P( T! I6 z5 _         document.layers["supertext"].left = xPos + pageXOffset;/ W6 g3 N+ F5 t# c" q$ Z* Q9 p2 F
         document.layers["supertext"].top = yPos + pageYOffset;
7 O# ?9 O# x0 o% `         }
& H$ @5 A9 E3 ?# Z      animatetext=setTimeout('moveBall()',20);0 L& m, J: W3 `7 M% `. p
      }6 a4 F8 Z1 c' r4 [$ V) X  _
   }
( N3 x6 g& f& ?4 K9 X" L/ T: E& e
function calculatePosition() {6 V3 F# ]. K( A
   if (xDir == "right") {
! M4 f5 ^) a4 z      if (xPos > (xMax - contentWidth - BallSpeed)) {* W2 z- J5 k# F0 g: }% o" E
         xDir = "left";6 s" [+ c1 E: q( F) Z1 s) s! b' K
         }
3 q1 H6 K  B$ R: B2 `' z+ H      }1 O2 g% g) y7 ^: C
   else if (xDir == "left") {
5 w0 _8 I' M9 P) K+ r( t, x      if (xPos < (0 + BallSpeed)) {
6 O0 X1 ?8 O4 \* M1 n         xDir = "right";* _; c+ q9 j! H( h  r: p
         }
8 R1 F9 A, o% ~      }
' P  M  a" @7 y+ c! C   if (yDir == "down") {% O- R1 |, W; m, e# c
      if (yPos > (yMax - contentHeight - BallSpeed)) {$ C0 d# s" Q/ N0 A9 c
         yDir = "up";; g+ B2 z( J2 c9 f4 F
         }0 d5 g* e  Q; J* b
      }3 U& \* c' h5 K: W3 q1 x
   else if (yDir == "up") {
6 x. v' J5 V- v' Q; c- G' u      if (yPos < (0 + BallSpeed)) {
, ]7 I  p; G0 S         yDir = "down";
: u' B. n0 M' K) |7 w         }/ E* t1 `: C8 m/ _, ~
      }
$ {7 I, a6 [# q/ A, p% Z   if (xDir == "right") {5 m" f+ S# ?1 a  U3 {* H* }
      xPos = xPos + BallSpeed;
* o  ^: ?$ d0 _) z4 K; l$ @- a" `      }
9 d; s- T( g( V7 `- }( J8 X   else if (xDir == "left") {
, D" t' e( J4 G      xPos = xPos - BallSpeed;
- d) X! O; S9 E, C' O      }, g0 X& A" l/ X$ p. P
   else {
( ^- Q5 y5 N9 J) V, }- T, o      xPos = xPos;
1 h. e% i2 |+ p0 d( K% m      }
4 f& r  q  Y  D   if (yDir == "down") {/ K& N* R. r8 y  w6 x; Q
      yPos = yPos + BallSpeed;
1 O9 t1 |% j1 G      }
  s8 t; s  V5 e* v) X6 A% Z   else if (yDir == "up") {
! d/ |$ }0 T( x      yPos = yPos - BallSpeed;! X) t* Q9 w, i' I2 ~0 n1 h
      }
  Y- x, r: [% x9 z   else {
6 O, `& R5 a8 b- l      yPos = yPos;
; ^+ i! L! z1 Y! f6 u) K      }* C* _2 N8 A& t1 @" d
   }
( d$ c/ Y5 r% m/ E+ s/ d' W2 _; h; R8 Y' u7 S. i- _
function hidetext(){( |$ D# n7 E$ B# ?) S
if (document.all)
7 z& Q# Z6 x# C$ Ksupertext.style.visibility="hidden"
& N) \% e+ w5 `" E0 q* N3 welse if (document.layers)
! z% ^8 [' W' E5 rdocument.supertext.visibility="hide"$ t* C7 |2 W" @3 D
clearTimeout(animatetext)  v& S5 K) ?5 l+ R! d
}
, {1 @7 c6 w% p! ~! B' d3 \. g- @
' E5 O- M* T  l. Z+ m! z% }) zif (document.all||document.layers){# N% c; s! k: Z% H! q
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 N9 f5 k" Y2 G; F# Fwindow.onload = initializeBall;( U: {2 N1 D9 h! Q9 b. s
window.onresize = new Function("window.location.reload()");
# n1 V1 z" z' k6 R7 L7 U/ m4 t}
. m) x2 @/ ?9 B0 O, W  Y- r% Z" U  y
</script>

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