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

|
网页之不断弹射的文字-特效
<style type="text/css">
1 {2 ?- _ |: J#supertext {& Q% v5 k9 h& C, Z% P1 r7 e% b
position:absolute;3 B0 \3 H# t3 M! o
left:0;, B% x; |" ]6 B8 X0 l; o3 ~ S- z
top:0;
7 ]9 _6 Q) ^- _1 A' V% e9 `5 jvisibility:hide;6 p' h: [8 @) x4 f: @
visibility:hidden;# i1 A" [4 c! P) R
}4 j1 ^7 {3 T) Z. B# u3 ^9 M
</style>
. X* r9 ~ ]6 b<script language="JavaScript1.2">; C) z' ~1 a; @# A y5 [
<!-- 改变下的字体的大小。颜色-->
- a9 |6 l! y6 a' [9 w5 Fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 m+ I, j, B9 I" B6 D' ]& Evar hidetimer='';: @$ ` _* s3 L0 q0 C7 o6 A! A+ k
<!-- 改变下的弹跳速度-->
) T% [+ e) w: l7 B9 A" {var BallSpeed = 20;4 U- A9 ^" ?9 q' T$ N
var contentWidth;
* s0 L% M; P8 K1 kvar contentHeight;3 |. _$ \% ^( _' Z u7 A
var maxBallSpeed = 50;5 E, l9 ]9 ~: o, S* \
) F4 u1 s5 [9 r: e6 D5 U% a
% {" F5 V% z# q6 k- T
var xMax;
9 U! I( t/ r# w7 |7 |2 jvar yMax;9 p5 H( W* ^+ w6 }7 y* Y; W) K7 U
var xPos = 0;
0 ?+ x! b7 E7 X/ Dvar yPos = 0;
+ P3 Z1 i; B- Kvar xDir = 'right';6 ]7 m4 |/ s. Q0 g o1 E6 e) Z
var yDir = 'down';$ ?# k, w: J# l1 Z9 R# p) t
var superballRunning = true;
6 c3 k" E& }# _ cvar tempBallSpeed;
& @/ d/ |- `4 L$ ^, m' d- cvar currentBallSrc;
% M) Q3 X% H( u$ H5 k s) s# bvar newXDir;
/ x; [$ @' N3 K1 d5 Cvar newYDir;
0 k' E; ]- C9 H; S0 R0 ?1 f5 E3 [2 P* t; x% F
function initializeBall() {# I. i# s+ U7 W+ U7 H/ @ F* Q. `
if (document.all) {, b2 \7 I; s# S
xMax = document.body.clientWidth `/ b" O; U! U
yMax = document.body.clientHeight
) d+ B: {7 d. ` document.all("supertext").style.visibility = "visible";
& v6 o* R8 x5 R$ y5 \ contentWidth=supertext.offsetWidth, Y9 k( }7 a' y8 ?) s3 G
contentHeight=supertext.offsetHeight5 M# A5 i- G$ E% G3 T3 E& V
}
$ i1 b7 g4 N6 L5 X0 _4 L1 s else if (document.layers) {
- j4 u6 E( \! U$ h0 J. L xMax = window.innerWidth;+ ~* S& }! o5 t8 ~
yMax = window.innerHeight;) {8 G w, {8 ]3 }% |
contentWidth=document.supertext.document.width L6 K6 O0 f% Q; q2 I
contentHeight=document.supertext.document.height
! }8 T: `) c$ r document.layers["supertext"].visibility = "show";& S+ e) r/ U0 w% u7 d, T7 T8 S
}, u/ F$ l$ D. X- y- w" o5 ]" H
setTimeout('moveBall()',400);
6 _( M6 a; s" \) ? if (hidetimer!='')
' F. C) \2 L/ F4 R) a setTimeout("hidetext()",hidetimer)
7 V5 [+ c2 L2 W# `, D/ i: d# t1 ^ }6 G$ T6 P7 {! ~$ m8 F6 e' G
! Q$ X* N; e' l) ]
function moveBall() {
4 i6 D* I6 w3 c7 N2 \* x& H9 [ if (superballRunning == true) {7 f' a# J: z4 l/ z' Z: k
calculatePosition();4 j. q' |% L1 c; U- B i
if (document.all) {! u) y7 W' e4 A6 a/ N+ \
document.all("supertext").style.left = xPos + document.body.scrollLeft;, L! `* v2 q* V+ a6 A# G% p, X) q9 y: ?( X
document.all("supertext").style.top = yPos + document.body.scrollTop;& ~5 g+ x9 G0 ~. W1 E v4 ~3 s, P- @
}0 j2 y2 C) o! z- T$ ?# B4 q
else if (document.layers) {
4 ^) H0 z2 ^/ M6 e0 U% G- \9 X! q document.layers["supertext"].left = xPos + pageXOffset;
0 D+ ^% O2 Q! l! k% e document.layers["supertext"].top = yPos + pageYOffset;- \# C2 k5 }, x8 y
}
+ K2 m- f4 g4 z8 N. z9 f animatetext=setTimeout('moveBall()',20);6 `' u( C! ~5 e. p% k
}) c/ e& b: s3 i' \$ \( ^
}
+ h3 i" K1 Y$ J* P* k* a8 k8 C$ d2 x0 P8 _- ]: a) Q
function calculatePosition() {; b+ q7 L" M/ u+ K! L8 n9 ^
if (xDir == "right") {
; N2 A# ~; A; l! r" ^ if (xPos > (xMax - contentWidth - BallSpeed)) {
5 `( Z$ [' ~0 [ xDir = "left";
, v2 {# ?2 d( h# D, J; |& h }
( J0 {% ?3 m, c: j9 V }) x# x$ S) g5 J& J8 V6 V
else if (xDir == "left") {0 |, I$ Q. ]/ u+ l5 P& m: ~
if (xPos < (0 + BallSpeed)) {& V7 {, |4 b8 E0 Y, l
xDir = "right";7 d6 f! ]. a9 Y* v0 T7 O
}: H* u" w# K) v, n2 g. B8 V
}) c9 v; o# k# f0 g: R
if (yDir == "down") {0 a% w% d) q$ v
if (yPos > (yMax - contentHeight - BallSpeed)) {2 q7 d0 }2 B2 D% L9 [2 F
yDir = "up";) L0 b# k9 o( S# p" q* V6 k
}& U$ ~6 H' x0 S1 a
}/ `- e( k) y& ~" a: Q
else if (yDir == "up") {6 C! A2 d9 k9 d/ e9 _2 V7 w
if (yPos < (0 + BallSpeed)) {
& k1 V& g m+ w# ~+ i. Q& G$ e yDir = "down";
: ]9 |8 g4 b+ |5 z }
3 @0 r O6 y8 E) x% [, I/ P$ H }
4 y9 E) H3 l+ W! z% u if (xDir == "right") {/ v0 f! _/ W) p1 w3 {$ d
xPos = xPos + BallSpeed;3 s# ?9 r, j5 h; c, m
}# {1 x# T5 F5 y1 g
else if (xDir == "left") {. H! n/ H. ^$ @
xPos = xPos - BallSpeed;
8 n2 d" V J/ C2 Q' ]0 W }, r; X8 B& ~4 N- q& s
else {+ j$ s {& x, f: X2 |: c& N
xPos = xPos;7 N& }# {: B& X7 B' Y
}
+ Z& Z1 d% i; N if (yDir == "down") {
2 M! q8 T0 l4 m: k5 B# R2 N6 ? yPos = yPos + BallSpeed;! M$ p0 R1 X: F5 A% L1 B r. M
}' @( p+ {$ T3 s' |
else if (yDir == "up") {
1 k2 ~; u. Z' @9 N- m7 H6 h6 Z# q yPos = yPos - BallSpeed;
+ z) G: c4 ]6 \ ]' c }; n0 w Q3 Q! D B$ t2 |- e7 k" t
else {& x# m# s- K9 D4 k
yPos = yPos;
6 _% b* X9 I) ^1 e& p, l# O) x" b }+ F5 N! N9 Q: A# s6 x y* [
}; g4 |* h9 ^; b% H& Y1 T! P
2 A8 N1 |( E/ _1 h& S; x8 [/ I7 [function hidetext(){
, ~" w/ h/ X4 G, S- d) pif (document.all)/ V! |; i# e6 e0 v8 i, y
supertext.style.visibility="hidden"0 v+ |( s/ Z+ ~9 A: d
else if (document.layers)4 j4 P' f" p' W( G* G$ _
document.supertext.visibility="hide"
1 g. f! q' e* N* ^( a9 L& ?clearTimeout(animatetext)# R% }( e+ K" o. {) d0 U, r" Q, h3 C
}7 g; w3 A! ~8 A }% X5 a
7 _2 h! z6 H5 O/ E h( ?
if (document.all||document.layers){( _) u1 F* [+ ]/ s* @
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
I8 W1 Z# k- _9 q$ K7 |window.onload = initializeBall;
7 t% `, I3 ]+ D6 u9 [: l9 d1 ^8 Zwindow.onresize = new Function("window.location.reload()");, a3 m! f1 V( M5 b) O5 g3 @
}
- g5 c0 [( ~ x3 z* \4 \6 z0 }2 S) f% Y+ }3 v
</script> |
|