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

|
网页之不断弹射的文字-特效
<style type="text/css">* n) }" J2 f2 ?; z4 ?
#supertext {
2 S7 A z' ]! Z' zposition:absolute;) c% x7 t& p+ M- e; f# K+ Q2 y
left:0;+ z0 A$ d: P, B4 E* [. }; \
top:0;. M6 `$ \2 n# R. `
visibility:hide;+ R9 @" o! E8 \- K9 m8 E
visibility:hidden;3 ~$ K& j/ R- Z( D
}
; W: O+ O& e. ]+ M0 W</style>
% _% y: H' P. H8 \9 P( V" x* }' ^<script language="JavaScript1.2">
u+ i# s: }) X6 A K<!-- 改变下的字体的大小。颜色-->
' z ]1 l8 q3 w4 x1 i( r: Wvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" B% W- M8 [2 B: H ]1 Pvar hidetimer='';
( r* }$ ]# M' I- o<!-- 改变下的弹跳速度-->
/ q, `" {2 m- ^var BallSpeed = 20;6 C4 [9 z7 n& D/ O
var contentWidth;
' Y* k. k. G$ i: c# L! ]7 v' m* R" p& Zvar contentHeight;, V6 N) ]- R) z3 g* I
var maxBallSpeed = 50;
. [6 K* C- G9 m7 Y8 l+ j3 z" z3 i7 d9 l$ j* s k# y
9 V B+ L- `- Gvar xMax;$ _' [4 s$ L! k! Z; ?
var yMax;
, P; h) R& v4 \' r2 a) e0 d; xvar xPos = 0;# h8 t4 G4 z2 ~) W* Y7 c' R5 d
var yPos = 0;* h" O7 m) [3 H, y! S5 Q
var xDir = 'right';
4 L6 ^9 t2 X: |- j( S& kvar yDir = 'down';$ u& e; `: A; y# ~" _$ U# c% S
var superballRunning = true;
7 v0 G. j) e: k% s# z" k' P$ B# ?var tempBallSpeed;# J ~) T" R0 ?9 G2 ~
var currentBallSrc;
4 N) _! _, Y: d5 Fvar newXDir;4 q: Q Q" S( e8 [# s
var newYDir;
4 U. P, j# Z$ @* z- p1 H. m" M9 T. P: U1 A3 C
function initializeBall() {
2 t3 d$ `8 T! x2 ]# N' { if (document.all) {4 e6 c" H/ c' Q& W# {! c/ k8 U
xMax = document.body.clientWidth
/ L) H& j* c0 }' h6 |( b0 x( V yMax = document.body.clientHeight
5 N: T4 O m* w0 V document.all("supertext").style.visibility = "visible";; q O5 U) p4 J) H
contentWidth=supertext.offsetWidth6 W2 w" H* s, x0 E" a+ u
contentHeight=supertext.offsetHeight* _5 w; f* f( {4 S
}! w7 k9 F+ E* y! K& a! l7 O4 Q: r9 c
else if (document.layers) {' s5 n2 s7 I: ?$ E& e. \" {/ W
xMax = window.innerWidth;$ J6 y7 s9 ?1 Q$ n7 J# Y& o$ M
yMax = window.innerHeight;
7 M8 ^) x3 T! o' }# u7 N; e( [ contentWidth=document.supertext.document.width
+ J* M1 i9 i, W- `4 d& j9 P+ r% s contentHeight=document.supertext.document.height
. W8 m- G0 G# @6 R document.layers["supertext"].visibility = "show";7 f4 K& i$ y; o, x/ C! ]( @
}
* L3 f, [2 h9 H setTimeout('moveBall()',400);
1 j+ y. t& F6 w$ C. I if (hidetimer!='')
2 z9 |% Z9 o; S. H. a8 } }8 m setTimeout("hidetext()",hidetimer)
4 a$ }& S B* P }
. f3 B! m) E2 S3 S! o6 Y3 f7 m2 Y" u
function moveBall() {
! _0 g/ V6 _- n5 d- Q if (superballRunning == true) {
% J6 ^4 x& `7 j# J calculatePosition();
+ p$ w5 V" J* i1 H7 g! A% s1 G if (document.all) {/ T- r' \+ u8 G( ?. J, L
document.all("supertext").style.left = xPos + document.body.scrollLeft;
q0 r% m; ~4 e* u5 Z document.all("supertext").style.top = yPos + document.body.scrollTop;4 W/ |9 j8 C3 j5 f4 @; t- g9 s5 L
}
8 s R5 p$ v9 A6 F0 B% W else if (document.layers) {
: i p, Z9 ?8 O4 w% { document.layers["supertext"].left = xPos + pageXOffset;
5 B! v1 h$ E6 a0 t' u; r" I document.layers["supertext"].top = yPos + pageYOffset;- x6 c2 ^- P, F
}
% n+ S/ O( M" d9 g animatetext=setTimeout('moveBall()',20);
+ k! y0 ~, G4 K9 n }" w) G" U9 E. a7 Z+ Y
}/ _# S6 {7 d# U( i! n. q
$ |3 [# N# q/ ? c# r: z
function calculatePosition() {
& D% z- _7 K0 q) N if (xDir == "right") {2 Y. T3 t* [2 X0 I6 r/ o
if (xPos > (xMax - contentWidth - BallSpeed)) {
4 |4 j# W; a( T8 W& c xDir = "left";$ s; _+ B4 _8 y7 k- T
}
: ~2 Y G' ]- j1 G b3 C( l }: p3 H$ S7 N; x- m$ N3 M3 u. }
else if (xDir == "left") {- s/ }" \& E$ w
if (xPos < (0 + BallSpeed)) {* a/ ?' A0 W1 _4 i$ ]- C
xDir = "right";7 N* }- x j4 b, |2 T
}
# i1 G7 a* Q, y }) P- h* s$ |5 v- }
if (yDir == "down") {9 Z( L/ e3 r7 @ P
if (yPos > (yMax - contentHeight - BallSpeed)) {
4 f$ ~5 Z, o9 R9 u yDir = "up";
8 j- m, e0 h' Z) } }
4 y! ?( `) i* ]2 C }
! w* D7 S* P) X& @" d/ k& y else if (yDir == "up") {
8 V/ D6 b. p- Y, F/ s$ k! R5 Z9 | if (yPos < (0 + BallSpeed)) {, D# E3 i2 a1 n/ p% C) _& x
yDir = "down";
, M4 P+ `' ^. x. R }. \- q3 B% y5 Y# b
}- I" k s7 z2 }! A' i" q
if (xDir == "right") {
1 G, X4 _! V& ~. A% p. g ?0 h9 D xPos = xPos + BallSpeed;
( @: T! g# H! M, n- H }) E/ }2 q8 m' v) @$ s: [8 q
else if (xDir == "left") {( m. w. k7 Z% |5 b
xPos = xPos - BallSpeed;: d) @: m* t5 b" `
}: J/ r) \9 A. a% T
else {
C2 f% c6 R- g& G. Z' r# i xPos = xPos;1 L9 q( r2 m# c7 @) U* H K
} f! D! d+ P8 u8 P* M1 p
if (yDir == "down") {
* F: S4 i8 S- l3 v4 B6 X5 y$ g% _. b yPos = yPos + BallSpeed;9 A4 C5 M! c% Y% _( L# m; T
}
: b( M2 ~; y4 W+ i9 u else if (yDir == "up") {. W, W4 O3 P' c4 g
yPos = yPos - BallSpeed;
) Z+ `; N+ Z5 g. i+ v3 | }
0 o8 T) N+ L: d+ `9 Y% `+ o else {
$ I- X( A, O4 x- `. n yPos = yPos;& i9 Q+ {# C8 R1 w; ~0 L! Z% U
}0 n& e$ U- W* G2 q3 u1 K4 O
}9 w( D. o1 b7 i& e: t9 F, d! m9 N
0 o5 D8 v$ W0 xfunction hidetext(){/ n; f. R6 E% J! L
if (document.all)
) `! ]" x* ~: q/ j, @5 esupertext.style.visibility="hidden". ^- u; g7 \% }1 E: Z \) R
else if (document.layers)
4 M! u8 ^* ~2 F' q odocument.supertext.visibility="hide"
9 U7 ?6 @8 E& W4 KclearTimeout(animatetext)" R. H6 f2 H: {' Q
}
0 R! m6 a; _) I( i3 o. p5 h B% ^3 ~% Y) D- l7 i3 O( [, v+ a9 X
if (document.all||document.layers){& [ t: k, Y* c
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 J5 W+ q) p: T9 j
window.onload = initializeBall;+ @& D) B: U4 e" ~1 f, Y: A9 F
window.onresize = new Function("window.location.reload()");, ~4 i( ~$ j) {5 O4 Y) u
}
* y! Y2 d: u" ?% Q0 t" [
# ^1 N2 Q/ T/ N& u. S' s. g/ T</script> |
|