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

|
网页之不断弹射的文字-特效
<style type="text/css">
0 m# i" J" A( L" F#supertext {
) W( e- N6 Q! pposition:absolute;
$ l' N0 U8 C. r& f5 Q2 P* Aleft:0;$ }$ b+ l/ w$ K' u
top:0;
$ k* U( J- C& Tvisibility:hide; S$ R6 f6 M( `( j+ _! d' m# ?* q
visibility:hidden;
+ ~) A! d V. w7 d3 K: L" `}& O, V) p9 }! o7 ^7 C$ k
</style>: U, K% @7 l. _6 W7 X
<script language="JavaScript1.2">3 o1 B- l2 b8 _8 L1 g: u
<!-- 改变下的字体的大小。颜色-->
5 m+ o: P% w/ S/ Z/ @var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( b* h7 w5 k9 b7 D# Svar hidetimer=''; O( ^1 O5 T; b
<!-- 改变下的弹跳速度-->* ^! O. C) k2 v
var BallSpeed = 20;
& Q: k+ e$ b6 o) H; e; Nvar contentWidth;" [) T+ ^8 R: J
var contentHeight;, y6 I8 w6 Q1 n+ Y" o
var maxBallSpeed = 50;
- y8 I3 F" K3 G& M5 q- o1 x% ?; H2 h+ G4 Y* {& ]5 C
$ _# p/ u. S/ J( t
var xMax;2 @, I- I2 \3 s/ X/ u
var yMax;
" C }7 m% t( z" w7 @8 @* Qvar xPos = 0;- _( |1 J& A+ x% l/ P
var yPos = 0;/ ^: x) ?4 u, y6 P: F( e
var xDir = 'right';* Q8 @" V# i& S, s( a$ Y
var yDir = 'down';
a M6 {( w+ i avar superballRunning = true;! U; x1 ~2 t* u, r" v
var tempBallSpeed;* z$ j. p* c8 ]; Q" k
var currentBallSrc;
9 X& \/ K5 T6 B- |* kvar newXDir;" N. k" E1 M& E9 G& G! X/ b) F0 N0 N
var newYDir;6 G5 p W, y: P/ O, w( }; z
/ X+ s$ p; N5 Q
function initializeBall() {1 g+ r! H! |. E; F6 z; F L
if (document.all) {+ S7 d: ~+ `7 e: U
xMax = document.body.clientWidth$ a; g& J+ Z) h# Y* W
yMax = document.body.clientHeight
* n& ^8 u7 x+ d, u/ c' A document.all("supertext").style.visibility = "visible";5 G4 D. _" F& I3 n+ L
contentWidth=supertext.offsetWidth
, `* l. J$ ]) Y# N" ~- w contentHeight=supertext.offsetHeight
# d: G$ C5 T9 {/ i }
$ v- u v) o8 g6 T) V( p. | else if (document.layers) {) I# z( W* r9 h% K8 E1 I6 y
xMax = window.innerWidth;
) R' k8 ]+ W4 X0 P6 l" K yMax = window.innerHeight;
; Z) x$ a9 E( S5 m( M contentWidth=document.supertext.document.width) G. W6 ?" E; @; H3 _
contentHeight=document.supertext.document.height
. u. s u p9 x/ x0 }; E4 Q4 | document.layers["supertext"].visibility = "show";
; Y0 R( M6 N3 V& ~ }& V: f; h7 c% `
setTimeout('moveBall()',400);: E7 Z' v( x- s2 `. _" f
if (hidetimer!='')
; k7 U8 l8 m9 _0 R9 T setTimeout("hidetext()",hidetimer)% t! V) G+ P5 Q' s. n- G
}" y: T# S3 k6 V8 i
8 `4 M; S. P/ ^2 P
function moveBall() {/ e7 K: n$ d$ P7 \
if (superballRunning == true) {
( C/ g6 ^& p9 i/ C4 d calculatePosition();
6 O4 q- L/ Z2 G7 t; X4 J H5 [ if (document.all) {
9 D$ J% Z8 ^- `$ g document.all("supertext").style.left = xPos + document.body.scrollLeft;" T) x+ u" w' t9 r1 w
document.all("supertext").style.top = yPos + document.body.scrollTop;7 ]% s/ Z2 W1 t6 h. K: h
}
/ z8 t5 v' Q% ]+ W- X else if (document.layers) {
6 `: F7 k5 z: X7 I' u( N document.layers["supertext"].left = xPos + pageXOffset;
) h" Z/ a; Q! B- r document.layers["supertext"].top = yPos + pageYOffset;6 O6 }4 v1 L" g; y8 e
}% x d. n. [9 Q N2 D6 W2 w# M4 O
animatetext=setTimeout('moveBall()',20);9 ?8 l# M2 H, U _
}
, j7 s7 j2 r5 U0 V& X, Z- k }
* l- \: W& z! E' ~8 M/ c' f# Y
8 ~1 ]7 C* y: d# F: a$ [function calculatePosition() {
3 C/ W7 M6 t6 o/ E$ V) n if (xDir == "right") {
7 w8 c. g2 \3 Y t! B3 x) s if (xPos > (xMax - contentWidth - BallSpeed)) {
$ o1 R! {8 ], B% O. A xDir = "left";" @8 D5 E- p- E# g9 U/ |
}
* v) \3 x2 i2 k$ r( D/ U+ v }
5 n( G0 B7 l1 l$ o& i. l1 H else if (xDir == "left") {! v; X* k, T6 p& Z" t
if (xPos < (0 + BallSpeed)) {
9 X8 s# b0 B9 ]6 O xDir = "right";8 L5 f$ I1 N5 {; _0 M
}
' g& g) B$ d. U6 G# l }, q G) p* H; o
if (yDir == "down") {3 Q' g& m: d1 l# ?) p
if (yPos > (yMax - contentHeight - BallSpeed)) {3 m, f+ d! b4 e T
yDir = "up";3 j) \* N2 s8 m8 |: x' S1 N/ ?* \
}
+ V: V7 }3 g$ d1 p5 W$ | }
' D$ o& l5 w/ T5 V1 a2 A2 L else if (yDir == "up") {
0 w! J( N. g% k$ ^2 o3 n5 |! L1 \7 c if (yPos < (0 + BallSpeed)) {7 ?8 o3 e9 a2 ^- k& k
yDir = "down";/ e0 G3 h. s2 b+ H4 [% e( v
}
3 R. H% `' S% Q }! A% Z1 o# G# ^+ Q9 J/ V
if (xDir == "right") {( y+ G+ @+ Y; H
xPos = xPos + BallSpeed;
% ]: ?' x! k* E5 A4 n }
0 K; u, ^; G9 H0 K6 }+ _ else if (xDir == "left") {
; l! S; ]% e N/ A3 w6 n xPos = xPos - BallSpeed;
4 f7 F0 c1 S: i* b9 a& {. {* [0 s }
+ q, ^- k! X+ q) ~ J+ \3 i, r else {+ V, }* o/ @- _' u3 f5 G+ @
xPos = xPos;* \/ e! g$ \2 _* j; ~: T
}
5 y: ?* B8 |4 N( n# W0 v# } if (yDir == "down") {
& @" ^3 s. i! y yPos = yPos + BallSpeed;; O2 Z1 d/ m% ^; b
}+ l- a$ \5 S# n1 |8 m
else if (yDir == "up") {
' ?7 ?. ~* R. }6 l1 t7 C4 y yPos = yPos - BallSpeed;9 o, T& Q6 B6 z
}
4 `6 u; z* E9 {8 p else {7 o& M, P" d" e8 L
yPos = yPos;: A+ m# n) y0 Y3 _8 ~5 y
}
) A3 Z# u, {, k1 ~. H }
- ~( p* ]' C6 C2 G' R( L
( w- U% ?) m# Q% u& L0 Z) Hfunction hidetext(){; Q7 j- n9 v. A% W$ h) I
if (document.all)) r% V: Z6 L) c% ?
supertext.style.visibility="hidden"; _" J" u: x3 b) F' }
else if (document.layers), Y0 g) O; L' F8 t' J+ o% r
document.supertext.visibility="hide"
5 X: P9 X5 {% m/ P7 j! L R3 iclearTimeout(animatetext)
$ \2 q) z. m1 k3 j( y7 |}
. M- r# R% w6 W& }* e. |( l1 P& B
! a; r3 K9 Y7 L* K# o; A- Nif (document.all||document.layers){1 s2 n0 V% }- R; T+ c9 u O2 H
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 \' v! G7 K; F* B+ awindow.onload = initializeBall;
9 r/ o9 ~" |, c; ywindow.onresize = new Function("window.location.reload()");
9 {# D H4 M) n}
! {% `: ~, o W/ M0 m) ~" [, H
1 z! E: Z0 @7 O- N: b</script> |
|