返回列表 发帖

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

<style type="text/css">
: K0 n5 S' m5 J5 r# n1 S3 f) R: A4 h#supertext {
! B# j1 |, z* ~9 z$ `$ }; Eposition:absolute;
7 l" C' M0 o6 H' Nleft:0;8 z% D9 [5 k2 T3 b
top:0;/ L9 X: j6 B5 P- M& e' p; U. q
visibility:hide;  l" X5 ~3 w, r* n+ k- D3 l
visibility:hidden;
5 z1 A% F  A$ S: M}! Y, R8 J# x+ \) s" e0 X. e$ U" Z2 @
</style>
2 ]* {3 G0 X" a& Y# K<script language="JavaScript1.2">
& y0 o+ `9 C# z, F+ L<!-- 改变下的字体的大小。颜色-->
. g) a/ V+ D9 {var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') f3 Z8 ]8 X" B% [% h* X1 a
var hidetimer='';
" u' \& a4 F3 q<!-- 改变下的弹跳速度-->
. R0 D: p" B" k3 Z' V$ `. lvar BallSpeed = 20;
2 _8 {& s  h0 f* dvar contentWidth;  d- g8 e3 Y. a; h$ X
var contentHeight;
6 L6 T' r6 p3 ^; Mvar maxBallSpeed = 50;' h/ Y! I+ J1 ]+ g  B- G; l; I
, s3 j- E4 t7 Q, ^
) P( F! G) T( [+ W
var xMax;
& E$ B! c0 }6 |& H  z' Vvar yMax;" y' {  _8 |# ~/ H
var xPos = 0;* Y& U& }5 l0 z! v
var yPos = 0;
3 e( ~! I! e7 {' r$ [- Bvar xDir = 'right';8 Z. C4 G5 G' y( P) ^% W
var yDir = 'down';* \6 W4 W1 @. r' Y
var superballRunning = true;
2 W. V7 g( ^2 k) A* dvar tempBallSpeed;
1 A% M9 D- {7 q* N5 Ivar currentBallSrc;* L% e# L/ K) n- A$ P$ d9 J
var newXDir;3 J  p. j; f  v- }0 Y
var newYDir;
9 N% u6 I  E- i  ~- G5 B8 D
6 o; P% a: I0 w9 u( E" y) x6 U: w$ y$ Gfunction initializeBall() {! F* A  C7 Q2 A8 ^) U/ c  o: z
   if (document.all) {1 a) ]' s5 g% ~9 E: d
      xMax = document.body.clientWidth
( Y/ h$ I. D! X5 ~3 ^+ W- L      yMax = document.body.clientHeight( A. F. D. [' x
      document.all("supertext").style.visibility = "visible";
: o* k& i2 E1 W7 I# @      contentWidth=supertext.offsetWidth1 X' g2 _; e  n
      contentHeight=supertext.offsetHeight6 j* ^7 V4 ?1 i' S4 K
      }0 K7 T$ E1 e1 I3 r7 _
   else if (document.layers) {
6 k4 R1 o2 w. ]0 ]' j      xMax = window.innerWidth;( V3 a: u# B4 c
      yMax = window.innerHeight;6 y/ g. D$ p% e( k
      contentWidth=document.supertext.document.width
- z% [$ s. s! q6 f: q* D$ W0 ~      contentHeight=document.supertext.document.height8 P$ E" ~% ?5 k0 C4 E
      document.layers["supertext"].visibility = "show";. O0 d6 }7 i  ~6 ]
      }
* `% A/ l# o$ S# P7 a   setTimeout('moveBall()',400);7 D# P* J6 b* h7 v
   if (hidetimer!='')
- A  w* Z* O& A9 q/ X1 c* o   setTimeout("hidetext()",hidetimer)
/ d- M7 V. f( l: H   }. l9 k) _: {2 I5 ~" G, t

; c! Y4 D! [8 ?0 ?) q4 _& ]% S9 ?function moveBall() {
, B) b# \& E3 I3 `$ G. k   if (superballRunning == true) {
' ^, z/ i; r0 c, e# I      calculatePosition();
8 e  k' Y& d4 }, k1 G1 L& p$ u      if (document.all) {
4 F" S. g  Z6 x8 S3 v* D( t         document.all("supertext").style.left = xPos + document.body.scrollLeft;* Y' N1 d% G8 x+ C
         document.all("supertext").style.top = yPos + document.body.scrollTop;
6 }" R7 N; Q5 e         }1 S' x8 s  B) V1 s; C7 p
      else if (document.layers) {: v5 r& W3 E( e$ W' u0 Z6 Y' U
         document.layers["supertext"].left = xPos + pageXOffset;
/ T, u/ B1 N& b# n6 H" V         document.layers["supertext"].top = yPos + pageYOffset;
  k5 S% D( l! n         }" r' l, A1 F# O. _2 v$ o& L0 s
      animatetext=setTimeout('moveBall()',20);
: d) D( e" E! m/ [2 T      }: [" M: R7 {; r' I
   }
$ F/ W9 O: s* X. B# Z& e! ~: {& c4 G! F+ h+ l/ f$ {
function calculatePosition() {" B: Z% |8 ^/ K7 ~. ?
   if (xDir == "right") {
% h2 c6 [" J! c) @( G3 o      if (xPos > (xMax - contentWidth - BallSpeed)) {+ \- H/ j  g2 ^2 U$ U
         xDir = "left";$ u/ _7 N' m+ r' M# I
         }) D2 f- X+ M* a6 a# }( j1 N2 v/ A
      }5 D$ j' `, a! t7 X) {) d  l
   else if (xDir == "left") {
+ K2 X' u: f# v5 d' ~      if (xPos < (0 + BallSpeed)) {5 m$ w% a0 y9 _; f* q& ?" l5 _
         xDir = "right";
/ `$ y* c5 L& I* L, a2 w( }# r5 Y4 t+ D         }
$ I- d3 R6 S9 Q3 h5 U/ ]      }; P+ p% C" V& c
   if (yDir == "down") {
! m3 k5 P2 t) d) D      if (yPos > (yMax - contentHeight - BallSpeed)) {6 W8 x, {: f; z
         yDir = "up";
! l5 A+ A- s( w3 y         }
9 v. ^* u( p, C: v& L      }
( ]5 u6 n9 \* m' M( o   else if (yDir == "up") {
6 ~/ K' u: q% q. @& }) V      if (yPos < (0 + BallSpeed)) {: Q8 e- v4 y: t& r! {
         yDir = "down";9 Q% D7 s2 \3 o8 b5 |: u( q9 ^
         }
2 c- m( c# e: E0 n) F. u      }" Q5 T3 O0 d8 f0 K) r
   if (xDir == "right") {) u2 R; f2 T. h5 ?$ b) T" R
      xPos = xPos + BallSpeed;0 L- S" S# p' U
      }$ k# {" `) \# T/ q
   else if (xDir == "left") {
- k: l+ C# P, q      xPos = xPos - BallSpeed;, |# S! r2 f! }- i9 ~/ A
      }( ?- e+ |$ \' M
   else {9 U# o" y  w; I6 i$ e8 v
      xPos = xPos;
. I) x  Y, i8 ~  X9 I0 a9 {$ K      }
& A& j6 f! d- R% h   if (yDir == "down") {  k5 d# x, N# |2 n/ S# Z  N
      yPos = yPos + BallSpeed;
* F. |# A6 X5 I! [0 i" o      }
/ Z/ n4 E" I* R- [, g   else if (yDir == "up") {+ @" g# \7 d, u# x1 T- z
      yPos = yPos - BallSpeed;
' S1 ?3 r+ L" l6 w7 z1 F      }
: T9 u) U) v' _% k   else {; O# |- ^  A% |: D
      yPos = yPos;
/ `! ]: a9 f$ |1 x$ d      }
* O! P7 _1 z1 ]: e+ |   }; c) g: J* U/ |' N; n' n& l

8 @( G, w8 G# c9 r$ o# K4 z( Dfunction hidetext(){
5 t# r. x6 s; }  n8 a5 [if (document.all)
+ q& e) i' b4 O3 P' P2 u+ fsupertext.style.visibility="hidden"
3 \0 n/ F- Q& b5 oelse if (document.layers)
0 w( I/ `5 p5 d0 u/ V$ W0 gdocument.supertext.visibility="hide"
3 o* ^" y9 ]1 f, x- AclearTimeout(animatetext)0 G# E% k1 [8 {# B6 m7 P
}" [% L- H4 n! L9 \
+ w6 `& c1 b) \$ x
if (document.all||document.layers){! A' @; a) k- n* u
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 k# @4 {( Y1 {8 f+ A& o3 s5 ~5 a6 mwindow.onload = initializeBall;* |: _: [3 q( P4 K9 |; V
window.onresize = new Function("window.location.reload()");
* K4 T  T7 d; z3 }# L: U5 S8 m}
8 J( g" D: K/ o( U" e$ H6 d& f* p. H3 w# H/ i% S& a7 x4 `, F
</script>

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