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

|
网页之不断弹射的文字-特效
<style type="text/css">
9 g6 r: N7 W2 B( ?" U1 m* n2 `#supertext {
2 i# b0 x' @; M! E# _9 M+ Kposition:absolute;
) ?2 T" g: y8 w) f8 W$ ^left:0;3 Z, u5 p" a& F1 F) ^- q/ ]
top:0;
. z3 ^7 m, R$ y; fvisibility:hide;5 ?* N2 J0 b. b$ ?( P* x X
visibility:hidden;
4 @0 R/ @. x- H- S# ?4 w+ z}
& k K3 y w! f8 |</style>6 H4 d8 C( Y7 y
<script language="JavaScript1.2">
+ y0 A# h) i9 b( l7 W' e<!-- 改变下的字体的大小。颜色-->
% \! G4 M. ^" z% c! pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 t: b' i8 d9 c$ [3 O# Qvar hidetimer='';
4 D9 d( Z6 z) o. e$ c<!-- 改变下的弹跳速度-->
: V! r. c+ a9 y# evar BallSpeed = 20;
$ V8 y+ ]# G% _var contentWidth;
# c: b; _7 C) k" |- Z2 ?" fvar contentHeight;
4 [1 u& a( x# N2 Z& Mvar maxBallSpeed = 50;
* R2 M# H0 x: B4 l* ?5 z# O7 F/ Y. }. i7 ?
+ G4 h2 p, l: l ?: Qvar xMax;
& w) y3 [. ]/ q+ S2 n; ]var yMax;7 F4 A/ E9 e0 U1 r4 h7 V
var xPos = 0;/ F7 W e3 A. L' o, y" F
var yPos = 0;
) k( ?7 G5 J3 o$ D& o& [var xDir = 'right';5 b+ o9 P) f' i2 g/ c- j
var yDir = 'down';; B2 k" h$ h" ^- L9 P3 ~
var superballRunning = true;
5 n4 _! a% e0 S: ~var tempBallSpeed;
- ~/ I, ]! X6 M, Mvar currentBallSrc;
3 K! ^3 i1 e n; W3 k7 J+ Wvar newXDir;2 W% ~& s0 L2 Q( S
var newYDir;
- s: x! i* h9 [* d" d# y1 J1 G/ n7 p
: a! Q, Z, R/ U. Hfunction initializeBall() {# J. r* E+ Q9 ?2 `, D
if (document.all) {
/ V! a- X9 x9 e' q2 Q xMax = document.body.clientWidth
1 U3 _7 T$ Z" k! I* R+ N9 a yMax = document.body.clientHeight' F: H* j! }' C/ K0 Y; \
document.all("supertext").style.visibility = "visible";
7 u$ a6 P: @; @6 a2 }% s contentWidth=supertext.offsetWidth: { s" y& r* @$ ^
contentHeight=supertext.offsetHeight( Y$ Y* u2 U+ [' q. x$ A' P, M
}1 g- X4 p4 x& K; U
else if (document.layers) {. ]3 U( n4 u8 \( y; E/ o5 ?
xMax = window.innerWidth;3 r2 E5 h) k. q" | V! f' |
yMax = window.innerHeight;
" W; ~1 s+ f, ^5 r+ X! r0 T contentWidth=document.supertext.document.width& m/ H; `. i6 l4 l x: X
contentHeight=document.supertext.document.height
( D( `2 @+ w! O3 ] document.layers["supertext"].visibility = "show";5 d3 c: R6 ?/ t5 {. p n
}
( Z% b( b! o. N6 [! d setTimeout('moveBall()',400);* P |) J7 b4 |+ [/ a. y1 m
if (hidetimer!='')
R8 Q) \6 l( ]" ] C3 g, K1 e- C! } setTimeout("hidetext()",hidetimer)" _, ?8 ]3 k V; o( O. y* t
}3 k0 \4 A) }* d- J7 s7 c4 ? r
1 ^: X6 v1 A" e( E2 Bfunction moveBall() {
1 m. e2 m+ ~( I: A6 o h6 B: A if (superballRunning == true) {) {# C! W% { D+ k6 w
calculatePosition();: n ~( D) B4 _) A5 }5 P. s
if (document.all) {5 I/ |; T/ K* ]$ U8 F& X& s( I
document.all("supertext").style.left = xPos + document.body.scrollLeft;
# r# K. v; Z3 P$ \2 ]" i1 g# H) k document.all("supertext").style.top = yPos + document.body.scrollTop;2 w( b% T1 J6 s0 |, N! Z; w W- k
}; N- i; q9 n8 S6 y+ c5 V: w( g
else if (document.layers) {
, d/ y R9 \; X/ i8 p document.layers["supertext"].left = xPos + pageXOffset;3 u& A8 b& I7 @& m
document.layers["supertext"].top = yPos + pageYOffset;
5 v3 X) w4 H/ y- J9 p/ w+ ` } R$ o n/ F; T3 y4 E
animatetext=setTimeout('moveBall()',20);
2 |4 i' O7 [. w }! d* @# N4 }1 q+ G
}
% d$ K4 f; l: y' V( U. n E$ q- o8 ~8 O, I- Y. x
function calculatePosition() {. I4 j9 |8 E# ~- R8 [; r. H5 \% K
if (xDir == "right") {
. ~0 n- g4 C% |; E( A if (xPos > (xMax - contentWidth - BallSpeed)) {3 ~" Y% K5 n ~+ c) |
xDir = "left";
( e, H6 r% @, y+ y0 m. B) g }
1 @* i' I" S2 G# ` }
1 @8 U. J7 Z* j) X' p: L4 f! }8 ` else if (xDir == "left") {3 C: }, Y$ J$ A# [5 b' I, |
if (xPos < (0 + BallSpeed)) {& I, j, } e" h) Z
xDir = "right";3 }5 }7 M/ R g3 m
}
! Y! l4 ~% e3 i2 S' f }
3 O0 e" B/ f+ d# A+ R+ p: G* w if (yDir == "down") {
0 a( q+ \4 z0 X if (yPos > (yMax - contentHeight - BallSpeed)) {
( p" F! s) y) Q4 O- m6 ^6 g8 x yDir = "up";
2 W, M! k6 p& @2 f/ K2 U* n }
( H" ~* W4 k( C+ u6 f v }: U$ h$ X# p7 `5 ]( R: D6 l
else if (yDir == "up") {1 W9 r* G; \& W8 p
if (yPos < (0 + BallSpeed)) {
. j9 G5 c7 l- g5 p3 K( u5 G% q yDir = "down";
, w* S: s' `6 c X) C) S8 `* t# R) I3 E }4 g5 }9 C% ~! e" ~
}, C0 ?) E6 u# g( M, q1 s0 d8 A; \7 y
if (xDir == "right") { S& q; o5 @8 K* t9 t! M
xPos = xPos + BallSpeed;
2 b2 P; A% y: W }
9 N8 l" p# i5 S2 e else if (xDir == "left") {- T3 B0 q# j* P. u/ u1 G- x- Y" k4 l
xPos = xPos - BallSpeed;* J2 e U( s! q+ Q' x0 p
}9 u& b8 C z, D/ @2 g5 V* ~
else {# ^! q# y5 f: {
xPos = xPos;
0 b4 D& {* R( R5 d% C/ n& Q }
o: b- K% n1 x. Q) {4 y if (yDir == "down") {
) I' s0 a; ^% P& t# M yPos = yPos + BallSpeed;- x5 w0 G9 {7 h1 _5 N6 S5 X
}
0 X( ?2 q' {! L. I1 V: D4 r else if (yDir == "up") {! N, Z5 [" W, H7 A! k
yPos = yPos - BallSpeed;# C! ^' R- p/ X7 g4 u0 b- Y
}" z5 {6 k6 B% F, E& H. U0 [
else {9 F! h) F) w: n3 l: C
yPos = yPos;6 K( r3 d4 i/ D. _( ^$ V1 a ?. j. F& X& M
}
8 J+ F# `4 w# c1 m h% R) g: I$ E }. F0 L9 }8 ^9 T3 }+ B
0 g7 q% }( S. Y( I6 Z# `: f" K
function hidetext(){$ U7 U4 `# J) L; u. r7 S* R: x
if (document.all)9 v3 L0 {! Z, R! p/ M
supertext.style.visibility="hidden"
& \ E2 O) }8 I5 P [: k: f( B* ~else if (document.layers): T1 @; o: X0 U' p1 u- m+ M. u
document.supertext.visibility="hide"* N: D. S! ]- O; |* g- U$ w z
clearTimeout(animatetext)
5 s8 e! I$ h% r M3 U. ]) j8 `}& k4 {& D1 `- i9 A
" h9 s2 P) J# m! Y
if (document.all||document.layers){" B2 t4 O) u7 F( h+ \* T
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 H8 N' N- b& ^/ Y
window.onload = initializeBall;
. G& L/ w/ K0 C; i3 Q- mwindow.onresize = new Function("window.location.reload()");
0 s/ r0 A0 W, S' N; X J}9 E7 S0 t7 o( U1 [: K) f
/ J$ F# N* F; e& K O% h6 k% ]
</script> |
|