返回列表 发帖

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

<style type="text/css">  R% c  z; @5 q+ |
#supertext {
! p$ Y2 X. s/ W8 \* o  v5 j& _position:absolute;
" U6 U: b% G8 P4 z1 X8 `* Sleft:0;
8 R; n2 k4 a% _* l! ftop:0;
1 H3 [! {: z3 c1 j) h: kvisibility:hide;# b) |. G; i! ~# ?
visibility:hidden;
7 f; y$ ^' q$ E6 [}' L# m+ ?% d" v4 {
</style>% C, z0 S# a  o  M/ k
<script language="JavaScript1.2">
: a4 m4 R+ r& Q  ^<!-- 改变下的字体的大小。颜色-->
6 t) D' Y6 Q. [* d  ?var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
- t. p$ k/ t- \" F9 A" fvar hidetimer='';
5 M! u5 P- h, v# u  N<!-- 改变下的弹跳速度-->
# M( y% `4 H' J% R% B( Bvar BallSpeed = 20;' J2 X. J8 t3 M% V5 l
var contentWidth;
8 u7 y$ ?  R& Q; p$ h5 q6 S% rvar contentHeight;- T4 S: p! Y: L5 @: m" W  h& m
var maxBallSpeed = 50;
/ t9 o( `% w9 X8 h/ [2 E! Y4 E# S: K2 n  |0 S6 A

% t# K; O' o! K; s- Wvar xMax;- ~+ H) \2 @3 D# A" ^
var yMax;
2 I& w; R4 l& i( Y4 m, V4 N9 hvar xPos = 0;
8 k$ d/ ^! U" y4 svar yPos = 0;( B5 G. M. V" E& C/ N3 N/ D
var xDir = 'right';
& G5 o0 D9 F, T6 L2 U2 A( w8 Bvar yDir = 'down';9 p+ t# [! }- a% [4 Y% g( @. K
var superballRunning = true;
+ T) @( q: j0 `( v, I6 gvar tempBallSpeed;4 @9 {8 _5 f6 v8 i' R
var currentBallSrc;
, p0 p  _. F( mvar newXDir;' W! e! J2 C4 l, y& e) x
var newYDir;- g4 B5 V2 R: e  J+ g) F! _7 f2 U

: t, `7 X2 f: @function initializeBall() {5 q5 }- R) n; @9 K$ ?# C% }5 s! y7 u
   if (document.all) {  S) a: R" a" t6 ~/ ~) K- `* n
      xMax = document.body.clientWidth3 [8 B+ W6 @) e' t$ T- @) C
      yMax = document.body.clientHeight
% Z8 r; n- ~1 d1 F      document.all("supertext").style.visibility = "visible";
5 M, h$ S) L1 Q, K( |4 z      contentWidth=supertext.offsetWidth
' s' ?1 ]+ v. Q9 ~% }- {      contentHeight=supertext.offsetHeight7 H+ ^6 Y  g& V* k1 R6 H
      }
( x/ d, K0 u( p0 l$ ^# @' q  ?   else if (document.layers) {7 p2 H2 [% E) e
      xMax = window.innerWidth;
, I, _* ]4 i6 a% C# f5 V" V      yMax = window.innerHeight;
; j5 g4 F( `2 {  ^& R6 \" J      contentWidth=document.supertext.document.width8 z3 x$ n0 K& S5 w& F. c
      contentHeight=document.supertext.document.height! P/ i# d+ }- r$ b
      document.layers["supertext"].visibility = "show";
, l8 R* J$ I7 w3 \6 f$ O* c      }
8 x5 ^) F, L3 x2 K/ u6 ~   setTimeout('moveBall()',400);
1 ^( o. M! t1 }; R; q, s' b   if (hidetimer!='')
8 m+ N% ]+ h, V- r$ D- w, [   setTimeout("hidetext()",hidetimer)
& o1 L  _4 R$ h' q. x, u! e   }' H9 O% X3 h8 \. H5 N

  i5 q; x$ a4 o, B8 \function moveBall() {( ?) v; r& q7 \( ]' }' S
   if (superballRunning == true) {
  n5 L& t% |. J      calculatePosition();+ {% u3 U9 ~, ], ^
      if (document.all) {& n+ t- O8 T( R6 k; u/ L1 ^
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
: P6 f( X/ k/ I1 i         document.all("supertext").style.top = yPos + document.body.scrollTop;
& ]( O" d# t' O& J& K  p         }3 N; k) f4 B- s' E& M: M0 n
      else if (document.layers) {
3 `( s: ?- V8 p2 O8 r* b         document.layers["supertext"].left = xPos + pageXOffset;
/ H1 }! S' ]) t9 c  v         document.layers["supertext"].top = yPos + pageYOffset;+ D6 ]# s3 m$ u. I2 [
         }
3 L+ v* n- Q. ]5 N; u: M      animatetext=setTimeout('moveBall()',20);
" N7 m, G. @6 ]' f: @      }- W4 \6 h/ ?0 i: F% o2 ?% C$ A; _
   }  C# U3 a6 d2 `9 g1 E4 X% k

$ @- i& K( d' b2 \9 u3 efunction calculatePosition() {, J$ R" A8 l% d7 C
   if (xDir == "right") {
1 S7 C2 y. R5 n/ r) t. \  m  w      if (xPos > (xMax - contentWidth - BallSpeed)) {
  G3 P$ i* r8 h         xDir = "left";- A. g3 f9 p! x6 Q
         }
! y& R9 x- J; Y$ ]& L      }' B& y! g4 R3 \: v# h# m2 @" o
   else if (xDir == "left") {" h' w; c4 ~4 N
      if (xPos < (0 + BallSpeed)) {
+ E: b0 }. r* v3 H7 d; Q         xDir = "right";& I" }3 C2 O( O! q
         }* M  K( p% c1 v- ^
      }
: X! w0 f6 [; ]: l) W' ~8 p: V" o   if (yDir == "down") {' w8 K' g- \3 j5 m$ b
      if (yPos > (yMax - contentHeight - BallSpeed)) {" K1 p9 n4 p9 v- _7 @+ ]
         yDir = "up";
" |' l5 [  X8 C         }
5 M* \+ y6 k1 v1 N      }
. l7 e. j+ m  t8 d- e" J   else if (yDir == "up") {
/ }$ H7 P8 T8 i5 W' ~      if (yPos < (0 + BallSpeed)) {& \5 e: X- |4 ]% z
         yDir = "down";4 {' g) I8 ^5 s7 i$ l; {) I
         }
3 k& e5 {0 [3 M7 t% I* Y5 N: {% s      }
, q4 ~/ L& t) x   if (xDir == "right") {
% q# s& J/ u% @) ^& P3 W! w" t      xPos = xPos + BallSpeed;# y+ Z, L+ T7 `/ I
      }5 B4 ?1 q% M% U! D
   else if (xDir == "left") {/ i% Y3 ]8 ~! z9 g8 \" b9 ?* m
      xPos = xPos - BallSpeed;1 a+ k% B) k# M% e
      }
% _/ u/ \; g. C; {6 b7 S   else {( V) d; g% s6 d& R' O0 D
      xPos = xPos;
1 r" d& B% H! P" B1 @      }0 v  v  ?  a9 W9 z
   if (yDir == "down") {
9 L# F7 r  V% s      yPos = yPos + BallSpeed;
$ M. T2 p) L. b  |9 z      }
" b" g! c5 p1 q* h9 P5 R4 C   else if (yDir == "up") {
9 F1 |  e% M, N, k/ V/ Z! h      yPos = yPos - BallSpeed;' q, }$ e9 Y; _" M1 L8 i
      }9 K6 g' e; C3 W+ ^4 a
   else {
. E* h) \% S1 g7 F. ]: q3 Q      yPos = yPos;
( K6 b: g9 G: j# H      }# Y$ P' O7 O: f  u
   }) R5 T  H2 w8 _3 S( C$ u

) f, P; Q" G: F" {function hidetext(){+ @; O8 }0 j. E' {" ^! V
if (document.all)
2 c/ N- q% Y0 y, y1 \8 isupertext.style.visibility="hidden"6 U5 O9 l9 d, p. X1 o5 p
else if (document.layers)
' B, _: f2 Z  m1 p, Zdocument.supertext.visibility="hide"0 @$ L1 ~  R* P1 R- r" f
clearTimeout(animatetext)
6 c' N+ I' Z% W}% P7 K5 C# p. v' [# Y! ^
% E. o  W$ ^% n/ p/ [9 E2 J8 _- l9 {
if (document.all||document.layers){. K/ Q  ?% m7 ~; W
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 n9 o) ]$ J1 w/ _: l8 i0 nwindow.onload = initializeBall;" ^  T/ U8 y! _
window.onresize = new Function("window.location.reload()");
  `% _7 @$ F- ~9 J% S7 @}
: }" ]9 C5 E' a2 d
# Y. f8 M3 P* W0 I</script>

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