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

|
网页之不断弹射的文字-特效
<style type="text/css">
) Q& r8 ?/ j9 q6 @" d8 |- G#supertext {
" n7 M" y# D0 Xposition:absolute;
1 t8 D+ d. M, h7 m, ^2 O+ M/ v8 W# Mleft:0;
4 W0 s. w9 O0 ?! otop:0;
1 r. d; n2 x$ [ K& J; Vvisibility:hide;. l* `7 ?" p/ M
visibility:hidden;
* t+ m, ?6 Q& ^, P8 M! D}. H% E7 M0 r9 ?5 v6 g% |
</style>
2 i& |8 f) h* h: Z' `" N7 o. J<script language="JavaScript1.2">
: J; K9 w& w; e6 ~<!-- 改变下的字体的大小。颜色-->; o N, _& a& w+ M4 [# Z
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'" l7 ~, j) @! I( Q7 h9 k
var hidetimer='';" x+ i9 Y. o9 C. C1 B" }2 T
<!-- 改变下的弹跳速度-->
1 C9 ~: \" z) P0 S$ X& A& gvar BallSpeed = 20;
# l( a( C2 R& R j- avar contentWidth;
/ ~2 `" l) `1 l# lvar contentHeight;
2 N3 s# M7 L1 ?9 Qvar maxBallSpeed = 50;
- V( J" ]4 i; |6 x2 Y; S9 @# D# e. B( u7 o6 T; R+ P
4 h4 H- c& g9 k! y- z+ e4 h
var xMax;
4 s, a2 t9 j" s' D9 x% \var yMax;8 h8 s! {( l# V- u' G
var xPos = 0;
, ~/ @4 \8 }2 ?7 [var yPos = 0;
0 `: g. q( c/ } lvar xDir = 'right'; l. m0 G2 l/ d0 A6 y9 u# E7 e9 Z6 j* o
var yDir = 'down';% [' X: x( M* B. @2 J
var superballRunning = true;
. \( t' ~* F$ _1 F9 Xvar tempBallSpeed;
) P) s ?) Z& U3 _' zvar currentBallSrc;/ j6 U! L% e- Z: I7 B, x, l' ~" }
var newXDir;8 a+ n* C# q' o; k. J; W b: T
var newYDir;- t4 w+ m! j! i$ x" N9 N3 I( @
9 C" t( E+ S, m I8 Q2 L
function initializeBall() {
( S5 r1 V! e. L& X: X if (document.all) {
1 e2 a- N; z/ V2 S! S! g xMax = document.body.clientWidth
' y$ \0 ~! D I `+ k yMax = document.body.clientHeight
' g& L, Q; p7 C: H2 \) t document.all("supertext").style.visibility = "visible";
1 m; u; l" d% o2 F0 T" l contentWidth=supertext.offsetWidth; `* g' p, G- u% p
contentHeight=supertext.offsetHeight/ m/ i6 \# \6 V- b h
}
( ~! q, w+ |5 q4 |) \% Q else if (document.layers) {$ A& R/ R" E$ @. n. y! h% _ Y
xMax = window.innerWidth;
) ?) P0 l9 a2 E. P6 I$ H yMax = window.innerHeight;7 T6 v- U- ?/ \2 k U! W3 ^2 T
contentWidth=document.supertext.document.width2 h+ ]$ k9 N) r' t2 g+ V9 L
contentHeight=document.supertext.document.height
8 A0 Z! ]9 Z: {# R7 w) m document.layers["supertext"].visibility = "show";' L& _& S8 L) Y1 f, C) a4 O
}
) D+ w4 R' d; o: C" {2 x/ W( ] setTimeout('moveBall()',400);' z- P0 Z) ?5 N5 L
if (hidetimer!='')' m; j2 o; t( }# R a
setTimeout("hidetext()",hidetimer)
' Y: k- ^% _( U* [" m9 ]. l$ q* N }9 b6 R1 G O/ ]7 N
4 Y3 j7 S8 m9 ~" k9 g7 Gfunction moveBall() {
/ X* J. A7 `$ j3 C if (superballRunning == true) {, n% F5 x- t0 a" q, E
calculatePosition();' s3 ~% y( g: {5 s0 h8 Y
if (document.all) {
% Q5 }, `8 y) j u& T1 p3 X. @ document.all("supertext").style.left = xPos + document.body.scrollLeft;
# L$ o; A% S3 ^/ W6 g5 ]$ Q' b document.all("supertext").style.top = yPos + document.body.scrollTop;& Y- _% q9 K$ }7 Q" B* t
}
* J6 v4 h1 ?0 a3 Z+ U# M" E, h else if (document.layers) {5 |0 h2 \/ e' t( T+ V
document.layers["supertext"].left = xPos + pageXOffset;
) m4 X; u, _, j, _7 O% F | document.layers["supertext"].top = yPos + pageYOffset;" L5 r( w1 M( w# f* ~9 k
}& d/ ?% |0 ]* P
animatetext=setTimeout('moveBall()',20);8 }: x4 ^, x% y% V
}
3 q* p8 x! o) Q3 F4 B8 D( ` }" l/ I# y4 p3 l
9 [' V5 ]4 I" |5 yfunction calculatePosition() {1 I6 F% t T4 b$ f2 M7 [# u1 J" u5 S
if (xDir == "right") {9 \- u) e% q; y% [' n6 n
if (xPos > (xMax - contentWidth - BallSpeed)) {
& X7 Z- k( t- `4 ?- y xDir = "left";
/ z* _6 O& L9 {. v! ]7 j' m$ ~ }) N" k; q9 p2 q6 ]* g" \- T
}3 n( P" K& K# D- t
else if (xDir == "left") {6 e, H; w, t. ^: B$ F" a/ j- y
if (xPos < (0 + BallSpeed)) {4 T- N& L* E. P/ D9 {0 ]
xDir = "right";
9 _/ J* P% z7 t }
. u! i* G1 x& ?. R }5 \' K! D7 x' ~) |8 T
if (yDir == "down") {
: a) m \; r' a( Z% {7 Q' X, f if (yPos > (yMax - contentHeight - BallSpeed)) {
, a) v" p: J, Z. a5 e yDir = "up";
& |3 [7 U0 L7 ?2 J }
( m, ?! q8 l- T! v0 h }
# a4 u+ j6 G/ J, Q8 L else if (yDir == "up") {
5 G5 C- L1 |4 i% O* Q if (yPos < (0 + BallSpeed)) {
7 `6 j0 K$ h. m" P& I yDir = "down";
3 S5 J7 S3 ?! H- f7 a }
0 _! a4 p! l0 X( E# F9 m9 u2 r0 L }. u; x9 w+ g" p c; {) j
if (xDir == "right") {$ [. v8 V* A& f$ _) w6 ]* d3 c- W) p
xPos = xPos + BallSpeed;
4 m) Z u: H' Y( d! q" `# p }, t% T+ c. d9 q# E4 ?; n2 g
else if (xDir == "left") {+ \- f. U J9 [( ]3 m+ h( J+ v
xPos = xPos - BallSpeed;4 Y: a5 W7 v, h* h
}. z# [/ C9 `; A1 f( l1 ^7 e
else {
( d4 Q# C$ i7 R. K& K7 ~; _ xPos = xPos;
; O+ D n0 f$ f/ p/ }, N$ c }
7 q B2 Y2 M* e( Z if (yDir == "down") {
q2 P) N7 {, D ]3 q yPos = yPos + BallSpeed;
9 Y2 l" q# W4 Q Y! W" e }
. R7 L$ L/ E# a1 v0 g4 [" @ else if (yDir == "up") {. X9 N9 b r S; I
yPos = yPos - BallSpeed;
, e5 ~5 ?+ G) ^$ t0 z }- G; c6 [; W# G) U, }. }
else {
1 L+ \) p/ [0 S" r; ?8 c1 s yPos = yPos;
' @1 d. Y' T+ Y3 N" K }* w/ t3 o* [- H; ]6 g5 l
}
8 e3 u; U2 e& ]5 s5 i( [* l) t( ?, ^; {' Z6 ~9 i
function hidetext(){) s. M0 z! G8 ?* F g
if (document.all); ]4 p$ W, _+ \3 F
supertext.style.visibility="hidden"& F/ Z C, B4 ~, y$ x
else if (document.layers)- \. C3 O+ Q5 z, r
document.supertext.visibility="hide"
( K/ k- d1 _ GclearTimeout(animatetext)
0 H }2 _, s- G9 i/ Z. T}
# H7 @, p# M6 K d2 {! X9 B/ \
/ j. O) [0 u* n$ cif (document.all||document.layers){
; W( R. c) L- u) @document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
: U% y8 Q! i% \. G/ x. Wwindow.onload = initializeBall;1 H9 B2 x( J$ _
window.onresize = new Function("window.location.reload()");' l2 }7 O, b- D% y. d+ |
}
% y" _* w8 g) V' ?8 }% o8 d
: g( C* G6 L+ h) H; P9 ~1 y</script> |
|