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

|
网页之不断弹射的文字-特效
<style type="text/css">0 A4 ?% _) g. h& Z
#supertext {
' E" j* ?& t! A+ V: A) Y2 Y; iposition:absolute; V6 \2 O# H" V& W0 f- o
left:0;4 ^$ N/ j0 C/ F2 Q7 a
top:0;2 @* o& F( ]* i3 q" _9 p
visibility:hide;" D% I( p: ]0 n7 l# J S- W
visibility:hidden;8 F9 F# J4 S! Z2 R7 ^7 n
}
3 N, p0 T, S1 X, {1 x; ?. |</style>
- K% r. J. f$ {<script language="JavaScript1.2">9 g- q( B# K1 @
<!-- 改变下的字体的大小。颜色-->
; h8 l! P" |# q6 k& e& Yvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'" u6 f( S: F7 T* T- x
var hidetimer='';3 A; f8 z) s0 w' S& ^
<!-- 改变下的弹跳速度-->/ d0 Q: g+ W8 u9 ]
var BallSpeed = 20;, H1 O6 v. f. O# |1 B6 a% Z5 g5 A
var contentWidth;. l; n' ~+ V V, Z
var contentHeight;& w5 F7 ]( o F6 f6 F
var maxBallSpeed = 50; v& d4 L* d: ]$ G$ N' v. N
, Y1 q2 W: x2 W( v. g1 |- A
4 W9 i [0 u4 }0 ~4 Zvar xMax;/ p$ V0 f, X* Z; K5 H8 @( o7 y
var yMax;1 U$ g6 S, x# z
var xPos = 0;
# L1 W* G7 ^% C Y" x5 Fvar yPos = 0;
+ C3 }. @/ d9 A% W& ?7 c7 Gvar xDir = 'right';
( r0 B4 Y% q; o2 t& F N; w- }! ?var yDir = 'down';
. {2 o3 r# n7 ~9 `7 v5 C9 lvar superballRunning = true;8 p0 O. G) V3 x5 q. u! W6 s
var tempBallSpeed;8 ? p# l% J" ]/ I) _2 {
var currentBallSrc;2 H' I# S B* C. @
var newXDir;" `8 g# ^) B6 E. V/ P5 ]8 _
var newYDir;
# j" c: l( ~+ o! @3 C
; H9 D0 [/ t, R8 C/ jfunction initializeBall() {
6 @. E( ]: [/ H, ? |- i if (document.all) {6 [: Q/ [# e( H" b5 w- D
xMax = document.body.clientWidth9 ]; V, I8 ]0 {+ V
yMax = document.body.clientHeight
3 t7 F$ X; _8 h9 b7 P+ G document.all("supertext").style.visibility = "visible";% A7 t- [% F( R8 D3 k
contentWidth=supertext.offsetWidth
7 j" W7 D( g0 x3 M contentHeight=supertext.offsetHeight
8 C5 g. y9 k L0 s5 ? }
' G+ e+ y! N! G/ K else if (document.layers) {
, U) E# C$ Y ~" B; p4 L4 H xMax = window.innerWidth;
# N; c# ~' f4 ?+ p yMax = window.innerHeight;% K$ x4 w+ d! E. T V5 A$ z2 c1 ?& \
contentWidth=document.supertext.document.width
f: ]% Y! {! |/ @4 V7 P3 X contentHeight=document.supertext.document.height
/ F5 ~* j6 [+ N, e& w( q document.layers["supertext"].visibility = "show";
$ d0 D& [ ~' S1 k; f) L }
# [6 y. _: r* U' N8 H a4 y& b P' _) F setTimeout('moveBall()',400);* l' G0 t9 D8 M- d4 H- l
if (hidetimer!='')$ w! f6 t& e7 F2 R" b; F
setTimeout("hidetext()",hidetimer)
K4 a+ ]/ U& v& h' {; v }# I. e8 z& W* D; |: ^
0 }9 Q3 l; n0 }/ kfunction moveBall() {
# y6 I& V5 z) j. \+ `# \ if (superballRunning == true) {
7 S* Z: x$ L$ ^! U) N, Z calculatePosition();. H+ _1 r' e- K& p
if (document.all) {8 p/ q/ i1 m: X+ h8 t8 b9 }3 i
document.all("supertext").style.left = xPos + document.body.scrollLeft;/ c" O3 \3 O4 R5 b3 e
document.all("supertext").style.top = yPos + document.body.scrollTop;3 ], r+ R/ j7 k+ w! k
}
" _, Q: a* Y) A6 v; @ else if (document.layers) {
4 { K: L4 @9 q. c document.layers["supertext"].left = xPos + pageXOffset;
, T9 V8 _3 t+ q2 g) E+ J5 C document.layers["supertext"].top = yPos + pageYOffset;
; o( j; y1 r! q" S }
+ A1 y+ B6 x# b+ L6 i animatetext=setTimeout('moveBall()',20);1 f Q7 K' V' x$ t: q
}, Y' ?2 S; Q$ U* W1 a) V9 d6 J
}
I% G% K+ b4 m1 e1 i. ^: }& Z
1 c) Y3 P/ s3 [. pfunction calculatePosition() {4 i% z% a6 d/ B- y
if (xDir == "right") {
+ M1 ^9 M% b0 g" t& r% t* U5 ] if (xPos > (xMax - contentWidth - BallSpeed)) {
3 F7 `* L: M# _$ S' |" f; \! Z# } xDir = "left";* ~2 _# _8 T" ~0 M& b
}
& Q0 e1 c$ y1 V7 c+ y$ { } K G' ^& m8 ?
else if (xDir == "left") {! Q$ y7 a; F! C4 j6 X
if (xPos < (0 + BallSpeed)) {
2 x& m' A R) w$ m) G) G) o" _0 X xDir = "right";
: i; k8 c) Y l }
' ?' I0 @3 a& I2 D }& S# k& [3 N+ B6 a% ~4 Z, v
if (yDir == "down") {
& l7 k; t) ~- Q* s4 H+ j& r6 v if (yPos > (yMax - contentHeight - BallSpeed)) {# ?/ Q/ G0 C1 i! o/ D
yDir = "up";
5 u" U/ ]4 g0 D& b3 F# M! y }4 [ g; [) i. I: k/ u6 g, ]5 z4 ?
}
1 a4 J& b4 ^6 g# v! L else if (yDir == "up") {
0 [& f8 P" h/ e) V! k( E if (yPos < (0 + BallSpeed)) {! T% U* B' l8 [
yDir = "down";
2 I; Z) ]) I d$ U% C5 _ } U3 Z" |. U+ s' u) r
}
$ o y! k$ o" C1 a O if (xDir == "right") {* D) ]3 l- Y1 Q. K
xPos = xPos + BallSpeed;
- q6 x' F# w1 `- U% n1 r/ e. `3 x }
0 [0 K7 |3 Y. ] else if (xDir == "left") {$ {* b# ?8 j) l0 [
xPos = xPos - BallSpeed;
+ Q y: K) q" V" K! Y) } }1 C/ \" r8 N' Y) D
else {8 j: |2 z% j$ |% E
xPos = xPos;+ ^4 c9 v- }5 o& w" q0 H1 p( k
}. c# l$ f. L/ U6 J5 W- a2 Z. `
if (yDir == "down") {
5 K( Z# w6 [. x( f yPos = yPos + BallSpeed;" I( k ?! L+ H5 ^3 C3 V* y
}$ D5 `; L0 g/ C9 Q, L
else if (yDir == "up") {- [# S4 g0 h; n8 p+ W5 `% x+ W8 _
yPos = yPos - BallSpeed;
/ B, a- q, H) G$ ?1 @; u% s, h- l; a } s8 G5 D: V, t8 d1 g
else {' T' I- }# y, d6 L) e( e/ [
yPos = yPos;4 t$ t: D! N* P: C4 P3 u
}
- b' M$ @; ~; d8 X }% Y& P# ]6 p; D: Y, P- h
& Y3 y* ~4 D3 ~. Q, @
function hidetext(){: i+ `# v0 | d- T/ V8 _9 ~
if (document.all)
# h9 K8 U6 a) W9 Jsupertext.style.visibility="hidden"
( S9 w, i+ k/ W8 k. n5 r+ `4 C6 w' relse if (document.layers)
5 l/ V* e2 L- [& Cdocument.supertext.visibility="hide"
- @6 a( R3 R% U9 D8 s$ t# d: ?, KclearTimeout(animatetext)3 x1 B% K# u R! e
}
1 P+ ~+ ]- s ?: p, [2 p1 S! J3 g' g
if (document.all||document.layers){" P+ w' b9 R% A) n( o' ?
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')# C+ {9 R( @$ b& o4 l( w) u
window.onload = initializeBall;
5 r- Q/ y$ h6 B/ r' t& J1 u2 \window.onresize = new Function("window.location.reload()");# Y7 C2 z1 V9 R. U3 T3 D
}
4 M9 A9 h& K% j4 g, i4 U8 P
) k5 I$ z/ \/ Y: s2 Z( J/ h</script> |
|