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

|
网页之不断弹射的文字-特效
<style type="text/css">
5 z) M1 Y# G4 K1 L7 J#supertext { o* _5 J, |9 c4 q+ {* M8 O. [! `- }
position:absolute;
) @2 g; D9 L/ Z' u0 nleft:0;3 O* O t2 r% U. {- V
top:0;
6 |5 b$ q. [7 u, cvisibility:hide;
0 O% }: s6 Y) K6 B1 |: hvisibility:hidden;
% c" U3 h# d' C* R( Y}
" y3 L- P' J7 [ V8 h: s1 X</style>
, @3 y, t U5 ?' f, R" B0 O' h<script language="JavaScript1.2">
# y" X8 c5 \ N# Q3 a& K# \<!-- 改变下的字体的大小。颜色-->
5 x$ a1 k G3 hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 e6 x" s- U( M$ s9 V @var hidetimer='';# ^ H3 q/ J! d0 N0 i" t( h1 d
<!-- 改变下的弹跳速度-->
& H4 Y# `# E; y- n& G; B" G- cvar BallSpeed = 20;
7 {6 C' i; q5 o; r2 evar contentWidth;
4 U4 Z% o% F6 L; i8 K: v/ svar contentHeight;; W+ L# G5 N4 N7 \" T7 M
var maxBallSpeed = 50;
+ j* d! J( W8 _9 r) P% T1 p
2 S( y! w' H2 ]) H: Q
' ` _8 }/ C$ M9 x, E# `( O5 Vvar xMax;
3 ]- q ]" J: u* I$ q/ Pvar yMax;
; L+ w+ u: u+ dvar xPos = 0;
7 e. r, m: Z% |var yPos = 0;
0 f. o2 {, X$ a5 W3 Q. Z. jvar xDir = 'right';2 ?0 @" U1 u) \6 k
var yDir = 'down';
, e- b6 Q& n0 wvar superballRunning = true;% p/ ~$ S7 F* K
var tempBallSpeed;
/ U. M1 U- W8 G" c1 uvar currentBallSrc;
) m& ]& X& c( ^- G8 A! x P( Kvar newXDir;5 T, X3 q) g( C! D+ P
var newYDir;- f% c' E9 c# s$ b! `: q
' w2 V$ @/ _3 C2 Ufunction initializeBall() {
% k1 b. K* f* X8 n. J9 a) z3 v if (document.all) {. K3 V8 J* X3 m+ r; V
xMax = document.body.clientWidth
1 M" f( g0 T: \: J& \ yMax = document.body.clientHeight! f' s$ _2 F7 r7 d. o) h% |
document.all("supertext").style.visibility = "visible";- t7 F# ?* n/ z- ?4 {4 |
contentWidth=supertext.offsetWidth
* T$ d: l1 d$ K* L" n$ d contentHeight=supertext.offsetHeight
+ K; `8 o- v [7 O3 t }
5 z* o& x; r8 ~8 c" e1 Z9 f+ ` else if (document.layers) {
4 `7 c# l+ J# a6 n, O5 ~% a xMax = window.innerWidth;4 O4 }' W* J5 W( H' q
yMax = window.innerHeight;4 |0 E; h5 y8 S$ {2 M! ^
contentWidth=document.supertext.document.width
& E* M4 G5 f; C7 n contentHeight=document.supertext.document.height
- s1 A! e2 v6 E$ Z" g$ H: X" S document.layers["supertext"].visibility = "show";
+ b% p8 Y% R. M; ^ }
) p Z+ y, e+ [) e8 b3 o, A' f setTimeout('moveBall()',400);3 A6 j ~$ _0 V) b
if (hidetimer!='')! a% H$ ?4 U. e3 w
setTimeout("hidetext()",hidetimer)
, Y$ y+ z! K z$ r/ p! v }- E3 p7 w8 P7 `; G5 `5 ~/ p6 b
- w q$ S+ d6 {1 g6 B
function moveBall() {1 @& R' B, S( s/ i3 U6 e8 I; m
if (superballRunning == true) {1 ^. A. p9 n4 Y+ Q6 R9 `
calculatePosition();
$ p6 W: s- \8 Y G3 w. F- k if (document.all) {6 {3 a8 L9 f3 z) p- X, m
document.all("supertext").style.left = xPos + document.body.scrollLeft;
" X7 ~' u0 a, H document.all("supertext").style.top = yPos + document.body.scrollTop;$ {4 {5 q+ _' e; Z% V& ?
}/ I" x1 ~. d9 \0 h+ z# T4 M- B& m
else if (document.layers) {6 h5 I9 b+ ?7 l9 N
document.layers["supertext"].left = xPos + pageXOffset;6 D% ~3 X: b- ~6 M3 H- n
document.layers["supertext"].top = yPos + pageYOffset;$ O* P0 \4 [: c7 q; h/ h
}
1 K+ M `: ^7 s% y7 D8 X" D, e animatetext=setTimeout('moveBall()',20);
A% T9 e1 F* ]! z, e9 ]% { }/ ]& P& J: v9 J# s4 e! L* |8 g, F
}# \# _; G8 B6 `* @& c3 I; Z' O
9 V( S3 i$ L3 j* K, @( Y9 o l
function calculatePosition() {
5 U7 Q: E, @2 F. R+ J! r if (xDir == "right") {+ A" t5 @7 t4 q* W% R
if (xPos > (xMax - contentWidth - BallSpeed)) {
# b* x6 s Y6 ^1 C* f& U xDir = "left";! P6 C. w ]" k/ h) v
} i3 s5 V1 t& i, U
}2 c' }/ C* U9 e0 o* Q4 D9 s5 T
else if (xDir == "left") {; X" ^, i/ T: l4 h4 r# y; A; F0 ?
if (xPos < (0 + BallSpeed)) {
4 h- z9 _* z' d xDir = "right";2 \& e, Z4 Z# K$ Z1 Q
}
" b: S" y8 s* ~: M/ | H }
4 F6 l( @# }7 A& L( H& k if (yDir == "down") {* q: T; y/ W5 j! H: L: k
if (yPos > (yMax - contentHeight - BallSpeed)) {# i' J- P) W) A; ^
yDir = "up";' @; D K) w4 w* T9 ]
}
' i& p8 `8 c4 H }
5 M: f" s" r8 z0 a$ `' i6 [ else if (yDir == "up") {4 _! {& E0 J# p
if (yPos < (0 + BallSpeed)) {3 d7 N6 t! m, H* Q T7 e# h
yDir = "down";
- w& n- f. |7 T6 {8 E- |$ F }
- D0 n( A1 b4 _8 }$ z: `, H) K }+ `- G/ S) s$ T# s- D* g+ T
if (xDir == "right") {- C) \7 |, x8 {2 U3 K
xPos = xPos + BallSpeed;8 Q Y9 T) n) t) D8 j" _' s0 R
}
" j+ Z+ {5 M5 t {; t else if (xDir == "left") {
- a9 v& h! T' N6 u1 r1 g xPos = xPos - BallSpeed;
T9 O- Z9 {2 e8 i. p/ s0 z }! M& l3 M0 g# G
else {
: j5 R# V% E" U& b xPos = xPos;% V: ?/ i7 _' _' P* J
}) K% t9 s) x* U0 Y" F
if (yDir == "down") {. x& A1 r1 c9 ?& Z; l( g9 \
yPos = yPos + BallSpeed;7 o+ ~- M5 ]! J+ q2 c
}, U2 ^! Q) x( V" e
else if (yDir == "up") {; r9 s$ i1 \9 f/ ], S( w, R% i
yPos = yPos - BallSpeed;, j1 m$ @' i: Z! e! G- T
}& y4 a1 d3 v. @% X; a7 s
else {
% C2 |. O; l& F1 p1 ` yPos = yPos;/ s7 p, v+ G$ F9 E2 r! e$ z
}6 o: J. E7 U9 X0 w
}
. z f# d/ _# b& v* W6 S
1 p" r0 _) H) Sfunction hidetext(){
: q; D5 ?" K0 \+ J# q' K* D. p+ Jif (document.all)7 m( L' Y! r$ s; H: ]6 n. j; K' \
supertext.style.visibility="hidden"6 b' O& o) f. X0 `7 G' ^
else if (document.layers)
& x+ m8 E( H$ o' W. t* p0 w3 g6 f) e/ odocument.supertext.visibility="hide"
& I4 {6 h% Z+ n) B/ N4 @' [6 ZclearTimeout(animatetext)9 h. G- n) p' @
}) l; y7 N! d5 ]( }- y+ u+ r
3 R& l1 f N& D6 ^! q1 a* y
if (document.all||document.layers){
! c2 r( A% T- Y3 ~document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
: x$ G6 q3 j1 _5 Xwindow.onload = initializeBall;( K1 A8 N' w3 n2 U; Z8 d' N, u
window.onresize = new Function("window.location.reload()");$ b( o9 l7 f; l6 T0 `
}
9 J3 k# K; a( _* \1 P- b0 i
% |; S& `) |3 m* I1 u1 s# A</script> |
|