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

|
网页之不断弹射的文字-特效
<style type="text/css">
2 `- c2 G" e2 K6 `& f- V! S#supertext {
, \4 p* u/ c2 Y8 w$ f# M" X1 a5 p) oposition:absolute;
0 E- U4 W3 s+ o5 q! f* R3 Xleft:0;/ m2 l6 l' {" x
top:0;
m8 M& |6 F# z; G6 Fvisibility:hide;% t. c: P8 y7 J) R' |
visibility:hidden;6 q V# `' x/ e! e; I
}
8 f" E! B' o. Y( i* M</style>
/ V( ?4 d3 q# f1 l! q<script language="JavaScript1.2">
: v9 o5 b+ Z3 e2 |3 F# ]1 g8 H<!-- 改变下的字体的大小。颜色-->1 {6 Z1 M0 F* B: I& v5 `: t0 l; S
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'" s* t( z- W+ ]+ M. @8 ?
var hidetimer=''; P$ A7 [0 y+ x' p( @) \# H" }& q
<!-- 改变下的弹跳速度-->( T a& Z2 L C: Z/ X
var BallSpeed = 20;
/ Z9 J* d- u1 ?" C7 evar contentWidth;
" K. G- z& G9 w Y/ e1 X3 Avar contentHeight;
. P; F: I8 J- @ E: F. Cvar maxBallSpeed = 50;# u$ j" j( E% c5 v; O
/ [6 z' }0 g2 ~7 l0 ]1 j( \/ f
7 d9 ~; d3 H8 M8 L* Y9 q
var xMax;% E5 `( y. R1 @4 w( O$ k" P
var yMax;
/ G' }" ?0 K2 W+ N0 P) vvar xPos = 0;
% g& [1 k$ i- L$ x$ o( v N+ bvar yPos = 0;, G& m. o3 t& Q& P* s
var xDir = 'right';
3 N( q* I+ | h8 z: s9 l; k6 cvar yDir = 'down';
1 P' l, g4 }4 A, `9 {var superballRunning = true;
4 D% ?: P* @7 o+ ovar tempBallSpeed;
1 P+ [$ |1 M. Ovar currentBallSrc;
9 S* D( c# O9 |2 I8 M3 i" j, c/ avar newXDir; G, n v9 d- }% o) P$ N
var newYDir;* o8 [) X: N" Z! [0 ~* R. n9 z
, X4 u2 s7 o7 W1 w8 O! i3 o2 cfunction initializeBall() {
1 }7 x8 v( M/ _& M if (document.all) {
5 I5 F1 L; H7 b; H$ M" S xMax = document.body.clientWidth
& x+ K/ F; \9 |0 j: H5 p, X/ n& J0 b yMax = document.body.clientHeight; X& ~5 n. S0 \) o/ N0 R
document.all("supertext").style.visibility = "visible";
3 d9 @2 }6 V- o0 \$ H1 T contentWidth=supertext.offsetWidth# }* o/ v6 S& K+ F6 p5 A% c+ ?
contentHeight=supertext.offsetHeight
7 m, P8 Q! N1 h$ d5 F3 N" P! ]/ r' X }8 V( b# d+ n! ?7 p, w8 l
else if (document.layers) {
) X. f% S; j9 ?3 T xMax = window.innerWidth;
. z& w/ F7 [$ O2 M/ b yMax = window.innerHeight;0 C6 |; i) T9 V
contentWidth=document.supertext.document.width4 ]( k- l# T1 N, g* P B3 e8 L/ S
contentHeight=document.supertext.document.height( l% U9 `, c2 Z. h
document.layers["supertext"].visibility = "show";
1 @8 K% ~/ L; d: u' W, Z! i } N# Y1 Q4 V0 A& c7 l* Z. b6 e! B' t1 l8 q
setTimeout('moveBall()',400);4 e8 _9 ~/ h: U( p5 v
if (hidetimer!='')
# P7 o! S& b* D& O setTimeout("hidetext()",hidetimer)6 z/ Y4 v" c4 \. k
}
+ g& W! g. P* c, ]/ K
$ c( ^2 I5 S2 U* r$ ?4 xfunction moveBall() {
$ ~6 A/ W+ {( I e+ { if (superballRunning == true) {
( P/ V5 g& }0 [8 v3 c1 N calculatePosition();) ]- j5 |& u( O# k" Y- b
if (document.all) {
9 }% `) k* k% Q9 A: i document.all("supertext").style.left = xPos + document.body.scrollLeft;
, I( W! h @, i7 t1 g document.all("supertext").style.top = yPos + document.body.scrollTop;2 B. n. C2 ^$ X( o+ s# Q+ @4 P. L
}* h+ m$ F: A# y0 d
else if (document.layers) {9 N" S' q$ R) L0 C
document.layers["supertext"].left = xPos + pageXOffset;
* Z% s3 p( i/ s4 f& F, F0 p document.layers["supertext"].top = yPos + pageYOffset;- y. l$ f* x& C) U% B
}
' k5 L* R! w8 B8 P% f animatetext=setTimeout('moveBall()',20);
) \, J$ `0 L) f+ W7 }* y }- J+ k8 w! q, c7 e6 A
}
- _+ b6 t! S- l" M
9 c7 L, G5 E$ `- Sfunction calculatePosition() {4 f& n3 D# ?4 f: I. o3 @- o' f
if (xDir == "right") {
9 r- L3 ~' a2 u% F* d v" }3 D: \* L' C if (xPos > (xMax - contentWidth - BallSpeed)) {6 b% U% ~: T* p
xDir = "left";7 t# w5 v% |# l* [( n4 `
}
2 V, ^" s8 o6 V# l }/ I, }! s/ e# m, F7 p+ \1 j
else if (xDir == "left") {' I$ M: G& F ]/ T
if (xPos < (0 + BallSpeed)) {! Q: u& \3 ~( m: j0 |# Q$ ^
xDir = "right";
3 {; P% O( ^ @4 O( c }
0 K5 B4 g Z+ a0 L }! i, |, \; M: G+ Q2 D& i/ Z: J
if (yDir == "down") {
[ I7 o, Y, l# C" n9 | if (yPos > (yMax - contentHeight - BallSpeed)) {
( Q( @/ W- d; g+ |* x, v& S8 } yDir = "up";% [3 M8 R( U4 F$ d3 [* i
}
0 S r q1 I, {- ]# L }8 s; q3 X2 a: R; f0 l% |
else if (yDir == "up") {
. X5 b6 ~8 K7 j1 Q: Q- ? if (yPos < (0 + BallSpeed)) {
$ w" E! f* R+ ]' \( z yDir = "down";( O( l9 O4 p5 u
}7 G) u1 p* D1 P+ ?; q! J, g
}3 U8 U- m3 Y& |% L: _3 B8 `
if (xDir == "right") {
, v0 H5 C% d( N& Y$ V4 n xPos = xPos + BallSpeed;3 S" f( q% j0 f4 A
}) n6 h! e( o2 x
else if (xDir == "left") {
1 x2 U8 H: @, S xPos = xPos - BallSpeed;! y) E3 D, ~* Y/ \/ q4 d- D* y
}
+ m) W8 ?7 H3 E+ x$ {7 A else {2 x$ {) u* T! _' m. f4 J) K7 l
xPos = xPos;# T; ^* _+ @# F7 F9 M$ S- O+ L
}
- F$ K; @' b2 B/ a if (yDir == "down") {
9 M) Q3 D* W5 _; x: D* K yPos = yPos + BallSpeed;
6 H3 `3 l+ g( @6 J9 W) f8 i7 h8 ? }2 i( O2 C2 P# S
else if (yDir == "up") {
( W" y9 {( |8 O3 \- C) q& ~0 F yPos = yPos - BallSpeed;1 _; c8 O) P$ m1 W1 m& @
}
) {, Y, i0 K- i else {
6 W% S7 p! ]* l" [1 Z# r yPos = yPos;1 T0 C/ a8 j5 l
}4 D6 x2 l6 n1 K( F/ \
}
- ~& o+ n1 }! Q& Z6 i, P! X5 x" x9 J) p
function hidetext(){! Z2 R/ ?+ r1 @0 ^4 q6 h
if (document.all)) ~) H! h& B% t8 {6 _: E$ ]6 q
supertext.style.visibility="hidden"
8 s% J8 H6 w9 f3 z# Jelse if (document.layers)
6 F' h' I, i' n5 H1 D, ?document.supertext.visibility="hide"4 W* N0 Z/ w* s+ T% q
clearTimeout(animatetext)" O" ]/ }* j! m; G0 z$ A
}
) f, B& U! |3 X
- p ~5 ?7 s4 \2 Y* }! O) mif (document.all||document.layers){* a6 |0 N) ~4 f
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 u, A" g* Q3 g
window.onload = initializeBall;
3 ]$ w2 X8 R4 i5 Dwindow.onresize = new Function("window.location.reload()");+ P9 y+ Y& u9 \% [# G, y2 ?: n1 o
}
1 _8 D5 x. @! F8 f0 [- K+ A& p8 A! P4 b% l* I, z3 M2 |4 p
</script> |
|