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

|
网页之不断弹射的文字-特效
<style type="text/css">6 M; S/ {2 B# }) x2 h& ?+ t
#supertext {
- @9 k% M' c5 Kposition:absolute;
/ e7 L9 k0 C, ?" p* S) a" p; B0 W8 Aleft:0;3 O2 g- v4 g: I f( F
top:0;
& [- O# H* L' `9 L9 n' ], w5 J7 _visibility:hide;# ?, l/ E9 N- _
visibility:hidden;
& p* a1 h6 c+ r% }9 P}
2 V% |, Z( j% ^, s. V1 h</style># m1 K0 ~( i' y1 I9 @0 N) s1 C" L
<script language="JavaScript1.2">) L1 R9 o y& h6 J
<!-- 改变下的字体的大小。颜色-->7 i5 }( `* N7 b. u& s$ a' {) j
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
$ _* @ L6 a3 _; F' T& k: zvar hidetimer='';1 X+ N0 @" R, Q
<!-- 改变下的弹跳速度-->7 I8 T3 q# |7 s: r7 Q3 O H8 y
var BallSpeed = 20;( b/ R2 b8 q$ w: ~5 j
var contentWidth;/ j, A: d' R3 X9 @# ]
var contentHeight;
. L0 G3 e4 @5 T( y$ q- n: Fvar maxBallSpeed = 50;
' {# g# G6 ?; F5 `/ N% S
$ I5 q. c6 q t/ j& ~+ Q5 n2 a0 B7 N" o
var xMax;
7 _/ E" u3 S5 n9 Z+ x8 G7 ?var yMax;% g/ N% @ o S+ |3 ~' G
var xPos = 0;2 H+ Z0 l. \' f. v
var yPos = 0;
% P& ^1 I. ^: E3 p9 i2 _: svar xDir = 'right';5 ]: v& d% H! ?
var yDir = 'down';+ R. V5 c) Z3 \+ o% w4 p5 O+ \
var superballRunning = true;
: ^" X# H) V5 Vvar tempBallSpeed;5 s4 m/ ?& d+ V V9 E
var currentBallSrc;
" @0 U% B$ c0 p) K1 t) o3 P7 avar newXDir;
2 j1 u( e% b/ j* A" tvar newYDir;6 h, I [ w4 O$ _, _- H: @# N& f3 z
* I! q1 p/ U8 u: s1 i! Y8 h8 afunction initializeBall() {0 U1 X4 x2 T: a8 w$ v
if (document.all) {* Z9 O; Q- q# u4 e* }. _ N& i! W
xMax = document.body.clientWidth
O# i: f R$ v8 F& t yMax = document.body.clientHeight
+ n' H! e, S& m9 H document.all("supertext").style.visibility = "visible";
8 M2 P j# z* e) h+ c* m7 r contentWidth=supertext.offsetWidth
2 \( p( K& K8 a4 y7 H# w5 H; H contentHeight=supertext.offsetHeight* Q; s& k: j( a' t1 I l
}$ |% j- x( P h1 \* Q
else if (document.layers) {4 F. m o( Q4 @* w g9 \
xMax = window.innerWidth;" k4 c- V0 }! @( y$ p2 z
yMax = window.innerHeight;& d. Z' `! I! h$ Q
contentWidth=document.supertext.document.width
4 Z/ v5 F9 L! E# L contentHeight=document.supertext.document.height3 ? I5 q! N) w& v( V6 `1 `0 W
document.layers["supertext"].visibility = "show";
0 S) \ u6 \. O# U2 f }
& _* b2 t' t2 z9 w0 |3 } setTimeout('moveBall()',400);
( Q' T% U' w, X; d# G; i if (hidetimer!='')1 V: {% i! |& s2 E- | V$ p
setTimeout("hidetext()",hidetimer)
" f S2 W5 _8 } u }
/ h! R K3 b$ e7 r. W3 V2 e$ G3 K1 X3 Y
function moveBall() {
) T- l- K+ Z7 W" ]* X* c+ l( u if (superballRunning == true) {) v; {9 h% Z0 _
calculatePosition();
4 G& [" }; @# A9 [: i if (document.all) {
- _8 T% ?! ]; g' S% ~+ d3 s2 ] document.all("supertext").style.left = xPos + document.body.scrollLeft;& ]' v. {. {7 T. J. P/ D& N4 R
document.all("supertext").style.top = yPos + document.body.scrollTop;1 v7 n. @, q& w% M' Y ~7 X
}
0 f( G2 |* y$ v1 J. H else if (document.layers) {
9 ]8 x; S- k, X1 U document.layers["supertext"].left = xPos + pageXOffset;
( S6 X' `8 U" T M' w: i& \ document.layers["supertext"].top = yPos + pageYOffset;. S( v D1 |3 x2 a
}' ^, j$ x* g3 Z( k2 \: E6 x$ {
animatetext=setTimeout('moveBall()',20);) h! k8 t5 B2 B
}5 F6 [1 e6 t; ] W1 Y+ s
}
6 N* M0 t4 a \" [$ `
( G9 I. K) X( U- Ufunction calculatePosition() {
) H2 n0 ^" u( b9 J! T if (xDir == "right") {6 q8 d; g7 G0 H- Y4 a/ S
if (xPos > (xMax - contentWidth - BallSpeed)) {
3 t9 s+ q* q; }+ ~' O2 Q7 e xDir = "left";7 \5 v+ |6 u% N% n. A% {0 o
}
W; Q: S* z9 ` }
" F7 ~7 F( y' c: z1 R& |9 V( x else if (xDir == "left") {" q/ w9 v4 ^2 A
if (xPos < (0 + BallSpeed)) {9 {: O4 Y9 V# q; b4 W8 F+ }
xDir = "right";) v" B$ m7 u7 _3 o0 i
}
6 l6 @3 }( M% l' s! K% b: A6 r$ f }6 y: b) l: S' \ l% J5 z
if (yDir == "down") {/ a, _6 b; e' M
if (yPos > (yMax - contentHeight - BallSpeed)) {
/ |2 l8 z$ ?* g3 i' U9 a% Z5 ~ yDir = "up";" J1 ?5 ?2 [/ V0 C- w; F! |. A
}
d' V0 f, ?$ n }
0 R( P( b' J8 { else if (yDir == "up") {0 @* k- f- s# {
if (yPos < (0 + BallSpeed)) {( e5 P6 D/ O n* b' I1 x# ~- u ]0 J
yDir = "down";
8 o* Z- O, s+ |" R6 v1 j# h* v }8 T- }2 i& K; S
}( U* V; |; `5 M% ~2 S/ a$ ~' M
if (xDir == "right") {5 Q8 ?+ e3 V# l' a6 p3 u9 K7 R
xPos = xPos + BallSpeed;2 j% ^7 V' V6 Q( h7 t6 _
}- ^6 Y' W8 b' D% S+ k0 k0 Y9 [
else if (xDir == "left") {# x6 |$ Z/ ?& @" h1 D
xPos = xPos - BallSpeed;3 Z J/ ~, s. E- R/ T i
}
9 X4 M; y! E5 ~6 j7 t else {
% ?- Z) G! B9 k2 D9 `7 y xPos = xPos;1 X! C; q- u/ L" m' _
}
3 y- J6 x+ a& B4 @' @ if (yDir == "down") {( E! s# e8 i" d6 A
yPos = yPos + BallSpeed;
1 \" S3 \& N' @# v+ \" X- ~5 W$ ?$ O9 c }
7 j5 \# J& E# y3 E9 G. O else if (yDir == "up") {3 e1 K9 d# U5 x4 E; o+ K* p
yPos = yPos - BallSpeed;
0 e1 Z1 C# s0 x( ` }, S( u" x: E) Q5 o& L% C$ ^0 B$ H
else {+ G: Q' n3 Q8 y
yPos = yPos;; N7 C% h; T4 ?
}
8 }. }$ T! W' H8 h( f }
7 P5 Y5 y' m9 j" `% C( U: o2 Y* t- E' ?7 {$ {
function hidetext(){
$ ?& P: x% U5 t4 u5 ^# _if (document.all)
: J0 a) k/ ]" l) hsupertext.style.visibility="hidden" S! @& q7 _, @
else if (document.layers)' I4 U5 {- }: ?* ~* R( }
document.supertext.visibility="hide"4 ]% V! @& l* u6 q5 F5 Q
clearTimeout(animatetext)) b% G6 x# V+ k+ e2 t
}
9 ^& v3 {) a) A1 h
7 e9 g4 o) f6 I+ y# F$ ~# sif (document.all||document.layers){
$ c, I; r7 X: r! }document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* ]+ v' R' c; Twindow.onload = initializeBall;3 S0 P: F. m F' I
window.onresize = new Function("window.location.reload()");
% L* J) ~% Y) |8 r}
. x2 d5 \- a0 t }$ f' v
. E% ?1 E+ c# |! ]$ g$ b</script> |
|