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

|
网页之不断弹射的文字-特效
<style type="text/css">
( ~: ^ \8 n5 K& y h#supertext {1 z; ?7 \: \& b1 z: X; \ y6 I
position:absolute;& d: a: T" @, P8 H u% a
left:0;
6 j+ O6 X! g W/ G1 [top:0;
; }4 J9 c( h6 J% k: Q& pvisibility:hide;; v, Z8 P7 p Y9 i8 Z& W. c' ^
visibility:hidden;
7 C: M* M4 ]) x$ e- Y6 L* ?9 J1 H}! U5 v+ q3 x5 D* R: e# `
</style> ]4 T( ~$ K; [( v
<script language="JavaScript1.2">$ ?# m( Z: b- ], h. V! c
<!-- 改变下的字体的大小。颜色-->. _1 r9 b/ F5 T
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" |$ F$ s6 N" j: u9 P- m8 G) ?var hidetimer='';
5 s% i r9 k5 b/ D2 d0 s<!-- 改变下的弹跳速度-->" n: S/ E9 e7 a, _: ~, _! Q! \
var BallSpeed = 20;6 K( F* \' u, q5 T
var contentWidth;
8 v/ y) N* ^% Q, A' s. }! Nvar contentHeight;- _8 {' x C) L( B& h# F
var maxBallSpeed = 50;) `6 T$ z8 N" F/ ?2 k( y
3 G3 i2 f, V: Z& w( x9 d. X: d* M$ s- M: x
var xMax;7 ]! y, H# }! }- Z% W! [; A- Q- P
var yMax;
. `3 v7 U- Q& j6 O( a7 u8 a/ |3 |var xPos = 0;7 j+ H! ^* _5 w2 b
var yPos = 0;
% n0 y3 ?' A7 Svar xDir = 'right';
J* ]/ _: m( [1 o# v' i# o4 {var yDir = 'down';
$ i* T; {. Q! I) P- Q9 Evar superballRunning = true;, R+ t# o/ ~) d/ X
var tempBallSpeed;5 W6 D+ j/ N- [* ~% k0 g
var currentBallSrc;! @7 d: J2 K# r- w: @7 M/ |2 \
var newXDir;
4 G0 D4 y+ h4 d; ^7 _+ y3 }var newYDir;
$ a# h) @+ ?, P1 u* f( k# P% R S/ c9 X
function initializeBall() {; [ v6 w G% O3 ?" {! }0 ^4 p. U
if (document.all) {1 q0 Q6 O% p" r4 I# T. N+ C% ~( k; v
xMax = document.body.clientWidth8 x( c: p9 M6 H7 C
yMax = document.body.clientHeight" v* s' N6 @% m
document.all("supertext").style.visibility = "visible";( j* F9 S8 f$ d6 ]
contentWidth=supertext.offsetWidth: T0 P2 v- g ~( N; [
contentHeight=supertext.offsetHeight# x( I2 z5 W$ q- S$ F- ^
}
2 U5 d3 I8 Y4 W y else if (document.layers) {
" I# O% I1 s# H* b xMax = window.innerWidth;
! b# Z* ?3 V' i6 N* g$ a1 n! m yMax = window.innerHeight;8 ]6 ?/ w5 \9 M: o- H7 n1 M- S
contentWidth=document.supertext.document.width
/ ~: S0 B9 n/ `1 ~/ f8 U+ e, w contentHeight=document.supertext.document.height
: k0 G" l( u9 z# P8 p6 U1 C4 Q document.layers["supertext"].visibility = "show";+ P& @ f5 X' J
} R! N; u( u3 F, S3 X% z4 q, h5 Q# ]
setTimeout('moveBall()',400);( S# T* Z( s3 [8 A+ f" ^; [) \
if (hidetimer!='')0 w; k! ~8 K4 _/ }
setTimeout("hidetext()",hidetimer)
% A; V& o% ?- ?9 ~ }" f* d6 L6 r9 F, G
: C' Z4 I# A) f. z S. O
function moveBall() {
) L6 h+ t$ @) h* h7 @+ g if (superballRunning == true) {7 d* o% P+ P0 x0 w* l, I
calculatePosition();4 A5 b$ y; i5 D) }8 N6 |4 g
if (document.all) {! e% F+ d! l% ] j7 M9 c1 ~; n
document.all("supertext").style.left = xPos + document.body.scrollLeft;% B4 G# W+ ?9 q. Y' w+ D
document.all("supertext").style.top = yPos + document.body.scrollTop;6 I* g' d1 |% j
}
) @, `+ R3 P) H& L/ \# U else if (document.layers) {/ S8 X. D+ n5 j5 n
document.layers["supertext"].left = xPos + pageXOffset;8 _% m8 r& L! r0 F
document.layers["supertext"].top = yPos + pageYOffset;
w, h9 D; r1 F' R }" N- c3 B. C. o, k. j- q
animatetext=setTimeout('moveBall()',20);! t' p; f* ?. ~* P( c7 e
}) l# t3 `8 T3 r
}3 j! r* a3 V! a
; d/ Z4 Q( R7 S8 `0 X$ p
function calculatePosition() {
( v+ E$ \9 x: p6 i; N if (xDir == "right") {
# X" C' z9 _6 T" k! Y* O u. V' x4 n2 D if (xPos > (xMax - contentWidth - BallSpeed)) {
7 X0 J B: X! t* m8 P$ _5 X xDir = "left";8 F8 f1 p& l! V8 G y# V0 ~' G! z
}
& W6 C5 v5 V, H/ e# a! r }
) t5 m4 l1 Q( s3 b! i7 v else if (xDir == "left") {7 I( b8 ^. U7 G7 n) R
if (xPos < (0 + BallSpeed)) {6 a; U! C( { P/ H
xDir = "right";) F7 q' @$ ?6 ?5 y! \! L: ]
}
# X* @' ]0 }( X0 l }" b- z+ c' W( _! |1 M
if (yDir == "down") {) m( M' V' b8 J! z. L! ~
if (yPos > (yMax - contentHeight - BallSpeed)) {/ n& D- o8 [! O* ]8 }
yDir = "up";
6 p4 [ s. X; a1 L0 h, G }7 E6 f f6 c* J, W
}6 u3 ~6 O# Z( r/ p
else if (yDir == "up") {
9 j; s2 {- ?. R! t* i if (yPos < (0 + BallSpeed)) {
v _# ~3 f8 i- a yDir = "down";: l+ d5 \+ y) V5 D* B
}
! u4 O" L: s7 s; B( y }
- A8 X1 _: B! }% \ if (xDir == "right") {
! k- u; S* i- ?) A9 h xPos = xPos + BallSpeed;
- W+ n4 s: u/ l# `: c: l4 F2 i }+ {. e7 `2 N0 c4 y
else if (xDir == "left") {
( I: Z& z6 u. Z% P1 O+ P; z' ~ xPos = xPos - BallSpeed;& c m& Y2 }9 a2 u. K
}
$ b1 t/ W9 {0 q2 u else {
2 W/ p) D/ V3 l, Z: ^ xPos = xPos;) x0 `) A% o r( u, a: J- P7 x
}# c0 L* l8 f" r8 h3 R# p
if (yDir == "down") {
3 x! M V0 W. D* n% R yPos = yPos + BallSpeed;; x$ _# G; N) V! @7 Q! j
}
3 D6 l2 r0 W- m+ [ else if (yDir == "up") {
' J4 T$ R; _5 f# t yPos = yPos - BallSpeed;$ x# q, h" ^; Q8 p
}8 Z; c2 f5 Q. j9 Z+ q7 }! V9 ^9 o
else {* i. N* }. d5 A: s$ d; q; s# T- \! J3 D
yPos = yPos;' ^' [* C. i) H4 V
}$ R6 P& X! r3 M0 q, n
}
$ @; w( V% B/ B% K. f+ s- f" T
5 n% P1 r7 i" T% B( _8 a# K9 Vfunction hidetext(){4 i6 ?& ^3 O( I0 a# _
if (document.all)& z" R* [' Z. h$ k) Q+ p+ O
supertext.style.visibility="hidden"
: j. Q& ^$ n, n) e) \" xelse if (document.layers)/ _1 I% H0 s" {( r: b6 o& M3 i
document.supertext.visibility="hide"/ c+ E1 E7 K8 q* U- Q' L
clearTimeout(animatetext)( c' m" H4 r5 z% K) N
}* U$ D O# r' L6 _
% P0 H/ u* v2 C$ `- }
if (document.all||document.layers){3 D% n; F B8 @, K/ X1 P
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 }1 G8 |6 B) ~1 D# h+ }1 V" xwindow.onload = initializeBall;/ q, d8 c* a- y. K$ X
window.onresize = new Function("window.location.reload()");
0 C1 q$ z. |" a: v}( b3 l2 l9 Q# Q, a
. [$ V0 L7 n8 C" k( m. F</script> |
|