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

|
网页之不断弹射的文字-特效
<style type="text/css">& `( o- j( _1 L& i3 ]; R
#supertext {" O6 b: K1 _+ ^7 h6 P* ?1 l5 v& b( Q! S
position:absolute;( a9 M7 g$ @. c
left:0;
% w A; g; H3 U" b1 Ftop:0;
6 Y* X) i. E+ y7 S Fvisibility:hide;8 f# p7 C) R8 {% J- n% b) v
visibility:hidden;
+ F$ ^ ^% N: Z}" o5 B/ L1 }& F1 |8 s3 {) ?5 S
</style>
, e2 ]* c* e: n) F E<script language="JavaScript1.2">
& l0 I, {: {5 @3 v& t: h6 `5 A<!-- 改变下的字体的大小。颜色-->! [9 m( r% s/ V; }
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
9 |/ @& Z- H# evar hidetimer='';
7 {" x8 ^) _/ n<!-- 改变下的弹跳速度-->& {6 ~7 \' `8 `, ^
var BallSpeed = 20;
: H" d1 ] ~3 `3 M$ K* @5 Hvar contentWidth;
$ J8 l- ?4 w& u; E6 s3 yvar contentHeight;
) ?* r) l! n5 \- l% a1 B2 Yvar maxBallSpeed = 50;9 o) X3 ?( N2 Q6 L% d# v6 p [
9 ^0 |2 T+ X: N$ }" s( w8 H' H2 q) N" `8 w7 {
var xMax;
* ?' ~. ]% ^' [0 l5 p$ E: v5 s0 ?var yMax;
5 F( V8 A. T% k& H- b* v* I6 |7 n( Q2 Fvar xPos = 0;* U9 \/ [" I" _
var yPos = 0;
: T% I: \" ^6 V, a' yvar xDir = 'right';
: ]' U' F2 a- [- Svar yDir = 'down';* f8 L7 k) L c( N4 x4 [/ F
var superballRunning = true;7 T. G3 M* O- m
var tempBallSpeed;6 s6 ?8 u: @# J/ Y8 h5 V4 `
var currentBallSrc;; n& Z0 V; d4 G
var newXDir;/ G: H7 Y G: z0 ~4 d2 ^6 \3 J
var newYDir;
8 D( s2 `8 l) ^& J
5 N+ G4 q/ m' }' w' X$ Qfunction initializeBall() {
' T$ u; `+ G3 r9 l2 h if (document.all) {* Z. k/ p/ P% H" U4 r3 g
xMax = document.body.clientWidth+ z) P& O" I. L
yMax = document.body.clientHeight) x5 m. m+ B H
document.all("supertext").style.visibility = "visible";) w5 m, z- }# s1 u* F
contentWidth=supertext.offsetWidth7 z6 D) m! U8 I' P B/ A7 e. e
contentHeight=supertext.offsetHeight
* {) s) J% C, h* j) L) x" l }
- S! Z0 i5 P( K3 W else if (document.layers) {
1 ]/ P5 p# u5 v. e7 {7 C$ [$ ?0 _. f! f% f xMax = window.innerWidth;) ]7 g9 v% y6 `8 i
yMax = window.innerHeight;& J, F; J! {4 v! m b1 u
contentWidth=document.supertext.document.width& c3 H, Z5 |; y; z
contentHeight=document.supertext.document.height0 z; N( Y+ B4 L
document.layers["supertext"].visibility = "show";: [# m4 |, Q' O3 z& J) T
}1 W! x* ^! j& p% g9 o, S3 d
setTimeout('moveBall()',400);
) S0 t% Q" \/ H0 P' j8 p if (hidetimer!='')& f, R6 N. g ^ \; C
setTimeout("hidetext()",hidetimer)
8 S. P7 a9 s- Y* k7 k# X }6 N" Z0 P! k# T {) M
. z7 y F3 o' Wfunction moveBall() {9 f# E, G5 [- ^! z) U
if (superballRunning == true) {
0 k& g' k, ~9 a4 I3 X K7 f calculatePosition();
! y; k% v5 U! R |) b if (document.all) {1 w1 K6 G# e: E! ?( C2 }
document.all("supertext").style.left = xPos + document.body.scrollLeft;8 M1 \' R& A% s; T7 p
document.all("supertext").style.top = yPos + document.body.scrollTop;
9 ?5 p) g' c# b' X5 Y }
6 o" d: m& z9 G, i# N- L9 a0 k0 w else if (document.layers) {
" b! @0 V% @( Q document.layers["supertext"].left = xPos + pageXOffset;
' {. ]+ T! b" h# i6 E" |: y document.layers["supertext"].top = yPos + pageYOffset;
9 w. [" I. Q; g5 F# B8 P }
5 s' T. u9 }' I# h2 T% K animatetext=setTimeout('moveBall()',20);, p* i$ Z% t1 {+ C2 n" v7 D
}
1 e1 x$ M8 H0 X& B! T }
5 d# f' o- P" [' o5 O B
0 c8 j' u6 T+ S6 G; C8 C+ [function calculatePosition() {( U5 g; g; l3 D5 _! v+ h2 v
if (xDir == "right") {
h& q! _' n) ]% k# X; _ if (xPos > (xMax - contentWidth - BallSpeed)) {
& v! Y5 h! Q$ X8 b$ t/ R xDir = "left";
1 M1 ~( C" F0 m: A/ e& u: C9 C* r }
+ l+ ?% C* ]" q, P* U4 Y0 P }
: o1 M% n* n6 @% ? else if (xDir == "left") {; A2 T" ]7 Y3 {5 q1 s' q
if (xPos < (0 + BallSpeed)) {2 A4 R w& M) \! O0 x
xDir = "right";; k1 {2 j7 \; u% }6 ?; P
}
' Y9 b1 c. v$ C; ^, J9 J/ V. v- h }
& @6 B5 e, g* q( s' X if (yDir == "down") {* Y+ F& \0 ^; }3 Z" |( l
if (yPos > (yMax - contentHeight - BallSpeed)) {/ T; [2 {( |7 v9 [6 t
yDir = "up";5 U Q' e" o5 }" k1 h' n
}6 ~# |; q9 E+ G4 K1 q
}
, q$ I j9 E, @; a else if (yDir == "up") { p9 p* P! g/ v9 y! w; {) b o
if (yPos < (0 + BallSpeed)) {
0 ]1 }( Z" j) _8 H7 W yDir = "down";
" N1 O) x6 `- f0 \ }
2 T; Q6 I2 G+ o0 @ } V% _8 |6 \1 ?
if (xDir == "right") {( x5 S- S- j! }9 F7 P
xPos = xPos + BallSpeed;& X. Q) `+ E' {6 ~& j# s9 J
}, T6 d+ f- A/ a, e
else if (xDir == "left") {0 U6 L) K9 x; y3 V* \
xPos = xPos - BallSpeed;
# n5 v' @5 D$ }& N6 v" V: t$ ^+ }4 c4 A }
`" Y! I, R( R4 Y! [. i else {' U) O) z$ y/ ?
xPos = xPos;& w9 U6 O: Y w0 e- w+ F
}
% j% E6 @, ]0 I% }+ l if (yDir == "down") {
1 J$ |$ ]. Q$ v( G' \7 _ yPos = yPos + BallSpeed;
H1 x. W, {) d' w9 ?" `- S }" V6 \0 g1 l& m7 k; _* V
else if (yDir == "up") {
+ X, x2 O' F# ?. ]( O7 D* g8 W yPos = yPos - BallSpeed;
/ s" Q, J- G [* _8 w; @5 ~' v. h T$ } }% C: l9 u6 y( x* g
else {
% E S' k5 Q, z/ Q9 q; T. ^2 T yPos = yPos;
3 v$ k4 M3 S' ^" Y: @5 e7 U }
* @* n$ P& _# F) p$ _! U) P/ j }8 g3 w. Y. E8 ?1 Y N7 M5 a
& s1 _+ ? x" r p
function hidetext(){. O3 j$ u3 R& J
if (document.all)3 }/ T* z- |3 a/ y% y4 z; }$ s
supertext.style.visibility="hidden") ?1 A) D; y$ o# d8 g; K, I; z; E
else if (document.layers)4 u7 P0 ]; i1 q# z
document.supertext.visibility="hide"
5 [% O! A0 u# @6 t" ]. O- z. qclearTimeout(animatetext)$ m- o$ f# U7 L8 }# x
}
) k- ]2 e0 d+ r0 ?. k, [/ _- c2 Y, T% |5 s- N; H ~
if (document.all||document.layers){( P+ j& S% Y' e# @
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')' x5 t+ ]( W3 o" d4 j
window.onload = initializeBall;' G! c: F3 f8 D
window.onresize = new Function("window.location.reload()");& D& w* M' O1 c8 _2 A" C
}) ]. s$ n8 o: T3 L. N+ O
5 A$ D/ a9 S r0 R) x g
</script> |
|