|
  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之不断弹射的文字-特效
<style type="text/css">
! x8 _% \; S% q#supertext {% ^0 ~9 K6 _1 L% |: t8 [
position:absolute;
# `$ a5 h9 g6 @2 r+ `4 i4 t9 `left:0;
4 B. D5 C/ I3 B7 Ctop:0;0 E7 {" G. s* |; r- V
visibility:hide;$ [. u' o! @ R, ~& ]
visibility:hidden;
$ @; e8 ~. a/ l1 W* @, `}8 W, _& z$ q' h! o _. @
</style>6 C' ]* R6 ^0 a" F6 {
<script language="JavaScript1.2"> @' B8 [7 s* j. k4 g, d8 Z' E4 P$ s
<!-- 改变下的字体的大小。颜色-->+ O$ Y* _- q7 O; @
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>' R7 n, y- p* F, P% y; O& I m
var hidetimer='';
+ B3 h' O8 x$ R" a3 G<!-- 改变下的弹跳速度-->
O. q5 \7 G( R8 d `, wvar BallSpeed = 20;
( y3 O, G' D/ T$ zvar contentWidth;
3 I1 W i! v: n9 m4 J4 i; G0 q8 zvar contentHeight;$ b* l; K, \, y% q/ K! r! u# H1 O& J
var maxBallSpeed = 50;
$ O) u# d7 U& m$ T: r" }! T3 H- l
4 }3 y1 p. L. x- k9 X. H
' P* Y) p7 ^; t$ h9 Evar xMax;
# T& b& x; v. E& _var yMax;
% i. O- l; K# j5 Y2 t% Mvar xPos = 0;
, |$ ~+ q. }) y( qvar yPos = 0;
; E- K! `: ^/ _" e. }5 Xvar xDir = 'right';
2 l; ~# M D8 D+ ^var yDir = 'down';
7 k! U: q+ ]6 Q$ G q; R; P! k+ ]! s2 Vvar superballRunning = true;- @4 g( S6 ^/ e0 X8 G# d
var tempBallSpeed;
4 h! C' `) j7 t4 \var currentBallSrc;
H" l5 I& J% h1 I, r" }3 G. j" Kvar newXDir;- d6 }8 w7 N r6 E' k
var newYDir;$ {/ ?9 _5 e. `) i4 P2 ^3 R
. a$ A0 ~* ]: P! m4 M D4 b* Q( }function initializeBall() {
I9 l$ g6 {4 K0 f( h3 l8 E if (document.all) {: H7 g! }: ?1 P- o" f4 n& K
xMax = document.body.clientWidth( P- w4 C7 Y5 h. f/ j
yMax = document.body.clientHeight! Q# R$ x4 D1 y
document.all("supertext").style.visibility = "visible";
0 Q, g4 Y8 X( s5 E9 ~; W- Z# l contentWidth=supertext.offsetWidth/ O4 _ }$ Q9 v1 A
contentHeight=supertext.offsetHeight( B/ F8 {# X8 {8 {; v/ y0 @; `
}
$ q1 ]; b0 M* O5 s1 E" R; b else if (document.layers) {# C1 O" f% h" d. z
xMax = window.innerWidth;
2 G7 d# I9 A3 _: g! Q+ ^( L5 [) T yMax = window.innerHeight;, p7 \; @* B0 V' ^
contentWidth=document.supertext.document.width* O4 c' W. R7 H! i/ b$ ^
contentHeight=document.supertext.document.height
' U" I3 I1 L3 L3 T document.layers["supertext"].visibility = "show";+ V1 R- N3 g# f4 i9 B
}7 h' f! v, J) ^. g
setTimeout('moveBall()',400);
7 m8 c$ v8 i. y# K if (hidetimer!='')
8 a% U D& \* A$ G5 f setTimeout("hidetext()",hidetimer)
* a" n7 E. a* u$ [! D }
9 p+ \3 ?- }! t8 ]
' ~ P0 [' d. L$ [: G5 k; o4 Ufunction moveBall() {
: z7 b- z2 v6 G1 J/ m if (superballRunning == true) {
( g( N u) g" d1 G calculatePosition();5 r" {9 i0 t! w* B
if (document.all) {4 M3 V5 t* j% O/ f
document.all("supertext").style.left = xPos + document.body.scrollLeft;6 z% L6 B2 \' l6 d" \2 j
document.all("supertext").style.top = yPos + document.body.scrollTop;& s5 W. c" p0 y8 |- `( _$ Y1 L
}- F+ Q2 ]# r2 j' m7 }
else if (document.layers) {- O/ j0 l% a; s2 e8 j5 E
document.layers["supertext"].left = xPos + pageXOffset;
' Y3 Q- n* u" J- \% \$ E% n document.layers["supertext"].top = yPos + pageYOffset;
+ ^7 _1 B" V% b }
. w5 k, s# H$ d; O# [! p. ? animatetext=setTimeout('moveBall()',20);+ H0 \ m0 D7 {3 x$ t! o
}
& N, U* f* p- | }$ h/ k) Y( n4 b6 u0 D6 e
' g. t& g; M `+ |: {function calculatePosition() {* j/ Y N0 L. A& I
if (xDir == "right") {5 |2 D; t! E# q7 d2 M0 _
if (xPos > (xMax - contentWidth - BallSpeed)) {
( v7 i# q# p+ E4 {& { xDir = "left";
( `$ h1 V! Y+ a% b: ]* d' Q }
+ W! v7 U, x& M6 d. r }
2 P4 U, M: t! [ else if (xDir == "left") {
) _; {% o: }) z& m. Z if (xPos < (0 + BallSpeed)) {6 s; U/ z& L9 ^
xDir = "right";6 U# C o- a- W+ I& D! [/ X
} J }. h6 }9 i* d, w% O
}
$ r0 X! R( a+ |( T# x: e: w" q3 a if (yDir == "down") {, W4 Q" A( |& k) r
if (yPos > (yMax - contentHeight - BallSpeed)) {/ X8 e8 y0 q: [0 N( F
yDir = "up";4 O! H# d. V1 f$ v( [( Q, Y0 ]
}0 k9 P1 X4 w0 m$ i a( W
}; ?! i9 D/ z* g
else if (yDir == "up") {
( F7 ?) y' q2 K7 K if (yPos < (0 + BallSpeed)) {: _+ d8 G, t0 V
yDir = "down";& E' l9 E; B( q6 n' ^ h% ]+ |3 g
}$ q& }# M( |$ o# J; y F
}2 m; ~2 j+ K/ L5 Q! S& p2 q
if (xDir == "right") {0 w0 R- O* [$ v3 Z/ S6 l7 q# K P C5 o$ x
xPos = xPos + BallSpeed;
a# B; c/ z5 g7 [* { }7 L) O( s. j3 M
else if (xDir == "left") {7 p. n8 o. S( U5 O6 U) P
xPos = xPos - BallSpeed;
' U# v P) n; O: D& U: A# V- | }. x0 b, M* i5 H7 j4 C) [4 e3 I: a
else {
" `3 p) d: F0 Q8 |: t2 l; ?- j6 J xPos = xPos;$ l- w9 N+ d1 ]' ?+ r! B- G' |
}
' u" r/ c6 \0 A6 `" O if (yDir == "down") {
0 j/ J* ?- u7 m$ |9 ?' H! Q5 C yPos = yPos + BallSpeed;
. ^7 k4 E7 d% l6 c" N p }1 c/ N o% c8 R& [; X
else if (yDir == "up") {
" e7 p% m; N! a% m% u3 r- a7 _ yPos = yPos - BallSpeed;
6 _6 v% k& F8 K* G/ V4 H }
' c U7 \; M! S. |' F) \4 K3 x9 N else {
2 V8 n$ k( b! ^$ V4 m yPos = yPos;) ]: Y5 c; y3 f7 x3 m$ {! k
}$ g+ I! i9 I; M/ x1 @& \8 ~& p
}, Y/ V8 m, H# p- L& L
& V! _/ y! L0 W3 k2 ~
function hidetext(){
7 S" f) S5 {8 |0 Q9 M3 D7 H8 }if (document.all). u' ?9 |1 I1 T; i1 w4 @
supertext.style.visibility="hidden"
9 C9 Q. w# G W+ n2 M% ]2 e5 R) Belse if (document.layers)
; T; C+ I2 v* h3 G5 n$ _% Rdocument.supertext.visibility="hide"
; t+ ^7 u0 X [/ e' T9 L0 f4 x# D2 wclearTimeout(animatetext)
4 J5 D& k' g2 [) Q! ^}
0 K4 N( s/ B( _
" s, e+ K& v& e1 i: f4 _if (document.all||document.layers){
( V, H5 [6 S% X2 x0 r/ h) Ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 \! e, d0 M( K: o! f+ e
window.onload = initializeBall;
# m4 z; _9 ~ [1 Gwindow.onresize = new Function("window.location.reload()");
( ^+ U& i; d4 ]% q; n}
9 }2 _1 {) U& {% D; k" g$ F" r0 N5 \9 I* b
</script> |
|