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

|
网页之不断弹射的文字-特效
<style type="text/css">
8 \* E, _6 F9 N5 V& s- f#supertext {; Z' f: A* z0 q# ~8 i
position:absolute;
" @9 W' a8 G0 \+ T2 n- y1 Vleft:0;
, S% W6 B5 S$ T* c4 ytop:0;
3 a- x8 Q9 B- y" h5 |visibility:hide;
. h, u9 \" d5 t9 N+ Y% Zvisibility:hidden;) u' s! L5 d+ S. O6 K8 a
}+ X# ?( o+ N) \
</style>
3 C5 K$ |4 ~: j ?<script language="JavaScript1.2">
3 {( ]5 a" d8 @+ f' R; k. }<!-- 改变下的字体的大小。颜色-->& U2 v5 o" Y# K8 G$ d
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. f, `. `/ W( V/ D. u& o
var hidetimer='';
; Q" N/ T) w& j3 y<!-- 改变下的弹跳速度-->
! y5 V6 n( ^; t( I" D1 Rvar BallSpeed = 20;
1 e8 _' w Y% u4 f4 dvar contentWidth;" a2 A/ [9 t7 R
var contentHeight;2 h/ x ]2 N8 }/ E) H# q
var maxBallSpeed = 50;
+ b9 x8 C# {; e/ o* u" G B$ H8 C. K
& ]2 n) f9 J1 X7 w: U: Y9 V
var xMax;
, b4 u0 V, ^: Svar yMax;0 ~6 e+ x& w' C5 k
var xPos = 0;* e0 F3 A$ Q2 G& Y0 i1 f% m0 `
var yPos = 0;
% J. r' i- P: _; J1 k& Avar xDir = 'right';
2 W6 V& i- R0 l8 Vvar yDir = 'down';8 y) a9 f0 e0 v* o' W
var superballRunning = true;
+ t( u# y9 P& h# b" W6 Zvar tempBallSpeed;. z: {' X7 _5 T+ T2 o& H
var currentBallSrc;
2 W# w! T0 x, o9 v, wvar newXDir;) @( q9 s3 A5 I$ m7 _
var newYDir;% l3 U% I$ w6 J: u/ V/ \1 g5 J
) c6 e2 l: V; m
function initializeBall() {# _& P1 Y1 b4 \+ Y' i+ r
if (document.all) {9 n4 t" |/ j- e& |6 X
xMax = document.body.clientWidth+ ~4 r7 J: t( f. r
yMax = document.body.clientHeight% r. \7 u0 b! @6 V1 P+ _2 q
document.all("supertext").style.visibility = "visible";/ Z7 ?# c0 S" n; `! C$ L- z: w/ a
contentWidth=supertext.offsetWidth$ b6 h6 i5 ?- R, s, M0 ~
contentHeight=supertext.offsetHeight
& f, K/ n% A2 S% f, w5 p* P6 ^9 ? }
6 A, {; u4 ]( }# x else if (document.layers) {6 J! z+ N Y4 u, w4 P2 Q
xMax = window.innerWidth;
& I3 G6 \2 B3 P, Z0 I* l+ N2 }: j+ _ yMax = window.innerHeight;( u" Y& [/ ?& N) a* N
contentWidth=document.supertext.document.width$ j' k' e0 w7 s. D
contentHeight=document.supertext.document.height
: E7 C: M$ z; d7 {2 W. r2 C document.layers["supertext"].visibility = "show";
" ~3 [7 ~& N9 W) W }
1 [' x$ @0 ?8 p setTimeout('moveBall()',400);" h3 _+ B+ W$ q) | N
if (hidetimer!='')4 ? Z) u1 m% _& r4 h: M8 o
setTimeout("hidetext()",hidetimer)6 Y* _3 D9 g. J+ u6 K+ G
}
4 Y. s: ~2 }7 n# o( v' \
9 o# |5 Q3 o1 {5 S& v7 Yfunction moveBall() {
" i0 b* j, P- I! W$ B. } if (superballRunning == true) {
Y7 e5 u3 z6 M calculatePosition();
t9 L, {' A5 p if (document.all) {
8 i& P5 L% r2 Z6 i7 C9 n1 _0 ] document.all("supertext").style.left = xPos + document.body.scrollLeft;
9 K5 K2 I# G3 D0 F document.all("supertext").style.top = yPos + document.body.scrollTop;( H" d9 i& P3 g, I6 W& w
}) O$ {. K" }+ ^! k1 d1 h" J5 d
else if (document.layers) {9 n- i* q' B) ]# w' W# ? M. R
document.layers["supertext"].left = xPos + pageXOffset;
: B+ _$ o% r: j, J1 y document.layers["supertext"].top = yPos + pageYOffset;
1 R |, P/ G% n( ~ }5 D8 A8 r7 O }1 Y' {. P( t3 J* k$ C+ |$ c/ E
animatetext=setTimeout('moveBall()',20);
! g" c g+ f5 y2 E: d9 ~# ?9 \ }9 x0 @3 N8 J* C* Z
}
9 n! C+ {& ]! T3 y* w0 S, u: a5 i5 |: U) A* y, E& y! }5 X9 e
function calculatePosition() {* b# H3 `2 _/ ?4 n) M6 R
if (xDir == "right") {/ T; f+ {* e8 o6 \
if (xPos > (xMax - contentWidth - BallSpeed)) {
$ P! C0 h0 ` U& n1 v, v7 |% { xDir = "left";
$ Y1 z. y9 V. P5 f/ u8 O" i }9 Y7 T0 g( M4 E* Q/ p
}9 u! |" u$ y/ s2 E, H& J
else if (xDir == "left") { k* b7 E2 |8 P6 F# ?! [1 n6 l: B
if (xPos < (0 + BallSpeed)) {
, P+ B: X9 _& W$ y4 n: Q6 ?8 ?$ Z4 S: B2 k xDir = "right";
* D2 s" t8 @/ f2 n' D3 ~! u }
+ W6 s1 { s% P% p k: n }
1 f1 q& F% C' `& r, j F1 K if (yDir == "down") {# s' ]1 D# O) l5 @1 C6 ]# e& E
if (yPos > (yMax - contentHeight - BallSpeed)) {/ [/ D# ~' H5 v7 x+ |) C
yDir = "up";8 b8 h: n1 l6 o- z
}2 W2 T% w, h8 {" c3 f: j
}) z6 W" ?) [- u; F- ]5 a( E
else if (yDir == "up") {
, s0 n6 a: X0 c4 b9 A0 | if (yPos < (0 + BallSpeed)) {
+ J9 W0 G3 t7 T/ L H" ` yDir = "down";
) G$ C5 i- w" U& j* a& p- F }
5 I1 g( O* O7 A }( G( }9 I" k: o7 J5 L
if (xDir == "right") {
. x; s( t4 |3 I C4 ~ xPos = xPos + BallSpeed;7 M; }8 ^$ t6 o' M1 Y I* X2 J6 c
}) d* R* i& C% J& B+ @/ Z/ ^0 s: g
else if (xDir == "left") {- Q) A5 F- Q/ q+ L3 m0 E! H6 u
xPos = xPos - BallSpeed;; ?8 F# f) W( q w& C
}
5 g+ m, x- b% ^8 |6 Z/ E6 e else {
6 _. i7 P' i& t' ?* I- ?+ L& m% d xPos = xPos;. O, b9 K$ U" V% t1 q' X' [
}
. H, U6 {/ ?7 ]# b d' t3 G5 R if (yDir == "down") {
1 Q. q7 e0 E) _8 T( x7 p yPos = yPos + BallSpeed;$ a! W, i# T! O9 y9 x4 H/ ~7 `
}7 L. i' ~& w9 i5 s2 H. e2 k
else if (yDir == "up") {
/ [: n" p* h5 W- T5 o/ u5 q& r yPos = yPos - BallSpeed;% f$ I: C- O& H4 k' W/ G# I
}
\& C2 j" Y( F; V* [8 ` else {4 [ Q2 C' L- D
yPos = yPos;
) k3 Y6 R& \: V5 D }1 l3 S; j1 q( @* x/ g
}
% S, v+ m/ G2 b/ Y" }' f1 ^4 R. c3 [% x( I
function hidetext(){ z" m5 b# h8 W' K
if (document.all)
# ~. m2 q6 P, R% B! n$ d$ Fsupertext.style.visibility="hidden"
; Z6 U" @ N. Felse if (document.layers)( W& D5 z0 g* h4 J; R$ e: Q6 X
document.supertext.visibility="hide"
/ x. H. V" R2 x# o0 `clearTimeout(animatetext)
" f& `% \) Z) e) g ?* ^! i \6 ~}2 C7 z9 M8 m7 v
8 {1 |- Y) E: P5 g6 x$ `/ r' t0 Dif (document.all||document.layers){
! k9 G. j- n6 rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ @ E5 s ]/ Awindow.onload = initializeBall;- B1 e* J' Q( O3 L4 W% _& u
window.onresize = new Function("window.location.reload()");
" ~2 f' E. P! ?. \' m) X}
5 P% R! ^6 w8 k$ o- W) Z
! d+ A; C0 g' O: t</script> |
|