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

|
网页之不断弹射的文字-特效
<style type="text/css">
5 D! u6 x; B4 \8 |: _, _* x$ c#supertext {3 X2 B+ O9 U% J) i! r7 w5 i; N' W
position:absolute;
6 {1 E* A' g0 l4 ileft:0;
. h9 U( C. c2 X7 Itop:0;
, _6 a9 u* [5 a2 E( r8 Vvisibility:hide;
$ ]1 a6 I& h1 [; z: N) @0 v% E: D: wvisibility:hidden;& k' j, A9 b. {5 M5 V6 o
}3 f" ?1 d( t3 d
</style>7 g0 F% m# _) L0 S( Z1 l- U) T
<script language="JavaScript1.2">
- x( {- k4 {( q; ]7 h+ T C$ ]2 j<!-- 改变下的字体的大小。颜色--># A( ^4 O6 e; \( K1 ?
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', i4 c9 W- [- j G( g/ D& k+ Y! s9 y
var hidetimer='';
3 b4 G% u0 V2 x( F9 L: x; q# r' c<!-- 改变下的弹跳速度-->6 ]- r5 k* c9 f6 W0 Q
var BallSpeed = 20;0 T' b0 W% d8 _- W9 A
var contentWidth;9 Q# ]% R! r3 E7 |- N
var contentHeight;9 Z/ M# k, {- O7 |, G/ j
var maxBallSpeed = 50;1 |- r: N+ r) ?) R z
[3 x2 ]. Y8 L. E! U
( g, y. y, b: u% T) x; r( tvar xMax;2 n* c4 C- Y) y
var yMax;
4 I( B9 ]- p: ^- Ovar xPos = 0;& \# B, ^2 [( Y. _
var yPos = 0;
. L1 L' e& S: d5 a" j* svar xDir = 'right';6 {2 C J! M) G! W' [
var yDir = 'down';
( t$ u- I+ J: y6 r( V# {) k8 Jvar superballRunning = true;
1 ~/ F5 ]2 M7 F* ^3 h( `& Cvar tempBallSpeed;$ _% W5 F" h9 N: V
var currentBallSrc;
0 ]. E% s1 N6 ^1 A- Wvar newXDir;
- [0 `2 I2 I! G7 Zvar newYDir;
5 M8 Z$ l6 s$ x$ b9 L+ I5 i' P! ]+ E5 J, y! R( d( L
function initializeBall() {
2 M, C0 A; a0 N2 I! n. P+ P( { if (document.all) {, a- F: B/ }) W7 Z( e- ]% Q
xMax = document.body.clientWidth
' Q2 v2 k7 H& G! ?$ {4 q# E yMax = document.body.clientHeight5 s# M: x! X" j) [7 R
document.all("supertext").style.visibility = "visible";
. O' b- B. i7 @ contentWidth=supertext.offsetWidth3 H: D p- d; W$ f7 t
contentHeight=supertext.offsetHeight
$ j; Y2 Z# ?) k/ r4 F. n }
- i! s( k3 @+ i2 J0 t& |7 L5 u else if (document.layers) {
( y( I/ q0 A/ Z+ I% U3 f xMax = window.innerWidth;' B5 S+ o# [# a/ ~3 |( T
yMax = window.innerHeight;
x" v8 N4 M7 d0 E contentWidth=document.supertext.document.width
2 v2 t! i4 h/ x contentHeight=document.supertext.document.height! y1 n& n) r+ W' `# E" x/ _3 P
document.layers["supertext"].visibility = "show";$ m7 g0 Q6 N2 G# j3 y7 @; m% G
}
1 M3 @/ O! t5 x setTimeout('moveBall()',400);
8 o8 A6 v" ], X$ W if (hidetimer!='')3 b: e! W9 M* s% H2 A
setTimeout("hidetext()",hidetimer)( Z; I2 L7 H8 {$ N$ s
}0 Y3 p) A! \) {$ l+ c( ~/ v, m4 n
' m! ~6 C* A- `) ?2 i' ?function moveBall() {
! R1 s' W0 y( T" _3 r! _ if (superballRunning == true) {9 C$ k& ]7 [7 i" J9 z3 v8 C) @
calculatePosition();# `+ v1 q( [0 R' t- Q' S
if (document.all) {
% H5 U" T3 M; W" S9 j document.all("supertext").style.left = xPos + document.body.scrollLeft;
) _9 u! Y) a1 @0 O document.all("supertext").style.top = yPos + document.body.scrollTop;
: X3 I. g4 E% f }$ h% O% r0 m2 X2 o
else if (document.layers) {$ P' A. Z# }' P3 e z+ p( O
document.layers["supertext"].left = xPos + pageXOffset;
) m5 Y- v, f& W0 u3 b& `& D document.layers["supertext"].top = yPos + pageYOffset;* w( _- T& j3 ^, t& p* P
}
4 J0 J/ V6 B/ q& a. Z; G9 X. t animatetext=setTimeout('moveBall()',20);9 o. t. m- K' k2 o! ]
}" r3 G! A" f5 x t" h" e* K6 R
}
6 e+ k; _+ r2 W' _5 E) K7 V2 X& {4 t
function calculatePosition() {( |0 v0 s8 L# x
if (xDir == "right") {
& `: f( e. O' I* T& J6 [' ^ if (xPos > (xMax - contentWidth - BallSpeed)) {
( k1 h1 w# N# Y1 t xDir = "left";, i3 S7 d1 u$ n0 m' d g9 n6 f1 f
} A* z5 `6 G5 }. _" V
}
) {2 h; n3 F6 d& N: v" t5 z else if (xDir == "left") {, C4 U" \5 E: K! X
if (xPos < (0 + BallSpeed)) {" ^2 z# N$ x# U
xDir = "right";8 f' m2 c& `" ?, D) w, `
}
) }' j7 A+ u& v( I }. `6 _! W9 k; J1 g
if (yDir == "down") {0 d5 V4 A: B$ b$ i" a
if (yPos > (yMax - contentHeight - BallSpeed)) {
& Y# u0 n# m3 p1 z4 [+ G yDir = "up";
& u* w' D* o2 q/ ?2 Y/ e }
4 g9 i& p. @" U- M% \+ | }/ j: [7 w! g1 T$ }5 |
else if (yDir == "up") {/ z. d, @6 K$ q! I5 {1 e, ]
if (yPos < (0 + BallSpeed)) {
) }. V. b5 d5 ^7 a2 ` yDir = "down";0 e# s' O8 x6 n' ~$ [
}
# @& |& [% o* B F: {9 f# ~& n- d }
4 W F# G' S. B if (xDir == "right") {
, Y: O7 X1 s' K. Q c" Y# { xPos = xPos + BallSpeed;8 S2 B/ f# b+ B( P% s6 i
}
; l. F V f6 O else if (xDir == "left") {
$ W$ K& S [3 v+ R9 o( l( D5 k" q xPos = xPos - BallSpeed;# A7 P. I4 R) i; m* j D+ o; W$ e
}
R7 j* f) g) ]# P else {
9 b( |1 m& b4 ]' a0 F! A6 ] xPos = xPos;
- M9 O$ A* u8 K8 \( l2 D' K }
) \8 j' K# U: o% W; b if (yDir == "down") {
3 s3 d2 F, O& g yPos = yPos + BallSpeed;
' {( D/ u% S6 i$ s: l# t$ S }( E* R0 d8 v7 M) {& ?& `" P
else if (yDir == "up") {. i& J4 [+ |7 `$ p2 ]( J
yPos = yPos - BallSpeed;
( o! n F( c" R; R8 H9 J" m }9 F$ Y# V9 x) m4 N
else {9 o. D" K% W$ {% C8 }. x
yPos = yPos;/ m; I- M Q2 I
}
( T1 B3 |. [: L6 g$ r+ T3 u }
( L- F! R: s5 h9 B
2 W! O; `* s* P6 ]6 O X' ifunction hidetext(){
) o8 x- }: f4 o3 n& W5 l8 Y( M0 N! i9 Rif (document.all)
4 u8 Y( ?; S* x& d, ]supertext.style.visibility="hidden"/ Q+ Q4 b& o0 ^5 l7 ?
else if (document.layers)# a+ s* p2 F7 i7 i( H! b! D
document.supertext.visibility="hide"
; f( K- I/ G4 h+ ? gclearTimeout(animatetext)4 Z( b7 \4 L% b3 \( \
} Q: n m$ J" L% x5 A
( r4 S% _& z( C) S+ h' \0 v
if (document.all||document.layers){" j$ b! i* p# O* M5 r' x
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')* z r4 _ T3 `0 i9 |( a! e: D
window.onload = initializeBall;
& T# o! d* |3 B) K& X: Xwindow.onresize = new Function("window.location.reload()");
1 R, n% P# G% {6 I}
7 a0 f' x" e+ Z9 w1 |8 K
3 }) P3 ?( x8 P5 u' j</script> |
|