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

|
网页之不断弹射的文字-特效
<style type="text/css">
: G Q: q9 W2 z#supertext {: M% A7 [" I! n: o% W8 E
position:absolute;
* _% D% t) g% Z2 i- k7 c) bleft:0;$ N# C7 K( U$ n8 p# W }9 ?
top:0;
* q: \. T( w. [+ ?visibility:hide;( l0 q7 l/ w( k2 c0 U# h' \2 P
visibility:hidden;
+ y0 k/ r! Y$ k3 ^& s) c}9 k. w4 v' a; t- I& E3 }
</style>
. F. m; T& C/ u. v<script language="JavaScript1.2">& {3 y( Q" m3 e+ r1 X" O) w
<!-- 改变下的字体的大小。颜色-->! x0 N; @$ |( g
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
3 @2 R5 Q9 n( v& J' tvar hidetimer='';
$ X) U4 o+ N8 b% J1 m4 X<!-- 改变下的弹跳速度-->
+ y1 E# V' I/ ?7 N% ovar BallSpeed = 20;
& A5 A. ?9 F. U2 Zvar contentWidth;
]) k, n& F- h0 pvar contentHeight;7 F: Y; o6 f" \& q) c8 i
var maxBallSpeed = 50;" B+ T$ o( }$ j8 \0 x
{& P- F5 a4 h+ Y' _% y
3 b5 O4 L* F0 l2 z1 Jvar xMax;
8 V) q" n- L* Y& cvar yMax;
) V9 Z0 `( X* B, x# j( o2 xvar xPos = 0;
& @3 ~2 h& x0 R: p" Mvar yPos = 0;4 s; K" J- @! [5 B( v
var xDir = 'right';
2 l5 i/ ? ^. M$ {var yDir = 'down';
+ f: k7 n1 l) @* P8 S& }var superballRunning = true;
" V8 I* _/ Y% gvar tempBallSpeed; d$ `. P" ?- G3 l, d) ?
var currentBallSrc;' S& ^1 B C8 s) e; W1 P
var newXDir;
) G2 A* M. G: t" [3 [0 Y$ N0 _var newYDir;2 [3 q. o: A# o% b0 k
( ]5 B. J- n! _0 k" R! x" c
function initializeBall() {4 C# l. P7 Y E2 A' h
if (document.all) {# z! o n+ R# c7 H t5 D
xMax = document.body.clientWidth
$ f% L8 d/ i. f# Q yMax = document.body.clientHeight
% b8 Z4 ?: H N0 Z M1 @ document.all("supertext").style.visibility = "visible";
& H* n; V( R2 n d: E contentWidth=supertext.offsetWidth, r8 C9 H/ \% B$ S
contentHeight=supertext.offsetHeight1 m. K" t" b) P$ t" T9 z6 V% L1 v, c
}
) V- X# l! o3 r6 m0 L else if (document.layers) {
" _ a. E7 m+ Z/ ~4 P xMax = window.innerWidth;
, d+ M; _( ~" m. G- O yMax = window.innerHeight;
5 M g3 ^" a% _ contentWidth=document.supertext.document.width
' ?% {' N" a* F3 n2 r2 i( z3 t7 G contentHeight=document.supertext.document.height0 d, y! e+ |2 ]& ]
document.layers["supertext"].visibility = "show";8 a2 s$ d/ `* u! G. V
}
8 J x) A* k9 T, n: W setTimeout('moveBall()',400);3 b4 Y/ W/ @) n7 c- J* ^' ]- K
if (hidetimer!='') ~( w. e5 |) x; p
setTimeout("hidetext()",hidetimer)5 N" n4 q% D- _ `$ d0 t- Z4 y! F
}0 M7 n6 j# G: d% \
4 q* G0 Y0 e, S- b [* I
function moveBall() {
! V! N) @# ]5 t! c3 m0 |3 r R if (superballRunning == true) {& }. H9 h. [" ?/ a$ ?/ O# f
calculatePosition();$ i0 U0 E$ h( E$ s1 B0 Q
if (document.all) {
& c M7 k* }8 d, B, o+ K. ~ document.all("supertext").style.left = xPos + document.body.scrollLeft;' D7 l3 y$ r' D
document.all("supertext").style.top = yPos + document.body.scrollTop;
?( R' p) V( Q) k# r }
4 w7 ^% j: j3 O else if (document.layers) {8 W4 L% |5 C3 ]6 F+ B: w
document.layers["supertext"].left = xPos + pageXOffset;
0 Q! ^ D; u# Z( x) h- F+ q1 G document.layers["supertext"].top = yPos + pageYOffset;
, b# W: O! c7 U. p X1 f }
% t' k2 q2 G4 _/ q, V animatetext=setTimeout('moveBall()',20);3 q2 P" S+ q2 |. D) H0 Y4 w
}
8 [/ | q+ {5 a }' i& D( a/ u& R$ N
0 l1 ~* K+ A" h+ _+ @+ ?8 B: ffunction calculatePosition() {) {2 B* \0 [* @1 X0 e
if (xDir == "right") {
1 S- Z6 C; d. A( ~0 f. J( S( t if (xPos > (xMax - contentWidth - BallSpeed)) {
# P9 d! D+ |: i, g( X xDir = "left";
/ l! c% g1 U# h. m5 u; t+ K }$ @, m% ~' O6 l4 C9 Q, x
}4 @, j5 [# b' X1 I3 ?/ W& y2 Y
else if (xDir == "left") {
; ^3 a. }' O( L5 W4 J- C if (xPos < (0 + BallSpeed)) {7 a6 m; H7 H Y' N. V2 N+ d* r0 m9 B6 |
xDir = "right"; z8 B" e K" L; \+ F
}
, V+ V6 e {# @& Q/ `2 g }$ L; z% \/ @3 T- n) N6 k
if (yDir == "down") {
; W. z! o) Z; Q- E1 L if (yPos > (yMax - contentHeight - BallSpeed)) {$ i) p4 ~; ~$ v ?+ `% t
yDir = "up";& l0 I; H) M; h( ~. {
}8 g8 I/ s- J( O
}( c2 g0 w) s; |
else if (yDir == "up") {
6 y0 D" `$ D/ i# o6 X. [# ?- m if (yPos < (0 + BallSpeed)) {
3 ?( X' U' h6 j* x! a( B' q. r yDir = "down";
' N0 G7 m; f7 Z, q6 n% ~6 l7 g }6 g* y) O! F9 U M8 n% b8 {
}" E3 g/ h, b" R$ c1 n/ Z7 t
if (xDir == "right") {
9 {/ ~- R' w$ P5 v xPos = xPos + BallSpeed;9 q' v' i0 _4 k: n. ]1 \" e3 d
}
4 |2 m; A2 A# T! k else if (xDir == "left") {
5 R: G, ?" |. G9 m% e xPos = xPos - BallSpeed;
- v) G, q/ {& u6 Z' c! z+ l }
9 ]1 [& v; M: d& x2 O8 k5 j else {0 r7 ]; I9 D8 K9 a! h: I6 T9 Z
xPos = xPos;
& C C# Z; _: c) q }( \8 \9 d7 Z; R$ [
if (yDir == "down") {2 f' G* k1 u! b9 L0 y2 \
yPos = yPos + BallSpeed;
2 ]! W% z; E6 |% O. M8 C, i }2 W' Q, Q/ t' _. S9 S/ u
else if (yDir == "up") {
: J0 H9 R# f1 a% l8 v yPos = yPos - BallSpeed;; o( T, F: N/ L6 v; u, q, i
}0 R2 y3 j) B9 `( S& e. \
else {
' U7 G5 Q4 [$ \ yPos = yPos;2 l4 I! b4 s4 ~' |5 F9 G
}
7 Y0 W( G3 F1 d r/ }4 h4 E/ j8 ~ }
! G( U5 A9 i8 S6 ^( s5 F' V# {3 b4 u! ]
function hidetext(){: }( a2 S' M8 r- j/ j8 I
if (document.all)
# b% O: ^- `8 J8 c+ Fsupertext.style.visibility="hidden"
~' D1 g F; |$ P: zelse if (document.layers)
# {0 U e) e4 V5 o% rdocument.supertext.visibility="hide"
( }" K- ]( K- l9 {8 G- pclearTimeout(animatetext)
1 \5 d, W0 C; y$ p+ H6 u}& O) C; l4 L) |. G* P
( @0 O. |6 F* E' X8 y4 O V
if (document.all||document.layers){; Z& k, S; C$ d [; w j8 D
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 ^" S6 X# H' A. e" K9 V
window.onload = initializeBall;: A- B9 K+ A) M0 }: A8 c
window.onresize = new Function("window.location.reload()");9 i s: c; _' Z( ^1 F- _4 e
}' }5 M( k* w* H
) k9 X+ ^( n1 Q</script> |
|