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

|
网页之不断弹射的文字-特效
<style type="text/css">
- g: ?' r! J" ?* @! n#supertext {
$ k' D+ _/ v; ~% tposition:absolute;0 f6 Z* p9 \+ x! @( i
left:0;3 v- `) `# [2 t2 O* _
top:0;! Z2 x: A. k" e/ Z, m" Y
visibility:hide;
7 H+ E' O8 ~3 \1 m# {, Ivisibility:hidden;* p7 t3 W6 z% e; V2 w* ?
}; C' G# M, p4 E' u% R' w
</style>$ s9 v2 {8 `* N" L7 F9 v
<script language="JavaScript1.2">
( o3 W0 s/ i0 g( f O<!-- 改变下的字体的大小。颜色-->
, \0 t* K3 i% a+ \, I" o" m/ hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% ^$ V6 ]* r6 Dvar hidetimer='';
, C. Z7 X" l+ O7 \<!-- 改变下的弹跳速度-->2 V$ s. t, Q; ?% K
var BallSpeed = 20;
/ ]: X4 G) F4 A2 L* D3 Fvar contentWidth;
- @8 ?$ r6 B' Vvar contentHeight;( I& |$ U9 \5 X" y0 t/ ^- A
var maxBallSpeed = 50;
3 `" D! Y0 o: m. x5 z( d7 V) [" U$ Z- D; l. E
2 }5 s$ C w2 A6 X; b& f; B/ hvar xMax;" D. U8 |3 U! S! S& P, G* n' q6 U
var yMax;
# a2 L9 t8 B4 c7 T: c, _var xPos = 0;' W# F1 ~6 ~( [# B8 b+ z
var yPos = 0;6 L3 i$ C7 J* w! W) @
var xDir = 'right';
) W$ N+ p0 h5 I0 [! jvar yDir = 'down';
( f: r4 u/ m# `" W' d( Ovar superballRunning = true;6 h( N+ T+ c5 e' C
var tempBallSpeed;; r- J9 `$ _) ~. x1 e y
var currentBallSrc;! A# l# R B& I& i" a1 j( q
var newXDir;& W8 U7 R/ I, p9 a" \1 R
var newYDir;
" a+ O8 B+ U7 w7 Z& ?$ w8 a1 I8 E
function initializeBall() {& q" |; J3 Z- c7 i3 n% u
if (document.all) {$ o; ]3 P' I6 t& V8 d
xMax = document.body.clientWidth
$ F0 R* _% ?0 ^& I2 H yMax = document.body.clientHeight
& t/ m i, D( b$ V; s document.all("supertext").style.visibility = "visible";2 H$ B2 M0 ^/ A
contentWidth=supertext.offsetWidth; [( x8 t! g4 W2 [& U
contentHeight=supertext.offsetHeight1 |- \& m3 `. O& q2 C" Z
}
2 n& L9 T# c5 f; ^% o, s else if (document.layers) {' I, Y$ @+ z. `$ _
xMax = window.innerWidth;
( N& o% P) s! N! J7 [ yMax = window.innerHeight;
+ b7 d& p( R+ m; b5 ] contentWidth=document.supertext.document.width
k/ ^4 l) {* K2 W. M( S8 Z contentHeight=document.supertext.document.height
3 ^1 B2 b9 }8 l6 c document.layers["supertext"].visibility = "show";
8 h3 k/ M5 q- Z }
3 W; g8 F+ ]8 \2 Q4 i& o, T setTimeout('moveBall()',400);2 O5 d' B0 u/ V8 }; r; }
if (hidetimer!='')
( U* x* y w9 s& i9 c setTimeout("hidetext()",hidetimer)
7 ]9 T9 X6 N& H2 z3 O) u: H }: i* h, [* x" l' T# L" [! L' M
2 m% _! ? V, r8 U% j7 d7 Hfunction moveBall() {
" J: W* L8 n( \ if (superballRunning == true) {* u8 [1 `2 G# h+ U
calculatePosition();" [5 l$ e( w3 `& s; W; e6 j
if (document.all) { x2 s( I8 q/ w! u* {4 Y
document.all("supertext").style.left = xPos + document.body.scrollLeft;
5 k9 P4 j6 r: ?4 C# w+ q4 \$ ] document.all("supertext").style.top = yPos + document.body.scrollTop;
5 ?. C) s, v2 x; R3 S }
& x' g4 P7 @1 |/ E4 U& U else if (document.layers) {
+ t$ A2 H0 `$ r. Q* y7 A document.layers["supertext"].left = xPos + pageXOffset;" S% x2 [% P# z+ u+ @0 n9 D8 |9 u6 }
document.layers["supertext"].top = yPos + pageYOffset;
1 u Y* K* q" v u' a6 A }9 z ^/ s+ L6 {+ G
animatetext=setTimeout('moveBall()',20);5 x8 |& s c. r1 `* U; P
}% z( |; e) ]% J- p
}
: l7 y6 z' `' t/ v8 H8 K5 H# C3 d! J1 y) ^, F+ b( B
function calculatePosition() {
3 J9 @6 A9 K: {+ Q- J if (xDir == "right") {
* m9 ^6 ]% c" K5 M" g# m! U% C if (xPos > (xMax - contentWidth - BallSpeed)) {: o5 D0 ?! H( a
xDir = "left";
& r* l. q9 R. ~ [$ U% L2 ` }
4 q# P4 P- K, l }
$ o/ U9 P+ [7 v& p' p$ z else if (xDir == "left") {$ f: t$ ^' r( x
if (xPos < (0 + BallSpeed)) {/ u$ @# d( {& l) r5 G
xDir = "right";
7 m- j# `/ `9 U5 `+ {. a. P: Y& }& V9 i }0 M% U0 n5 B9 w& k
}* c) D* o. `* c( Y. a( |/ I4 R
if (yDir == "down") {
9 ~- r) {4 A- ~ S' U+ ^* T* X if (yPos > (yMax - contentHeight - BallSpeed)) {
5 d2 f) J' F& S2 [5 D% Q: q yDir = "up";& C& }3 Y) y9 U( i
}
# c+ A# Z& I3 f t: i! u }
2 o3 c% h2 a0 K) N else if (yDir == "up") {' \! {5 t9 w$ m$ h+ `3 q5 @/ Y0 T
if (yPos < (0 + BallSpeed)) {2 e$ z+ q3 J+ P0 @; v
yDir = "down";
7 f1 D; A% I: @ }
8 U0 c' Y4 u6 j7 i6 X }/ T3 k c7 s! b5 N
if (xDir == "right") {
5 t5 _" g4 q; J( k6 Z2 J+ t" f& I xPos = xPos + BallSpeed;7 ]9 U4 }: t! Z4 u$ U; {- J
}
5 @% I/ s( y0 { else if (xDir == "left") {
' x$ z; o7 w# x7 r( w* ~) `& R9 a0 q4 f xPos = xPos - BallSpeed;
2 v. b6 T. R9 v* Y& o }3 ?0 H$ @$ I0 g" E& Q, a
else {
5 R/ U8 K2 ^' l5 T xPos = xPos;7 ~5 n! X" V* V& Z5 D! Z4 L B
}
% b; T; b- a- e. Q if (yDir == "down") {
) }% J+ ^& d( M2 G yPos = yPos + BallSpeed;
# }7 h$ d: \: G8 N! L8 t }
- [+ y2 s; q7 h& d2 _& ]/ _* ? else if (yDir == "up") {+ X$ z. b$ O7 ` X: L8 ^ i, p9 _0 M
yPos = yPos - BallSpeed;
1 j5 V |& Z; Y+ G } s+ C+ `; G! k! d3 O' O
else {7 ?. \( V: z6 I' v' u2 U7 M% j
yPos = yPos;( j S* J- {/ e |+ R
}5 r3 L+ ?1 [5 p! Z
} _) J+ q7 Y. V0 U `' m
: L. q! f# h" Wfunction hidetext(){
: I/ F" S0 l q) l: [) ~2 Jif (document.all)& x5 I& J: k, s5 ^
supertext.style.visibility="hidden"$ s$ q+ q/ ~% Q- k
else if (document.layers)! m+ N% x3 s! Z) ]1 e' P
document.supertext.visibility="hide"9 ]3 u v% }2 T
clearTimeout(animatetext)
' ?6 s7 f" p0 N: ~}( s" B/ U& `% J) y+ y
3 y" P0 c6 y4 `. [ Lif (document.all||document.layers){2 L4 j' d1 q+ r( G `' [
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# w/ J7 _1 U; Q- R& l8 S+ s; A6 lwindow.onload = initializeBall;
3 `2 h- L& W* k9 `2 e7 a. [window.onresize = new Function("window.location.reload()");
; b8 w3 b- d- x# G+ N7 f6 S}
* |4 I1 g& ^- g L/ d2 t
' t+ X* I. x, @6 d; a3 h</script> |
|