返回列表 发帖

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

<style type="text/css">
0 f  g" F! s# A#supertext {+ R5 g+ z, z& t% u8 n
position:absolute;
0 f5 ?% q9 V0 a9 Hleft:0;6 K+ }; g* b: z! S) L
top:0;" `/ g( [1 h+ C0 }* I. j6 Q6 ^& A
visibility:hide;
" F3 f& w' R1 Y) a8 z9 a+ Cvisibility:hidden;
0 T6 c' L% l% c/ ^}; n$ X5 s: l$ i( Z( [8 ~
</style>
( T: h0 Y) z2 o$ C" [. a& {<script language="JavaScript1.2">6 ~, ^* v8 G4 Q. m6 s
<!-- 改变下的字体的大小。颜色-->
' m2 v- T$ Q% F, j/ P' i; }) S0 mvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. q8 |- |- K+ [; ]6 v
var hidetimer='';5 Z8 q0 F' E4 }% s. j' [1 K8 g
<!-- 改变下的弹跳速度-->
0 Q1 ^( L: D) P9 {! svar BallSpeed = 20;
% O' Y9 z! [: b) y' t8 rvar contentWidth;
3 m! J: I# i1 f' {0 U9 i/ zvar contentHeight;
$ n- c1 M0 [: r- [" v9 Nvar maxBallSpeed = 50;" i; U3 L6 V+ d% x
4 b6 r9 k& _, O# V

' ~2 ^. e& ]1 svar xMax;
# z: e" v/ e' [2 ?var yMax;
* `+ h% |. s+ c, D& fvar xPos = 0;
0 I, @( A* o0 n" n# o" ivar yPos = 0;
1 n9 E/ T2 |! qvar xDir = 'right';# [  e4 ?4 V( u) v4 R6 R% h; X
var yDir = 'down';: `2 z& N6 \! [1 q
var superballRunning = true;
8 N% a# p4 l$ F5 m/ F  e6 Yvar tempBallSpeed;
9 {1 h0 E  U- f/ g( B. |var currentBallSrc;
" B7 N$ Y& g. ]% pvar newXDir;
) e) e) O  j5 G' `* \  fvar newYDir;
' Y0 h1 y! X% v+ o0 y9 Q" l, j( n& g  c1 l& o
function initializeBall() {
" Y3 R1 c( [/ K   if (document.all) {7 a! h1 t* |9 w1 t
      xMax = document.body.clientWidth
$ ?5 h8 z% B2 b% b9 G      yMax = document.body.clientHeight6 {* ]. v9 H: m: m& ]: D
      document.all("supertext").style.visibility = "visible";
' Z6 r, Q5 ]3 B1 v- k1 H      contentWidth=supertext.offsetWidth# q( ^0 I) ?+ h' Y) P
      contentHeight=supertext.offsetHeight
3 D/ I+ A( o3 M      }1 I8 q' N) s4 l) u& m7 j5 s2 p
   else if (document.layers) {
0 ?9 W9 o: P8 `: X6 A      xMax = window.innerWidth;
) V  e& z/ J0 N, [- H) n9 K0 G      yMax = window.innerHeight;. n1 W& M2 A6 E1 N6 D* O
      contentWidth=document.supertext.document.width
; L* X) `9 P* m7 M. E* e      contentHeight=document.supertext.document.height
3 I1 Y3 f5 m6 Y+ r$ \9 d      document.layers["supertext"].visibility = "show";0 T& N3 o* j. p  b: e3 w3 ~
      }
9 Z0 _0 ^% T& n. u1 [   setTimeout('moveBall()',400);
' E4 t- {2 ]% s1 r/ j% ~   if (hidetimer!=''); |$ Q* ?/ [2 ^* m0 y5 O; H
   setTimeout("hidetext()",hidetimer)
- U4 L2 s+ u4 w/ r; X! n   }8 V( C- ^* O6 ?9 w$ R! |

# J2 i& X0 C# r* H1 Q3 \- Tfunction moveBall() {4 j$ x% \1 e5 @3 u3 y
   if (superballRunning == true) {: \* [$ f. g1 O
      calculatePosition();
5 U2 P1 h/ I9 i      if (document.all) {
. c; o0 Z2 ?  Q* J         document.all("supertext").style.left = xPos + document.body.scrollLeft;& I  K8 [' x1 F1 O& L* W
         document.all("supertext").style.top = yPos + document.body.scrollTop;- {6 I: ^7 R1 ^2 G
         }
9 G- \; ]; P' Q      else if (document.layers) {
9 H2 o% e2 L1 h6 G+ b         document.layers["supertext"].left = xPos + pageXOffset;5 J: f7 d, C: p3 ?
         document.layers["supertext"].top = yPos + pageYOffset;
3 I! X5 a( t  |7 |6 Z8 C+ C* ~: t         }2 C! t" q' ]: S" U* @* F
      animatetext=setTimeout('moveBall()',20);
9 y/ H3 i+ ~; {. _      }* b2 W! _, z! P5 L  W( b
   }  @" ]1 O0 s0 O4 m9 o; ~

! [/ E6 A7 i5 X: t: S9 ~- J) `function calculatePosition() {
' Q; Y" k6 C! V) y   if (xDir == "right") {. \. j2 N( ~5 y
      if (xPos > (xMax - contentWidth - BallSpeed)) {+ g# J8 Q' ~! R: [& k
         xDir = "left";
1 l2 L1 `( `, k0 E; z5 K0 t. v4 E         }( w) U9 c- n7 I" P5 }2 l
      }/ h/ M0 ]/ d' V9 a, L$ W: f* }+ \; \
   else if (xDir == "left") {
, r8 a4 }0 S) L; d      if (xPos < (0 + BallSpeed)) {
. x& S% F8 B/ w+ U, h1 J         xDir = "right";! ]  U  w; g' S2 k/ A2 M
         }
* z: ^; M! Q& S- _0 A      }  h2 _- @% ~4 s+ v8 ^
   if (yDir == "down") {+ ]/ _7 S; m6 U1 [
      if (yPos > (yMax - contentHeight - BallSpeed)) {
* _! D$ S) Y! R# a- c# l& y         yDir = "up";: q- s) v7 w+ A
         }$ V: s. o- |( ?3 Y* @! ]
      }
: @, t: }# `- ?/ B: j% S9 D   else if (yDir == "up") {# c; r0 Y1 k/ o" n& S9 j
      if (yPos < (0 + BallSpeed)) {
6 h' D8 y  W+ ]7 u3 b( b. P         yDir = "down";
3 c! `! z; C2 G+ ~& c         }
9 p+ x9 k" p3 n9 x% A& b0 a2 ~) t      }9 G% v8 G& s  C
   if (xDir == "right") {
5 Z* g  z/ R+ l, \% W0 \, m      xPos = xPos + BallSpeed;
$ f; |: f4 p, @$ @( x4 z& b6 O' v      }  ~* y" Z9 y" f
   else if (xDir == "left") {9 {/ T- d2 A3 z# ?' D) j" O/ `
      xPos = xPos - BallSpeed;
" P. e6 G1 K; D  e( k4 y$ ]      }
, o& Q1 S& d; l' F   else {
8 [8 F5 }- I, @( c      xPos = xPos;, ~2 s1 i" s* g: E# O8 \/ L
      }
, Z0 u% g" C  B   if (yDir == "down") {0 j4 C2 U- R- e. e0 M" V
      yPos = yPos + BallSpeed;: Z9 v( m4 N3 e
      }+ W1 r8 {/ M$ W8 x. n; e/ t
   else if (yDir == "up") {# F! ~  o! |$ {( C, N/ F
      yPos = yPos - BallSpeed;
+ P2 L; L) `  c      }' t1 l% W# _8 m
   else {# m/ W; T4 R; k; W4 G; `1 _
      yPos = yPos;$ P8 T( I" j# ], i7 B5 d* n6 w
      }
+ x( p5 B$ t+ F. S+ f' m4 V$ S   }7 b5 _* L- ^. d$ J# W

" g0 G; z" w+ U- k) Z% Efunction hidetext(){/ e/ w$ E) E& h  G4 D
if (document.all)5 d# A+ O% U9 _7 \
supertext.style.visibility="hidden"' Z; r+ g# C# @
else if (document.layers)
9 B' \1 \, m! t9 n" B6 \document.supertext.visibility="hide"
" q" f+ O6 A% v) H4 j! f1 mclearTimeout(animatetext)+ s  s" D8 o" i/ i( F  \
}1 o$ ]2 ^" P+ d: [3 [7 P0 p
! u0 D6 H. K6 U# X0 L
if (document.all||document.layers){
* \# P/ C" T& B" Q7 i9 T# p5 bdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')) I: j- @7 i& ^/ d" r6 ~
window.onload = initializeBall;
: U$ p0 D5 {" E1 i8 B7 t; t# gwindow.onresize = new Function("window.location.reload()");) R9 X' w* `) G$ o- Q" l
}
1 y# d" h  O, N; E% p5 M7 L& D# k* W6 g$ ]- }  t
</script>

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