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

|
网页之不断弹射的文字-特效
<style type="text/css">' y( z8 Y' J1 f
#supertext {
: D1 W. x) ]- n9 N* U$ c. A9 wposition:absolute;) p+ z& m+ k8 g$ _8 Y& I- t
left:0;6 l7 f) b' `1 N: |$ L9 h3 i
top:0;
6 C: B \9 X/ U8 Jvisibility:hide;& V: D \& f) k3 N- e7 o
visibility:hidden;
- u' c3 S! B& C, e- L6 `}
7 U9 \6 ^+ K$ L6 T$ a: @8 J! f</style>
* O- i/ B+ k" V4 e! s<script language="JavaScript1.2">! E; a3 V; F+ H2 ]4 o5 o) m
<!-- 改变下的字体的大小。颜色-->
! ?1 G6 r* ^; d6 i- O& Ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', S/ a H0 q" I/ W; I
var hidetimer='';9 t: d. O. @( d; N8 E
<!-- 改变下的弹跳速度-->
* ^3 I& X& S0 N/ M; v7 a6 s3 }; Kvar BallSpeed = 20;" T* F. J. `: L
var contentWidth;) \, k+ u# n; p; g2 y0 O9 R# F
var contentHeight;
: V' I# B4 L/ yvar maxBallSpeed = 50;9 R5 ~: j& q2 { N& A
1 s+ y8 ~2 @- t2 [. Y, @. ~3 L x
. o+ [* j& Z$ h8 z( nvar xMax;4 k( Y# ]1 t: y* L# O4 m
var yMax;
4 `, X6 u# b9 F5 V! Q3 svar xPos = 0;( r0 F0 F8 R+ ?0 Z6 h$ y; j* Z/ ]2 ^
var yPos = 0;
9 D, N4 r3 V, e4 |" X* d0 `% w8 {var xDir = 'right';! j8 m8 m6 V# R. A& g( f
var yDir = 'down';5 m3 a# C- s+ q6 f: p, L. v
var superballRunning = true;# W1 S1 Y' I' y! x1 x& S- |/ k
var tempBallSpeed;
( s9 Y' Z! H4 Rvar currentBallSrc;- b5 I3 j8 }" m9 h! L
var newXDir;- G# u1 `) c3 V
var newYDir;9 \+ }- j9 T4 g. w5 S6 [" g& T7 r9 n
: u' ?- k2 z1 L" c: W; sfunction initializeBall() {7 b4 h+ ?. {: F" D( G6 n
if (document.all) {
! Q6 o5 j1 B- _5 C5 C- t xMax = document.body.clientWidth
6 ?5 g" a x6 [. L% I- l yMax = document.body.clientHeight
# ~* s$ S5 Z7 Z9 Z document.all("supertext").style.visibility = "visible";1 {% _+ J) y$ R" ? s9 S
contentWidth=supertext.offsetWidth3 O/ Y0 D4 H- `+ ^( T1 h, k' j
contentHeight=supertext.offsetHeight
0 W$ K" }0 a5 O z$ |3 l }9 [/ O) k% G( R0 m( ~* w6 h/ V& J
else if (document.layers) {" \; @* [# [9 y# k
xMax = window.innerWidth;
8 \( B4 {* @' ^( D1 {* t yMax = window.innerHeight;* U+ p% q2 i- O# T
contentWidth=document.supertext.document.width: e5 M* \+ |! F, d" f
contentHeight=document.supertext.document.height! n$ i$ d6 d: w! T. T1 k" m
document.layers["supertext"].visibility = "show";
3 S( z9 a' m' @/ p) Q) } }
% F3 g4 B$ R) ?! F9 ?# x setTimeout('moveBall()',400);4 d0 X* H5 T9 g/ c* Z0 h
if (hidetimer!='')7 x% ~$ ?4 d+ q9 l8 W
setTimeout("hidetext()",hidetimer)& O1 f7 z$ T e2 y; B
}
+ S( K/ X/ {/ F) Q% T0 n
) ~: z5 K" B( M# v) D! P' o3 ^function moveBall() {
2 U- E1 h' Q7 G; Y. { if (superballRunning == true) {' P3 V; J0 z- B6 a% Q
calculatePosition();& y! }; j6 v7 m9 \; t/ ~0 v3 w$ M" B
if (document.all) {: @5 p' ~$ H) k
document.all("supertext").style.left = xPos + document.body.scrollLeft;! z+ _/ R3 H" X8 s$ R# S
document.all("supertext").style.top = yPos + document.body.scrollTop;$ s2 |7 q6 T, b9 Y$ c, y6 K$ i
}
9 U, m, I9 i- S( V9 | else if (document.layers) {
9 E% E7 l! B% K' N document.layers["supertext"].left = xPos + pageXOffset;/ U& k, N! N2 U' y( N
document.layers["supertext"].top = yPos + pageYOffset;
% k9 U0 d+ s/ X! b3 L }
; V1 J4 o& @0 L' ^, b _0 k animatetext=setTimeout('moveBall()',20);; V5 O3 p: U5 H" N3 ]
}
3 k) i) l7 T! I, H, s3 j }$ V" [9 D E6 n2 y& ?. o6 ]/ G
, x. \$ m9 K* ]8 Z% b8 w# U- r
function calculatePosition() {
/ X8 Z4 n, }: s4 i if (xDir == "right") {% C" B4 p7 S# }& f
if (xPos > (xMax - contentWidth - BallSpeed)) {5 n; A8 P$ q9 ^7 ~& q% E
xDir = "left";
6 G8 h! e; X; q. T4 J% z7 | }' g% ~4 k/ `( [* u: J
}
& @4 P1 D; k, i! c$ [ else if (xDir == "left") {0 D. V' i0 V' g# ~+ a8 ?0 V: U9 s- J
if (xPos < (0 + BallSpeed)) {# n+ N: e) m R: f& ~& y
xDir = "right";
6 c9 L6 g& ]$ O1 s, e }: r; y2 K, {. i) q' p" s' N6 [
}
I$ x g% d0 w" m- I if (yDir == "down") {
a$ U! X" P/ F# r4 D4 v- v* V if (yPos > (yMax - contentHeight - BallSpeed)) {2 U4 R% b7 ~) u$ r% x2 u% O
yDir = "up";
+ j; V+ J3 e( q8 S }, R" I R0 Q x$ _' O k3 ^
}/ `7 l+ _3 ]0 N: ?
else if (yDir == "up") {9 q. z' n) i# I8 u+ x/ Z
if (yPos < (0 + BallSpeed)) {
0 X6 Y) r2 n2 q G, Z: Z yDir = "down";
0 i; {1 L7 G$ q$ h7 ?( ]5 l v# T }
+ u9 |$ P( m; Z) S& ~1 n/ ? }
" m1 i! `7 R+ Q& C9 H' K4 h8 j6 e if (xDir == "right") {
- {6 D; A# `6 m, p xPos = xPos + BallSpeed;6 V' `1 @ c( O1 f
}
0 u( h4 h: F* S9 \ else if (xDir == "left") {' i) v' M# }0 n, y2 x/ Q Z
xPos = xPos - BallSpeed;( a: f9 P) |/ R* {* X+ D6 K
}
! Y. C( k: {% E1 k else {$ F! V7 m6 E6 p' T
xPos = xPos;% W$ i N" ~' h6 ?* u2 e! |
}' A+ o6 \0 J( F' |* ]
if (yDir == "down") {
3 t: r/ {, l w3 k9 M1 U$ ^# ~0 B yPos = yPos + BallSpeed;
0 }) Q$ @( z7 u! Z2 H5 _ A' U }
) C. J* Y& G! q- R else if (yDir == "up") {
2 F: t3 U/ G: ^2 z yPos = yPos - BallSpeed;. L" n4 e) P6 P
}- }& W' v1 s3 g& I
else {# F2 I' `/ l- B+ {
yPos = yPos;
# Z/ J4 O8 G: N* O }0 m# k" w+ y2 c0 V0 Z. V. v
}8 G( p8 K6 W6 G9 N7 `! C. p
' @7 c# Z; {8 m( y& O. xfunction hidetext(){: ^# n0 K9 s, W2 [1 }4 X
if (document.all)
" }2 R0 n9 o: L! A$ @$ Osupertext.style.visibility="hidden"- R) ^& ]$ s+ ?' P8 S& G
else if (document.layers)/ }) _7 R2 m( F0 K( a) q
document.supertext.visibility="hide"
+ e0 ]6 D/ U4 f+ S2 eclearTimeout(animatetext)# T* E, w) s$ V" s+ r( @3 u
}
/ ?5 f9 b/ n4 |. f6 | G8 Q+ j* f0 H% [8 L+ B5 Z
if (document.all||document.layers){6 C# y& U9 K7 k' N0 }0 F
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! I, K- z) a0 U- N/ y6 Y4 D* B: ywindow.onload = initializeBall;
5 \% Q" \ @" qwindow.onresize = new Function("window.location.reload()");
: p h0 z* x2 p. p- [* a}
' ~5 q4 i; t9 X0 B* V" W; \; C2 `/ b
</script> |
|