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

|
网页之不断弹射的文字-特效
<style type="text/css">
) P4 q1 y' I% c& y# ~+ F#supertext {
' J( P* F ^% O! U0 Bposition:absolute;
_ e' W4 ?* ?: o7 Rleft:0;: I- K1 L" L4 m. ~5 k
top:0;9 r' N7 V) a0 h8 p. I0 y* ^
visibility:hide;
$ A' q |, \& C, fvisibility:hidden;/ |4 C3 g3 p* A6 N; |3 v/ z
}) _' q* u# @% J1 F/ {7 K
</style>
( H" K: t- E7 y* }& J. y% S/ C( T<script language="JavaScript1.2">
* ?& Y5 ]' Y& b4 E7 w0 ~# p<!-- 改变下的字体的大小。颜色-->" y# L) h" y7 t/ C0 |
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'- K$ _" s5 K3 s: }) ~
var hidetimer='';
% Z+ E9 L. U0 m<!-- 改变下的弹跳速度-->: A1 S) h. h6 k7 B, j* d+ a, p
var BallSpeed = 20;
/ M! u3 s' G, pvar contentWidth;
8 Q" s! W0 H" ]var contentHeight;
4 m& x: U- k* a$ N: Dvar maxBallSpeed = 50;
/ q0 v* C' l' B. [4 O
' }! o* X$ ?% |$ \
7 G3 C, q9 h- w$ Zvar xMax;
6 l8 t, o: b1 kvar yMax;. e) X# w" M& @2 B9 y3 \
var xPos = 0;
6 T* w1 Q8 V4 C1 ~' g# ]3 ~% \var yPos = 0;
- K' h+ L* A k- k3 z8 x! ]var xDir = 'right';: Q1 v# X2 S+ E: l! n0 G
var yDir = 'down';
: t+ Q7 ]$ X5 m! h) k$ @var superballRunning = true;
% O& i7 f9 K- K* r: V1 xvar tempBallSpeed;
, x% {. l' I. {4 b1 gvar currentBallSrc;7 @: d! k7 \* H, W6 S
var newXDir;/ X3 u0 }& G" u) v* }) D$ I- v
var newYDir;
5 D$ m% q' S8 g9 d2 g b. o$ S8 ]/ C" c+ X$ y2 Q7 e
function initializeBall() {
. V, P0 {0 \3 r! K! F! u+ D if (document.all) {( Y9 Q. s6 I6 n6 a' r& O/ V
xMax = document.body.clientWidth5 t" H5 u) T1 ]7 d! O
yMax = document.body.clientHeight+ o4 q: J* J9 `# Q \# \+ R! R0 d9 I
document.all("supertext").style.visibility = "visible";, }( q: I _. {# u- S( J' `
contentWidth=supertext.offsetWidth0 a6 e* ?5 H: G
contentHeight=supertext.offsetHeight5 O. _0 D ?+ o/ j0 j. v% K& ~
}
! t! L8 I6 B5 D" w- v: R [ else if (document.layers) {
( C9 t* r6 X- r5 p7 n2 m' Y xMax = window.innerWidth;1 Y, b8 g6 {, F; U; e
yMax = window.innerHeight;
1 S3 o$ y- o9 j. X7 X8 g9 u contentWidth=document.supertext.document.width/ A- e$ U+ S2 h0 t6 j% O; W
contentHeight=document.supertext.document.height
, ^9 I+ f3 R, _4 m8 ^# p( d0 k document.layers["supertext"].visibility = "show";
1 N& {1 T# p: _: Z }) T' B _. k! p9 T
setTimeout('moveBall()',400);! m' w2 _1 O4 a2 K
if (hidetimer!='')
* b3 q- y$ `7 f2 u- k. W c setTimeout("hidetext()",hidetimer)' a2 }( a7 m; c8 f3 h3 n
}# e6 f8 j5 c( d2 E% I/ u
) R7 g! S$ y# \& n2 c; b
function moveBall() { q1 ?' K. V4 G2 z
if (superballRunning == true) {
( [; ^3 I0 M& g _6 M calculatePosition();5 q. K8 K {4 u1 Z7 O
if (document.all) {
- W1 b& o2 n" ], R document.all("supertext").style.left = xPos + document.body.scrollLeft;: s4 k4 s/ Y- O) n, p& K. F1 H; j6 I
document.all("supertext").style.top = yPos + document.body.scrollTop;
/ P- m1 Q! I- W/ T8 @1 m7 W. c( Z1 ~5 F }8 i& @7 Z" }8 s+ k5 S3 ~
else if (document.layers) {6 k/ U. y# E. ?! S9 }. W$ N
document.layers["supertext"].left = xPos + pageXOffset;. U5 c' Z* ]. E0 U
document.layers["supertext"].top = yPos + pageYOffset;
, J( K1 P. c- i( R2 ]/ ~ }
! A C9 Z. |) H7 `: m" ~* c" C animatetext=setTimeout('moveBall()',20);+ _" H; n7 u6 V! Y# p: q5 _
}
: B1 D8 q5 K) Y }
- ]( y1 d) a: a: | J& J* Y9 j! N" E N3 s5 N$ O$ H
function calculatePosition() {
& K& F6 b7 e# B" M3 [0 e0 F# D# z if (xDir == "right") {6 D0 j0 ]1 g" o! _7 y' W2 o! L
if (xPos > (xMax - contentWidth - BallSpeed)) {. o& n& b, }, ~% M" [2 F
xDir = "left";
: m0 M% b, [8 f* q1 k* C }
- C' y1 N7 V X- f! S! e$ C2 R }
( |6 p4 K$ E2 W: x; T! q" A else if (xDir == "left") {
0 Y8 {8 _ V& A if (xPos < (0 + BallSpeed)) {
4 r& T+ y0 H) O- }4 d xDir = "right";
! S( V. ^/ y7 c b+ O& [ }
1 A& C9 i/ U; r! s$ O% X# x }
7 J$ H' i7 c4 U/ A6 C if (yDir == "down") {$ D7 [4 ^; U* A
if (yPos > (yMax - contentHeight - BallSpeed)) {# y+ V" R% k, }* D
yDir = "up";
$ s3 J& N8 i8 k$ j }
- X' i8 g- B6 u* Y0 y9 B" Q }$ h2 {! n" \' Y, A. C& m8 N
else if (yDir == "up") {+ H+ k# O/ G% |1 r- F" g6 D8 Z' L' f
if (yPos < (0 + BallSpeed)) {8 {* y C3 k! |9 y
yDir = "down";3 c4 S5 W1 M8 o. \& g* j6 [
}, B g8 ?8 O; M6 c; Z
}
: D* D2 O1 }, Y6 b& X if (xDir == "right") {
3 d1 n+ C; l, a; I- \ xPos = xPos + BallSpeed;
) H0 R! B% y7 Y' y8 U }
# ^8 ^( u1 T& R! c0 ?% n1 y1 k else if (xDir == "left") {
$ H/ _( V1 U' w0 |4 ^3 N xPos = xPos - BallSpeed;7 w* e, n& @. ?: M. z1 d
}: c' m( [/ t3 h9 m5 g8 b
else {
5 p' G, {1 n% b, O* | xPos = xPos;
' r* ^1 U9 ]; o: T }
# m. x1 {- |+ [1 F5 @# q Y: V if (yDir == "down") {
3 ?) o% q! V+ f! r yPos = yPos + BallSpeed;8 G. a7 j& K. S4 x2 _8 `2 Y, \
}
3 j* h& e6 U4 E/ A+ h `' { else if (yDir == "up") {
# K. L6 M2 O+ k/ v$ a yPos = yPos - BallSpeed;) |, g! l5 G4 E6 x- G) u
}
T$ k% T! X- Z( d' @ else {- l2 T' ^3 x# }2 E3 e7 h: {
yPos = yPos;( z/ F+ C$ C7 U% |3 G
}& L8 `% z3 L" N% @" K9 T
}3 s( f; L, H- d2 l2 P
9 G5 e2 N# N" o3 D) M9 t f6 d: [
function hidetext(){
: e; s0 ^ \, @2 _% e+ C3 wif (document.all)
' ^, r# ?: R3 f) U7 V* [* D/ X" U1 Ksupertext.style.visibility="hidden"
. R& e2 Z4 }* a2 ?" o% X- velse if (document.layers)5 c+ K+ g# n4 }
document.supertext.visibility="hide"
& E* X3 J8 K" t8 ?clearTimeout(animatetext)% V5 y0 O m( U' T
}& T4 |" y& ]5 I$ p. v
. h2 f2 h, V0 n
if (document.all||document.layers){) E( o7 E1 H; O" ~. d) X, Y2 S9 s9 s
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')- E, J4 S) R( Y: a+ _ T
window.onload = initializeBall;: c; l6 N' i2 Y5 e! V
window.onresize = new Function("window.location.reload()");
- N5 K& k! R5 v7 d}
0 e% A2 X2 E( S/ x2 A. o. b5 x( A. L
</script> |
|