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

|
网页之不断弹射的文字-特效
<style type="text/css">" e0 N5 m' b$ J9 M4 t. J; e" y
#supertext {9 O0 ^6 I; E' A& g1 N/ C# ~( n2 M4 o
position:absolute;
- X) r+ R2 J, B8 B4 }left:0;
: \0 Z4 }$ |4 h: b$ {& G/ vtop:0;) w3 j* X5 j8 \$ i! U. T2 \6 t+ D
visibility:hide;. }! @- m. t0 h. ~
visibility:hidden;/ c# }( s4 O% n, ~- h2 B
}5 c0 g0 Q) h/ G; x
</style>2 p* u( R$ n+ L+ N3 K8 H) e
<script language="JavaScript1.2">6 B7 j! c8 U' h: A; Y
<!-- 改变下的字体的大小。颜色--> s0 ]2 ^% f; @
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
: I9 J9 p$ N$ p7 ivar hidetimer='';
_2 B2 \( G! J& I$ e7 A<!-- 改变下的弹跳速度-->2 K% f# d2 x# e& Z, a; ~ A' a
var BallSpeed = 20;
/ ~8 R4 _" u t" B# G) |6 \ e: t2 }4 Yvar contentWidth;( x' I" l' p# \
var contentHeight;
: N6 T' Y( f2 [% Y- F! | K, {& D- vvar maxBallSpeed = 50;" ~+ r2 p2 M5 Q0 B7 T
0 k) O/ w& O0 e2 j, Q' _
4 g7 N3 V$ x p+ b, x
var xMax; E$ \' D' C+ B- W+ g) ~% I
var yMax;( |% x, y/ m! K) u
var xPos = 0;
/ ]4 r* I. {3 J& z ovar yPos = 0;" w' Q& Y7 D* ^; l4 s) M# v) q
var xDir = 'right';
4 h3 M' U2 y5 q) s3 R: `% Cvar yDir = 'down';" f d9 x/ {- F0 a1 `2 K! J, V
var superballRunning = true;+ v' H6 X$ P1 Q* `9 z) W7 s! i. d9 ^
var tempBallSpeed;+ N3 r) i: j$ ~9 H4 \' F
var currentBallSrc;$ S6 }+ ]' L' w' A* M
var newXDir;
5 y# A: n4 W& J4 F! K2 evar newYDir;; s' @% |' i6 m* S
! M* W, O5 d" v" i1 s9 rfunction initializeBall() {" z7 G, f1 p! F( J. K I1 e
if (document.all) {
- f$ @6 c5 e) y xMax = document.body.clientWidth
9 l. S) F6 ~) O6 O" G/ b3 W& a yMax = document.body.clientHeight
9 n# \6 o! p+ w document.all("supertext").style.visibility = "visible";
* C5 h, d* o+ L, O' ~/ _; x7 G contentWidth=supertext.offsetWidth. n: ]1 ^: `# \7 ~$ b3 t- I
contentHeight=supertext.offsetHeight
a3 G. }* |5 h' i- k: t4 L3 n }
( ?" h* q" @# ]' y/ T else if (document.layers) {! E- s& D0 U& O6 U# N
xMax = window.innerWidth;; d6 Q! _& b- f0 j m
yMax = window.innerHeight;
6 I& W9 M* P7 B- \ contentWidth=document.supertext.document.width
' t8 e# |8 j" O, g2 R contentHeight=document.supertext.document.height s% }1 Z* [/ k/ Z& I* N4 v; T
document.layers["supertext"].visibility = "show";
1 G/ X5 o: _9 b" o. J( f }2 j/ J$ C& }: h, C2 G% P; I
setTimeout('moveBall()',400);
3 @- u: W* _' ?+ {3 T if (hidetimer!='')
8 Y9 ^5 H% ]' R5 G1 n. Z$ N# W7 e, C setTimeout("hidetext()",hidetimer)
( D2 s. ^0 u- N }$ c: p6 I/ r& w8 i
0 h% C) ?/ H' a* q R5 s/ l8 Wfunction moveBall() {5 f: m/ x3 {2 ^
if (superballRunning == true) {+ ], S/ b; l" p% A* ~
calculatePosition();
9 u4 n7 X, z: X2 i if (document.all) {
; ?) Y" P* l, N A document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 q2 n' i. s g) _1 {7 l) P document.all("supertext").style.top = yPos + document.body.scrollTop;
: h4 ?* E" D! b }
2 \- m" S2 |2 a# _# D( Y l else if (document.layers) {2 C; i0 w, c! m; ?
document.layers["supertext"].left = xPos + pageXOffset;' E8 B; l! n$ W8 _" S
document.layers["supertext"].top = yPos + pageYOffset;
0 d* N4 L: C4 c' \. D+ s8 A' b }" Q& | S! \! A J
animatetext=setTimeout('moveBall()',20);
g- ~& J( ?1 i" O: N6 j }( x: O8 E1 w. C+ w, ?' Y
}
/ y; l0 Y5 o+ @+ f7 L/ M
8 k; @; `2 P9 e _: D! v3 x# Kfunction calculatePosition() {
1 S" U& P6 f4 W5 h* |5 w if (xDir == "right") {
! D7 e$ Y2 t9 x) e* h, X if (xPos > (xMax - contentWidth - BallSpeed)) {, K' ?" Z% q! r9 o$ I! w
xDir = "left";5 x6 W0 Y7 F4 }
}
4 a+ e( O; W' O$ Y$ A }$ G+ _- ]4 k/ A. w! D
else if (xDir == "left") {. u+ U( d! b: N% D7 s( T' f
if (xPos < (0 + BallSpeed)) {1 e: u& D; S4 f
xDir = "right";
+ _4 f! n, L. x3 K- K( a2 S, T }" Q# X: M+ _. {+ X1 H8 [) H
}
/ K3 w9 _- U6 q2 c8 I; Q if (yDir == "down") {
& L# H: K6 g# N4 U if (yPos > (yMax - contentHeight - BallSpeed)) {9 v L0 V, N! i7 Y- S- Q5 z
yDir = "up";
" e7 ^/ A- Q2 W7 \* \ }5 ^ |5 f( r. J6 x
}
) X7 N% _1 q, I else if (yDir == "up") {' C7 ` L% i, X) R* B5 P
if (yPos < (0 + BallSpeed)) {
0 b7 E- r; V% Y$ G yDir = "down";. U# F! R9 ^9 L# b
}' U# y* d" }, h2 X
}
7 g- i0 Z# \, K/ ?; \ {- Z3 f if (xDir == "right") {
, j4 M4 E, S9 g; o+ k xPos = xPos + BallSpeed;
8 r+ P8 x7 [$ }3 s. o6 } }! U( U( A' @5 a& ?- ^2 u
else if (xDir == "left") {; W7 p' i n9 d/ o" h* b
xPos = xPos - BallSpeed;1 l' J8 x( V. J8 h
}
9 q: {& c! u$ G( b! b% i- k else {8 r. m, \; c. A
xPos = xPos;% C% J4 L6 q$ c# r
}
8 D) \8 o. Y1 F9 y, H' @ if (yDir == "down") {. q, \ ~5 N: u* `$ q+ k
yPos = yPos + BallSpeed; o( S7 J7 x: a6 I" ?
}7 f7 Z. Q& {$ D
else if (yDir == "up") {
& o4 @" P R; ~$ H yPos = yPos - BallSpeed;6 E' J6 w6 w, u# a5 x8 t+ `
}, F, U* [# t0 w6 z
else {5 j! R# q, f2 {+ F& W0 E% H
yPos = yPos;
$ c; s+ J( i T: k" `1 y$ A3 ] } u( g2 z: \- ? ]# ]! j: r
}. p% y# A3 Y5 D1 z
; D3 W" t1 t3 x! ]4 s8 I/ i" T" ~
function hidetext(){
9 T% R! F/ R& Q: d. bif (document.all)& i6 v$ B( c; w$ [% t
supertext.style.visibility="hidden"
% s/ L: u& A/ ^8 ielse if (document.layers)) t3 A/ _/ r. R3 Q- n [* x
document.supertext.visibility="hide"
$ ^$ r( \! u8 A5 MclearTimeout(animatetext)5 A; F) P5 H/ f& }7 B
}. \. ^0 H, c G; h$ z
5 i, @/ g; t# I2 {7 i! iif (document.all||document.layers){+ M, I' \8 X* f# ^3 E$ Q6 p5 C
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ I2 N3 C8 Z" ^4 e
window.onload = initializeBall;% Q3 z7 o: R2 p* ^3 c: b
window.onresize = new Function("window.location.reload()");
5 L3 Z( q3 u3 w+ `0 ]7 M9 f3 p2 t}
7 H3 h1 n) s- ~0 {4 J
9 a1 S$ E% z& L, X</script> |
|