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

|
网页之不断弹射的文字-特效
<style type="text/css">
! ?( N" e. Q( y5 h) `3 s#supertext {
8 X/ x l$ ~7 N [- e8 h/ zposition:absolute;9 U9 q) `, O4 z- Z- u) i
left:0;% c% C$ k6 \$ }
top:0;& ]: [, N& V4 ?
visibility:hide;
2 e+ [! i$ q& h- L% [visibility:hidden;
( Q# e% e! c& b* {6 _* F" h! q}2 a! q8 `0 g& |" @' W
</style>
% n3 g3 f+ B7 \& |8 d( H1 \, R<script language="JavaScript1.2">
. D7 I7 h1 E- q! L$ ?; A<!-- 改变下的字体的大小。颜色-->( u" s# W. r9 R# q
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) x$ ?0 ~$ r& ?! T0 d1 ]& @. hvar hidetimer='';
' N# g8 |% X, X3 G+ W! m1 c1 ]<!-- 改变下的弹跳速度-->
% e3 I( x7 ]1 j6 a9 i z0 mvar BallSpeed = 20;
' X* d4 K1 E9 Q2 t2 Rvar contentWidth;- K2 U1 k! b' s5 P% T1 o
var contentHeight;
5 q. ]2 w# }# A" W4 E0 s0 ^var maxBallSpeed = 50;
% {! c7 ?% ~" f8 F: I4 t
; Z: F- e8 T5 ~6 s7 T# d a0 l' N- K+ f+ ?" N
var xMax;0 k6 m. v( A/ W* T6 G7 T* S- \& s
var yMax;* x$ |+ o! ~/ S, t+ M9 B5 m) M5 I
var xPos = 0;
3 t1 S; j7 b3 |% gvar yPos = 0;
; L" _7 j9 n0 Y7 O; @9 U, bvar xDir = 'right';
0 t1 N$ x) o$ S$ z8 \; Q! qvar yDir = 'down';
1 p% k" Y) G3 M6 u6 V# }4 |var superballRunning = true;2 X3 J/ N! Y. a q( o
var tempBallSpeed;
$ E D# v6 e0 l* Qvar currentBallSrc;* G" V$ D9 b* a5 l; z, V
var newXDir;
+ Y0 l# Q" l. Q2 S( bvar newYDir;
" y( ]( l: d$ L4 j: M# _9 ?
9 m/ r3 \ z) {# }function initializeBall() {6 J8 P* |% X% i9 D- i8 Z+ Q8 @
if (document.all) {) s0 H/ c. [; ]# w: T
xMax = document.body.clientWidth
) I/ Z0 E# I0 ]9 \' ~/ M4 B yMax = document.body.clientHeight6 J0 O& D. m+ F y
document.all("supertext").style.visibility = "visible";
* a4 f {9 d1 m& M* C9 v2 \+ ] contentWidth=supertext.offsetWidth; t- D g% X2 F. z9 U
contentHeight=supertext.offsetHeight
) n$ A0 g; w. W6 r }
6 \! _) f! B, x; e# g& ?4 s" t else if (document.layers) {
. c& |" f) ?$ |( I. X& w* n xMax = window.innerWidth;! ]" S$ ^9 \" X/ `# l( L; u7 A( G
yMax = window.innerHeight;
5 F* X6 Z4 d4 _$ J) i9 g7 h contentWidth=document.supertext.document.width
- |( [ i/ t3 p% F3 o6 ] contentHeight=document.supertext.document.height6 J* @ M1 p, n q' [) F
document.layers["supertext"].visibility = "show";3 g; q5 |' N& T% }9 C, H. G
}: v( ]8 G2 R2 E6 J* A
setTimeout('moveBall()',400);$ ^$ U- D3 M% k9 J! {4 R/ x
if (hidetimer!='')
2 r' k* Z1 c, j' b/ D& J5 v setTimeout("hidetext()",hidetimer)$ {! T2 t6 H, E5 k6 [) n# O) {
}
. G) V# m- s) {8 ? Q( C& j7 U/ {6 O; \) M8 G8 K7 P) j
function moveBall() {
|; k& @9 I$ T if (superballRunning == true) {
J' b! @2 v# J4 F' M calculatePosition();" }' R' W( L4 [
if (document.all) {+ w2 }/ i T: ?8 }7 l" @
document.all("supertext").style.left = xPos + document.body.scrollLeft;8 E- h1 u, L9 D
document.all("supertext").style.top = yPos + document.body.scrollTop;
0 i, @1 a0 R4 ^; \- S/ H5 j }
& E* T1 G! A- m6 H/ T else if (document.layers) {, t* ?+ M2 h5 Y% y" G `
document.layers["supertext"].left = xPos + pageXOffset;
' ?$ \3 D |; ~( { A document.layers["supertext"].top = yPos + pageYOffset;& @7 q4 h1 [8 k, M/ q) |9 O
}2 \+ }/ G- G0 j
animatetext=setTimeout('moveBall()',20);
8 @5 x" P) ^. ^2 y' | }5 U- k1 A" r" M F. E
}! a/ Y& ~+ ?/ S& s* Q9 s; f
5 S6 Q% B7 {8 {5 wfunction calculatePosition() {
& X7 W* Y6 F, ^+ c6 L0 ~ if (xDir == "right") {
! ^& u. {3 i, ]$ ^$ L! k4 _ if (xPos > (xMax - contentWidth - BallSpeed)) {
, Y! ^9 J# A3 f; A xDir = "left";- w9 c3 B+ y6 p2 E
}1 I N- s9 U3 s" I' d; y9 p
}' h' }4 E6 F* o9 N' Q
else if (xDir == "left") {
- S. Z& R, i0 w if (xPos < (0 + BallSpeed)) {- t6 ? r7 j1 V8 L/ I) M
xDir = "right";
4 G6 o& v' _8 c* H! x: _. r }
1 S5 A7 P( I. R2 ~& I+ ] }
5 s& X6 |3 U _ if (yDir == "down") {- U( x6 O% d* ]3 L" ~
if (yPos > (yMax - contentHeight - BallSpeed)) {
, V) a2 J! {4 j3 u) g3 v" P( M yDir = "up";7 |' ]- f. D4 E5 [$ v) ]
}; O8 k, j" S2 |( r6 k
}
! g2 @- }( a( U/ u else if (yDir == "up") {
$ ~" w6 p0 I; P6 p if (yPos < (0 + BallSpeed)) {; {% W0 t" @% K% C4 _
yDir = "down";
3 r# {& ]$ S4 F0 k9 H5 t0 o }
. E3 |/ Z- e* t }
7 t: Y: T4 v& Z if (xDir == "right") { b+ S& l6 N( ?1 m+ p6 F6 u! x* C) n Z
xPos = xPos + BallSpeed;2 Z5 b7 g3 k" ]; ^; I3 C. R `
}
; Z- N; ?% E' \5 N) w* B1 u" J9 m else if (xDir == "left") {
% t1 }" |3 l& ^- i+ y. O xPos = xPos - BallSpeed;
5 i3 x2 p1 }$ B) h }
, E3 P, Z1 U0 l# M! Z else {! A0 k. ~# j/ D4 g- |5 X) j1 w
xPos = xPos;- x: Y3 S" D G( W/ ?
}6 W& F- p( e7 g- E' W- X1 ]( f
if (yDir == "down") {
8 ], V1 q; Y7 ^" H$ b yPos = yPos + BallSpeed;9 f, j d3 n! x8 t0 Z
} M% L& B) V: t1 O) G
else if (yDir == "up") {( s8 w. U5 R. t( h9 A) L2 j7 r
yPos = yPos - BallSpeed;7 T) E( K9 S# D2 ^ H! a
}
- }/ x+ C& Z5 N' P& F8 J$ Y else {2 f7 R4 Y0 n2 ?* c5 W5 Q* {) ]
yPos = yPos;
" T* F- i' Z4 ?! ` }+ g' ` r. W+ D6 Z7 E, S
}
& F1 L- {0 X) Z% O3 ~
& ^5 p) `$ G2 {function hidetext(){! Q$ S8 i7 O0 x3 }: K4 ~
if (document.all)2 U. k `- S4 D! e( U) s$ ?% V
supertext.style.visibility="hidden"
$ X1 Y! e8 U0 z2 {else if (document.layers)* _" r4 j9 K2 a+ R% U" y/ g
document.supertext.visibility="hide"' e! f$ \0 T$ N% u* y3 x7 r+ M
clearTimeout(animatetext)1 x3 d' r' y+ s J
}! W' _4 K' c$ c; e, D2 Q" }
3 e5 ^2 |& y7 rif (document.all||document.layers){
# h6 I( R; i2 O/ ]+ Sdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
: q# G- }: I1 q4 M* Dwindow.onload = initializeBall; d5 g, S" T T
window.onresize = new Function("window.location.reload()");, I1 s6 O& [- I3 H4 x
}
; m+ z/ C; W3 s/ j
g7 I1 N; U- U ^. A& j+ j; k/ t</script> |
|