获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">" m1 H: N! `' E# ?4 |# I
#supertext {
$ z: T5 W+ T0 X6 ^+ rposition:absolute;
# @  |) k9 o% f  U* a# `/ m* Aleft:0;. @0 [' i& w1 ?, W5 h6 `
top:0;
7 c2 _, g) N# M  e* }$ }! R. Zvisibility:hide;
  ]  M2 ?" D) U9 }' R7 tvisibility:hidden;8 G$ u7 W2 W) i  @% S8 q
}
% p( r% ~2 d$ W! f. P/ H+ z</style>, l4 |" [2 X* |& J9 Q" T
<script language="JavaScript1.2">
; ?% q& l' W7 C; M8 m2 s& o! v<!-- 改变下的字体的大小。颜色-->
+ y4 V( [. k- v- [var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 Q. X0 d6 ?. b1 [$ pvar hidetimer='';
9 C8 a6 A9 d) ~' M3 v<!-- 改变下的弹跳速度-->9 P2 N4 f0 z2 r8 z) h
var BallSpeed = 20;
3 M9 `" h8 c6 [' N4 E1 b% _var contentWidth;
3 @& S. x7 U8 o+ e1 P& w$ o! Tvar contentHeight;
! K  |/ O* e  E& evar maxBallSpeed = 50;- k1 k2 _1 {* @( f' F! w- _: a
3 W' w9 o+ D* R0 v4 D( h1 L
! i6 ^$ f% E% f2 ^/ r& c# B) B7 }
var xMax;
! j, Y. P) K$ n9 m5 A  f" @var yMax;
/ t4 y9 D2 B3 _5 x$ Rvar xPos = 0;
0 x; W* B; E6 A1 ~4 ~var yPos = 0;+ ]/ C- B6 a( V! v5 q2 i
var xDir = 'right';) |5 Z6 W, s/ j6 ?0 a5 d- y
var yDir = 'down';; T' Y1 q" q( r
var superballRunning = true;
8 H: V- H1 e- q9 r6 j0 V; ?var tempBallSpeed;. Y8 [8 j5 A9 g$ v% Z6 ^8 d
var currentBallSrc;$ K7 Q& H! W  M; w8 ?' g6 s: E
var newXDir;7 Y, B) ^: X$ p, L) L
var newYDir;
; ~' @( u1 Z  W+ A/ L; B7 M* F! ?1 L6 C! m/ r! J( T& ?
function initializeBall() {
7 E0 p/ v/ y+ h& g0 j3 F   if (document.all) {' H! V( E% _+ D
      xMax = document.body.clientWidth+ r& M. s8 G+ P: T; D
      yMax = document.body.clientHeight1 c/ |2 B- y. V% N. r
      document.all("supertext").style.visibility = "visible";6 A" ]: X$ p1 H5 u2 |
      contentWidth=supertext.offsetWidth- v& j- f2 P. R" A, q/ a: r
      contentHeight=supertext.offsetHeight( ?, V: a1 V2 _2 F4 {& I, T
      }
, d; l* K3 e/ y- j   else if (document.layers) {
: s5 n# }# V5 a7 W      xMax = window.innerWidth;+ s2 `1 S0 L$ b7 _
      yMax = window.innerHeight;
6 U* G* Y+ G+ H& e0 c      contentWidth=document.supertext.document.width5 I  ^) a! y7 g9 X7 C3 H
      contentHeight=document.supertext.document.height3 R8 v3 T9 Q" C5 x4 F
      document.layers["supertext"].visibility = "show";
" }8 Q5 x6 N+ V- n+ M8 Y, v      }
' m5 E2 u, I4 t7 G# c/ c   setTimeout('moveBall()',400);
8 z/ X; R* z6 U8 Y3 a; e( B$ Z   if (hidetimer!='')
& ?- |  Y- j: R9 d   setTimeout("hidetext()",hidetimer)
; l; H% E/ r, Z5 Z* K3 f   }
/ [8 T) E% s( T& |' h7 f8 `' h9 N5 I$ I
function moveBall() {
$ l8 Q/ O1 M: g$ M   if (superballRunning == true) {% J' [; b% ^; P) r1 G2 m4 x
      calculatePosition();
5 O% M: G9 Q) }- e+ S      if (document.all) {! N4 r- u) e, V  U$ j9 R; F2 B
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
( J7 z5 h& ?7 x         document.all("supertext").style.top = yPos + document.body.scrollTop;- @9 h" x, O& d( H9 ~( ~
         }) ]4 L. r' A2 J) F  e) K
      else if (document.layers) {
5 H4 M! d9 N% U- e3 r) P( k5 ]% }         document.layers["supertext"].left = xPos + pageXOffset;: g2 X2 D. d9 \6 x; z) F& q% N% h
         document.layers["supertext"].top = yPos + pageYOffset;9 A, j( a3 R2 E( p; x4 Z! W# f
         }; U# J' q. z  P3 v3 C+ k  R. M
      animatetext=setTimeout('moveBall()',20);( [& {. \' p* ?. @8 t6 T
      }; X) d$ H- F% b$ W* g
   }- {8 M7 G) ?, Y7 p" u5 X( |: @. t! \

5 @0 {( a/ f2 F/ `function calculatePosition() {
2 {/ L! b; P: H4 s) d9 N   if (xDir == "right") {* v" Q/ d/ g- ~+ q; t1 _
      if (xPos > (xMax - contentWidth - BallSpeed)) {! ]% s; A; X  \+ s" t! q4 N
         xDir = "left";
- E2 S- X( w/ V         }
0 K. W9 p: z. \' `1 F! e- S      }- D/ B  J) ^; M; v9 s& q3 c
   else if (xDir == "left") {; _3 K- s8 U9 j
      if (xPos < (0 + BallSpeed)) {, v# y2 ^4 X; `' y
         xDir = "right";
- L. ^2 J5 _+ M6 |3 [+ k. f" V         }: _. h8 P& [8 G  ?" ~3 [8 j6 w
      }' X, \2 j" Y5 H
   if (yDir == "down") {& t5 l7 v  _3 a. c& g
      if (yPos > (yMax - contentHeight - BallSpeed)) {
! x3 u9 B* }3 v- D4 _         yDir = "up";2 ?2 w. W; n5 U
         }
* p/ ~, D! S  u      }
/ B. W' J" L* ^) R! F9 n   else if (yDir == "up") {
+ \6 {2 {- W, s8 P: B" R      if (yPos < (0 + BallSpeed)) {
. W' S7 ~+ W4 v6 u  f6 b         yDir = "down";
! U8 A( q& q  o! l         }6 \& t8 @0 t# _5 {+ c& b6 m
      }3 C6 T% z$ A1 j* v0 }( U+ l
   if (xDir == "right") {
# y3 l- U( l; g2 h/ R      xPos = xPos + BallSpeed;
) U9 ]3 Z/ w* Z; y/ o- O      }
* x; K! g) F1 o, a! Q1 D9 Y! B   else if (xDir == "left") {
. g! z) I' l+ X4 \' e      xPos = xPos - BallSpeed;
1 d5 @: u  B; p" Y      }
( U+ M* n' r) ?   else {
& |% `4 J5 B; D      xPos = xPos;
& b6 V/ P1 ^" |+ X  H      }
' x5 g9 X+ F" ^9 k# E8 ]/ z  V   if (yDir == "down") {) z( `0 C& @1 d/ }
      yPos = yPos + BallSpeed;" W* W0 r/ B' N1 y: H
      }1 {+ g! h4 B6 A1 o
   else if (yDir == "up") {
; k7 ]% R  e% n" o2 |2 y      yPos = yPos - BallSpeed;! \2 c  F' C  L3 G8 J4 F
      }- P2 u  L, f; y& E2 N5 G8 Q
   else {
1 K9 k  j" f. C0 |: l      yPos = yPos;
8 M4 h! W& ~& Z      }" W' @8 G) @% w, n
   }( }! p% D& g# q8 N4 C
1 e: z. |7 Q3 D, l  q' B
function hidetext(){
2 s7 _+ S. ?9 p2 A- ^if (document.all), ^% ?* P6 O7 \3 M3 E
supertext.style.visibility="hidden"4 u# `. p- L6 c! N# I" ~
else if (document.layers)
' G8 o) d  B, p3 A% Zdocument.supertext.visibility="hide"
# P- S+ N& Z; }6 JclearTimeout(animatetext)
8 Y* i, v  v% J7 ]}
% k! C  D5 `$ _0 Y/ V
) E5 w3 ~' D+ q4 E; uif (document.all||document.layers){+ }7 z1 v5 s. J7 q
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# s) E/ L8 T! p. d- ?" N+ Swindow.onload = initializeBall;
; \4 ^! b8 ]0 m/ Kwindow.onresize = new Function("window.location.reload()");9 }9 N1 A) s, o* f
}4 M- W& C, u# W, J
% H5 i9 x0 H- z* l9 h) d  ^2 ~
</script>

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