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

|
网页之不断弹射的文字-特效
<style type="text/css">
, u( L# }5 W" g* x: i#supertext {4 x8 x( o% h/ [: }1 k3 \3 }# N( i+ V/ n
position:absolute;
H2 W; R$ c7 p3 v" _) R( Zleft:0;
4 u$ R/ O# u0 \ f/ c& F# ntop:0;6 O8 p. a! \/ d/ G( O
visibility:hide;% L( R& v3 B, [- N- e3 k
visibility:hidden;
9 x' `* G, ^# i+ I' B5 A}
) q4 \* P+ Z! y7 C</style>2 x; a) i3 ]5 l; j
<script language="JavaScript1.2">0 M$ S$ }8 Q" Z+ p
<!-- 改变下的字体的大小。颜色-->- W3 [2 u: G6 z+ v' Y) x
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
+ [# b. i6 y% s: O+ ivar hidetimer='';! s. B0 F& ~. h* u8 W% r2 D
<!-- 改变下的弹跳速度-->* |7 J) x7 ?+ @9 w' n0 L% I
var BallSpeed = 20;
9 }' E6 m8 B# g. W( Zvar contentWidth;
9 N: _ [" k% f# |$ L, J2 Ivar contentHeight;8 @: V( c7 N: q3 d8 }& W' {4 p
var maxBallSpeed = 50;
! `2 R! z" w( w5 n( J$ a) e6 F
& Y& W/ X2 S0 a: L, X% W! f" X
3 V& A/ x, D3 A% q0 bvar xMax;: r: H* q, _+ o& d
var yMax;
, t$ d5 ~3 o) dvar xPos = 0;! \/ y$ S d9 i, W3 e
var yPos = 0;$ o+ t0 Y6 `2 B5 d: R5 }, U
var xDir = 'right';
1 y, Z+ d" k8 qvar yDir = 'down';/ l% H4 L1 h( J8 A
var superballRunning = true;
9 T. Z( p) i. w+ g( l9 u$ Rvar tempBallSpeed;3 K- a- L2 @% V7 Y0 t- E/ K# s
var currentBallSrc;
7 ^+ U5 q& m2 l J' A) g9 b" s4 T1 V$ hvar newXDir;) x! @- z, m( K( t$ S3 V
var newYDir;
" h1 ?) c6 E( n5 m z$ `! n
5 M$ O3 u9 e9 @0 E Qfunction initializeBall() {
; ?/ r, x) k/ t if (document.all) {6 `3 g9 ~7 J4 U9 s
xMax = document.body.clientWidth( M0 ~/ J( O' y
yMax = document.body.clientHeight
# J. `# n+ [! |+ [$ j document.all("supertext").style.visibility = "visible";) U& n# k% P7 Q
contentWidth=supertext.offsetWidth
* L! ? B/ x- `; m y2 C contentHeight=supertext.offsetHeight
2 p. h! C' A+ d2 b% j9 X }
$ B) V# ?% d5 P& H else if (document.layers) {
1 x9 ^( L- d' o, ?; n6 R xMax = window.innerWidth;( S" \, t4 y9 `6 }: A
yMax = window.innerHeight;
% q% _7 s7 Y% F8 P) Y+ ? g contentWidth=document.supertext.document.width
: D! {4 w5 T3 t) _7 f8 t. V6 I0 @ contentHeight=document.supertext.document.height' w1 J4 u* l! k% x$ O
document.layers["supertext"].visibility = "show";0 ]8 h8 `# y1 t1 | d, z! s4 y
}$ n5 ]7 I% o G+ z
setTimeout('moveBall()',400);
& _. H9 U# o' O) E+ E if (hidetimer!='')! \% k/ Q$ K+ ?. _( [* D3 l
setTimeout("hidetext()",hidetimer)
1 U( E6 C& o- E" a% N }9 |& i0 U! F* B6 |1 K- b
+ e; x6 B9 L& s3 E, s6 g- d" d
function moveBall() {
2 i; \1 q% X4 D `# W2 |# k- n if (superballRunning == true) {! O( ~4 C9 Y6 K$ [
calculatePosition();
) c4 _! L# d) P/ O; h, B9 J if (document.all) {
; F% x2 \. ^* \& R8 N document.all("supertext").style.left = xPos + document.body.scrollLeft;
. \0 K% R8 u+ ]! K document.all("supertext").style.top = yPos + document.body.scrollTop;- G6 B8 Q0 }; t* K$ o5 A- l3 \/ R
}
5 i ~: ?: P) S; ` { else if (document.layers) {: n3 y" P3 {- F3 l; n8 o5 `
document.layers["supertext"].left = xPos + pageXOffset;
, h: B9 K {- {! R' f' G) F- U document.layers["supertext"].top = yPos + pageYOffset;
2 w6 `$ J( Z: Q3 q9 u/ E" ^# V7 Q }
9 |; x. l4 s+ n animatetext=setTimeout('moveBall()',20);- ^& }! ~8 x3 m. m, g
}7 }& K/ I. Z$ w5 d' r6 K* V4 ]
}
2 O! {7 L2 L. @ {
& ]6 p+ t4 ^! u& v0 @% jfunction calculatePosition() {
9 N( Y0 S& a" Z$ u9 C if (xDir == "right") {
$ g# D# z; C# F% O# }% y* z( N if (xPos > (xMax - contentWidth - BallSpeed)) {; _9 a0 K" e. Z1 I7 y/ `* s1 K
xDir = "left";3 M/ N& A! E5 Q/ L$ p
}
& X- H; ~' n _2 j$ w: }. i }# N# B' K. p, ? x. ?& I3 V; @( F. z
else if (xDir == "left") {
* Q1 i1 I$ @0 k if (xPos < (0 + BallSpeed)) {
8 f, I3 d* C9 | xDir = "right";' I' W% K; ~& n. \4 d8 @
}, \ p$ \% P2 G7 h; ^
}, T2 Q4 G1 T& U4 k) r
if (yDir == "down") {8 l' B! a h& m% l7 o' r4 {( G
if (yPos > (yMax - contentHeight - BallSpeed)) {
9 m" H( z/ w7 N, d yDir = "up";
. U0 t9 @2 y) v1 f4 R5 f6 ~ }' X; M2 w, t8 a- f: B) Z, H
}
, z e2 n/ l7 C else if (yDir == "up") {2 W5 _* j4 x* S$ Q
if (yPos < (0 + BallSpeed)) {! A3 w! M5 L! f0 O' D
yDir = "down";; H5 D- J W p& r$ G9 W( F
}5 n8 s1 |3 j7 `2 _9 U/ B
}( H- L6 U1 u9 w) H
if (xDir == "right") {
) B& Z: P0 i* H xPos = xPos + BallSpeed;4 w K& {) s T6 I! S$ o
}# J8 a3 D* Z) r( O& R( F4 t
else if (xDir == "left") {: y" z- Y0 J$ C( I% e! J
xPos = xPos - BallSpeed;+ R$ s) O2 L. ?7 Y" w* C7 A
}* w# Y p1 R' `: }% x
else {
9 {' t3 n) w) ] xPos = xPos;' R4 z! o7 s2 [% V# ?: ? m
}$ D- J* A q# ]+ C5 N9 }( v4 t
if (yDir == "down") {
6 S! L7 {2 z6 t5 y& g. o2 Y yPos = yPos + BallSpeed;$ D. T& E2 e) n/ A8 S
}
3 V6 v( Y+ p; U1 X3 m3 w0 g else if (yDir == "up") {
! b/ h- o* Z W7 f" X8 {( D& P* O yPos = yPos - BallSpeed;
l- G3 r2 K7 A9 O }
$ r+ w3 x) w! B! `% i" ] h else {3 s8 [9 Y( e: X( e
yPos = yPos;
. t z! ~# V R6 Z; g }
& ]7 F: W4 M9 k8 H$ L }* D. U- k, T, a% O
) m5 Y! x7 [2 t0 j: Hfunction hidetext(){
6 s$ r5 h" B( J8 z0 c* B$ sif (document.all)
4 G* d3 {6 b' E( h, `5 Xsupertext.style.visibility="hidden"
I* q/ \0 j9 Nelse if (document.layers). b, S o5 U& j8 E! \3 M
document.supertext.visibility="hide"7 B& N0 }7 x. g- @
clearTimeout(animatetext)+ ?! O- T* `$ T; @/ ]' j+ Q
}& l! I- G1 v+ ^% `3 ?
4 S2 O1 R6 X. T( G- h* M
if (document.all||document.layers){9 b8 [9 {" u, N! N/ O
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 W% Q, {% ^7 f) h* }
window.onload = initializeBall;
3 z5 Z* h y) @/ n4 l4 ywindow.onresize = new Function("window.location.reload()");
1 Y- ^# I/ d+ ?) I* ~}
; q d6 j' _3 k5 N# z, E6 }
, r1 ]/ S3 ]7 c% h" l. q</script> |
|