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

|
网页之不断弹射的文字-特效
<style type="text/css"> {9 i6 U+ D" J. ^$ r( p
#supertext {
4 J. T+ K7 V% q9 `2 nposition:absolute;
( ?! p* v4 X* K; Xleft:0;
% Q4 |$ J9 o1 i! f4 J* c- ltop:0;# X! G# _0 Q5 H$ Y8 b3 Y" N" a0 r
visibility:hide;
$ R! X$ P1 W. M% o' A+ {visibility:hidden; c: g t1 w/ C b: P
}' v) l1 s2 [6 Z( l/ g
</style>
1 Q( r- _8 P l9 P1 c<script language="JavaScript1.2">
' W! ?# Y, q, m' T! w<!-- 改变下的字体的大小。颜色-->; S$ L) K+ A$ Z. `
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
: a& ?6 D, h# Y; S. Jvar hidetimer='';# ?8 ]1 Y/ o% Q: O* h# K: v
<!-- 改变下的弹跳速度-->4 e& t8 O- B9 Q, v& V. Y! K) y
var BallSpeed = 20;& `3 L' Z4 E' ?4 D+ H! g2 Q# |
var contentWidth;1 D0 k) C3 y% ?( L8 z: }
var contentHeight;
6 B* C: L' p8 j+ Lvar maxBallSpeed = 50;
" V3 Q4 v, n; u% C ^4 R( M$ @. y' ?! ?/ f. X% ^
4 W9 I5 R: p% f& x- z, Q. n& ^
var xMax;" g! Z8 U- n! w* O3 M3 W4 l
var yMax;0 i. T2 L' g. r" k
var xPos = 0;5 H2 r4 b7 V0 D7 o/ Q) j' [6 e, U
var yPos = 0;0 w# i5 ~! g* _6 A% k* L
var xDir = 'right'; z( {0 `' D$ k9 A
var yDir = 'down';# ]2 D" U; M) _
var superballRunning = true;
# J; l& a) c0 }. Zvar tempBallSpeed;
+ J' E% H5 P6 R! F P9 Lvar currentBallSrc;
' W+ @) H( o) ]. y; cvar newXDir;/ o6 t4 I1 ?5 C% g5 n) e! [0 X
var newYDir;% J( O) X; C' q: z5 M7 a1 g
/ m) m0 f4 `" }/ C- B3 |
function initializeBall() {5 X: j/ ]5 R0 Z3 t3 r7 c( q
if (document.all) {5 |8 a" G/ H- p$ A9 f7 [
xMax = document.body.clientWidth
/ @+ R1 O, Q- v$ s yMax = document.body.clientHeight
- r2 e" m/ \* [5 o2 I3 F; ?$ `8 b8 } document.all("supertext").style.visibility = "visible";9 H7 I: K4 e; g. v# y, x
contentWidth=supertext.offsetWidth* {5 r4 ^; ~( S0 D, _
contentHeight=supertext.offsetHeight& X; W3 C3 i# \, ]0 r
}8 L8 T2 h* |: z+ Q
else if (document.layers) {6 c% \0 P) a1 y6 }
xMax = window.innerWidth;
5 _. X; w+ [9 ~$ L yMax = window.innerHeight;
0 z+ u' O% k/ q& X" K contentWidth=document.supertext.document.width9 o1 ]3 K5 u; A2 _6 h; o( k0 {, f6 k( Y
contentHeight=document.supertext.document.height$ K' z. h9 e7 c+ I: F0 S/ N& A
document.layers["supertext"].visibility = "show";/ Q8 k" T9 L# i
}
# o9 K1 t% j* P setTimeout('moveBall()',400);" n8 A* k$ Q2 `& l, ?; c3 V
if (hidetimer!='')
9 L, l! I# A6 P5 V/ e2 V( d setTimeout("hidetext()",hidetimer)
) z: J/ I% v/ W( V }
& ^9 o3 \/ y# g t0 R" y
3 U$ }2 d; A; X6 D7 {$ x8 Dfunction moveBall() {) f4 \2 f1 g! a O* d9 ~$ h
if (superballRunning == true) {, k0 M) k3 l7 q/ O
calculatePosition();
$ h+ h3 J3 Y( F; B8 N& X if (document.all) {! I) S* h5 C# m
document.all("supertext").style.left = xPos + document.body.scrollLeft;
& V" |* O+ r0 o document.all("supertext").style.top = yPos + document.body.scrollTop;$ H) O8 ]5 ?1 n# ^
}
. V- |; T' ]# V: v else if (document.layers) {4 @, r# ~" K& a5 X# c$ a( O5 m
document.layers["supertext"].left = xPos + pageXOffset;
7 e4 W* t0 i T- Y$ r7 n document.layers["supertext"].top = yPos + pageYOffset;9 `( w# N: Q J
}
* K* P& m6 R3 |2 V animatetext=setTimeout('moveBall()',20);
- N* C9 M5 l; f6 [7 {8 h2 Y }
; ?6 j+ B/ U& H( F6 c, A }
0 }2 [6 W6 u4 Q1 K0 v! W
5 }. D+ V" F3 `4 _5 v3 jfunction calculatePosition() {, _; }, {0 S9 O" h7 f
if (xDir == "right") {" c1 s' B) S3 l' D, W
if (xPos > (xMax - contentWidth - BallSpeed)) {0 F4 {2 a0 _6 n& f' p
xDir = "left";* E8 T5 d+ {! M$ U$ M/ j N- N+ y& u7 A
}
' p8 Y& p5 e- n& ^; G* ] }% }( a6 x. h, A: S) r
else if (xDir == "left") {% O$ P, N- D' b5 l9 {$ L9 R3 k
if (xPos < (0 + BallSpeed)) {3 s8 y: w* {# J7 m
xDir = "right";
* k: [% S+ L! x, b7 X# w8 p5 w }( w- _5 o( ?, M1 W) X( [
}
# y% g) h! @! w, }) i! G8 y/ v0 j if (yDir == "down") {; ~8 h, ~* Q- c
if (yPos > (yMax - contentHeight - BallSpeed)) {7 {6 U7 e! u+ K( P
yDir = "up";
. c! J4 k& M6 S# E i, ~8 u }
3 }/ A, c1 O9 p4 Z, B- `# x }6 D) }& ~6 `- y) d6 H }
else if (yDir == "up") {# \. f; [! U" T
if (yPos < (0 + BallSpeed)) {
0 }- h/ y j4 [( f- j+ \- s- V1 } yDir = "down";; Y0 o, ]7 ~$ x1 w
}/ a# G% r% i, i% |& m/ |% R2 T
}$ \' B- l! h: {: {
if (xDir == "right") {8 q) @6 H" p, X, D
xPos = xPos + BallSpeed;
! M/ o4 r; N) X }# q( ]+ w) C( {( l' [$ Z1 Q# _- X
else if (xDir == "left") {* ]9 K6 g5 M' H, C6 Z
xPos = xPos - BallSpeed;
. E7 }0 ?* C3 D) U9 M$ T2 w7 U }! a, M* Q9 e; T( a
else {9 [; B" n; [ m" ^9 L3 u
xPos = xPos;
0 W9 e! q# G$ N1 B }
2 v% t3 F' _$ Q# E* A if (yDir == "down") {% t, f _( X. j4 ~
yPos = yPos + BallSpeed;7 V' R# t7 L- z$ ]8 {; ]
}. i- J( y2 k/ L7 m; b0 j* P
else if (yDir == "up") {" O6 U" v, |# y3 S" e
yPos = yPos - BallSpeed;- B. l u; K- G5 ~, V
}
+ U' ` T8 ]% L+ {$ [8 O5 ~ Q else {
% E4 C0 n+ O: ~5 T yPos = yPos;
! R& `, Y" w5 o3 j5 E% n. O }) X: r; Q2 A! N1 F/ {6 f& L6 ]
}' E: o( o: p4 g
& b$ Y/ i7 k& k% Y( xfunction hidetext(){; P& P0 |% i+ W, L* o+ i
if (document.all)
- ~, A: E& M1 c w1 Rsupertext.style.visibility="hidden"$ W0 n; `- s9 x& i/ S I% E* G8 B- m
else if (document.layers)4 b' V$ [2 j/ ~: d" Q: _
document.supertext.visibility="hide"
) \4 Q1 r" E, j- v, AclearTimeout(animatetext)1 _5 x: }0 s V- O x. [$ \. X0 X
}
# j" b: R9 ?* ` j# o& k c5 ~1 m1 {$ ~# {5 _
if (document.all||document.layers){
$ {+ R7 R0 h4 d" _* K) q$ Udocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" P1 M4 C& e' k: L0 r6 s! Jwindow.onload = initializeBall;' ^8 i$ @" s& d' u
window.onresize = new Function("window.location.reload()");
3 C- m: @1 f4 a}
' o8 m. a6 p3 o/ Y6 z! f, S) _! L. v' [5 J% K/ U2 L
</script> |
|