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

|
网页之不断弹射的文字-特效
<style type="text/css">
2 @" `* [4 V$ ?# q/ L* |#supertext {' H! _2 w8 a7 A7 D$ Z% _
position:absolute;
4 k- r# k% x+ h+ r+ t& bleft:0; c9 i- ?! E3 ^
top:0;5 I, d- s: U0 b$ F; Z: k( _/ D
visibility:hide;
2 J, G/ G/ s! O9 v; H& {) u6 y7 rvisibility:hidden;" x% E* q" N0 u0 H! J
}6 s" H1 g5 u% P
</style>9 E [# u; l/ e* l6 e
<script language="JavaScript1.2">) g/ `" L6 N! p( _
<!-- 改变下的字体的大小。颜色-->) [! f' \2 B- E _( g
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
: ^; ~9 u X' r i; j: A! w2 bvar hidetimer='';/ t( F& P5 L- e+ |4 R. G
<!-- 改变下的弹跳速度-->5 ]+ `1 d4 b7 l+ o
var BallSpeed = 20;
- c: A$ D- O+ i; \var contentWidth;! h2 e; T' N% I( F( b; l
var contentHeight;
1 `! ?: ^5 X# x8 D' Evar maxBallSpeed = 50;$ Y# _) Q. \6 }! x2 J: ?
' m4 M( w# y' m- N( X9 r
8 V% ~/ k$ C. r2 mvar xMax;5 k N& v, u3 u! V; d" ~
var yMax;
! w3 |! ^$ x5 nvar xPos = 0;
. k$ F: n0 f7 p, T1 bvar yPos = 0;
- |! t! y1 Q- C. E ]+ v8 N& fvar xDir = 'right';
9 F) V( @' D) v# Kvar yDir = 'down';8 e& T* d! T2 H/ f1 ^: }
var superballRunning = true;
# G5 I$ x8 h- H3 v$ _. g# Nvar tempBallSpeed;, c8 _! F- A2 s' @4 v6 F
var currentBallSrc; v r' o+ s8 K1 N
var newXDir;
% q6 P; e& b# T! o7 h8 rvar newYDir;
* T7 ]$ t4 }; F/ t/ x/ d4 {3 z2 E0 L ?. h! l# _& O
function initializeBall() {
0 u# z3 t- o. i. C3 a. B( P0 _ if (document.all) {8 i6 \5 R8 B5 h" d3 C
xMax = document.body.clientWidth
3 F2 G/ i8 p Y; H yMax = document.body.clientHeight% f0 `3 H# d! W% j" P1 O% L
document.all("supertext").style.visibility = "visible";
' p$ d8 N" L; Q# G! L+ x contentWidth=supertext.offsetWidth6 X7 g w! r6 B1 t; L3 J
contentHeight=supertext.offsetHeight
" j' Y, ]1 c, }- u( t }
0 b0 r$ v _. ^9 M' S) L else if (document.layers) {: S- t7 q1 g' o7 B5 t
xMax = window.innerWidth;
4 N' f z+ W8 `, Y yMax = window.innerHeight;2 T, U5 T2 S6 W( t% a
contentWidth=document.supertext.document.width/ F9 D4 d) g5 E/ i7 J& N
contentHeight=document.supertext.document.height, r) E) n9 O% v
document.layers["supertext"].visibility = "show";3 e8 D# q7 ~8 H
}1 `0 l Z5 c# s; @
setTimeout('moveBall()',400);
) ^: l6 m* \/ T9 B9 w" _: v if (hidetimer!='')
4 F6 s! @8 N! B" l( i' b setTimeout("hidetext()",hidetimer)
* O% n0 _4 V8 p, O' V2 U }0 X# Y4 L8 Q# s3 [4 w
4 T/ |# h( \; m
function moveBall() {
4 @. c! R" ^7 p# L8 `- b s/ f if (superballRunning == true) {
5 h1 y: h0 B* {2 V& `, h5 D calculatePosition();
% n5 m( W1 D6 b$ Y if (document.all) {# F7 k% U1 f+ O- |' C* M6 u
document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 [7 @5 G0 V9 E0 b document.all("supertext").style.top = yPos + document.body.scrollTop;$ U6 z: `( w+ y
}* \; Q( Z: S: o" E
else if (document.layers) {* N [/ J9 v3 N" ^1 B; D; D, D
document.layers["supertext"].left = xPos + pageXOffset;
8 e0 ?, U2 v0 K, ?+ [+ e2 Q document.layers["supertext"].top = yPos + pageYOffset;& o! E* i6 i+ x5 W. Q) S
}5 G# t. _3 R( H0 E7 u
animatetext=setTimeout('moveBall()',20);/ J& n( K% }, g5 b' ]# r5 p
}/ E7 L- d7 b- i
}5 d9 L( U) i3 v6 [
5 G$ v4 l. k% C1 F. D) W" Qfunction calculatePosition() {( z( o( S- s; w% }
if (xDir == "right") {* H" f! G, n. E$ ?
if (xPos > (xMax - contentWidth - BallSpeed)) {
) t3 h6 R% x1 Q" {) L xDir = "left";& @2 R, o7 w. C# o# n
}
$ F5 o& i( E' c- X1 K, S4 k }; n* P: n& Z* @ o% K
else if (xDir == "left") {
$ V4 A! E5 U- l2 f# O$ w5 x if (xPos < (0 + BallSpeed)) {
, O8 A, Z2 f; _. R, N. A7 S1 L xDir = "right";. Y" p) z% `4 c
}" g; ?& S- l4 a9 B! w
}% X# ^' V+ `0 m$ ~+ K( R* e
if (yDir == "down") {0 a$ ?) z5 c) Y
if (yPos > (yMax - contentHeight - BallSpeed)) {. |( q- b" L2 w: u# u: d# ~( r
yDir = "up";
/ @7 G8 x. _' |) g* b }
& S" ~( `3 E' [. J }
( A8 X2 o( }9 {. Q. R5 ~ else if (yDir == "up") {% v2 _+ B4 B: P9 O' Z. c, G0 a
if (yPos < (0 + BallSpeed)) {
& [( A) L6 N6 N9 r3 b yDir = "down";6 e! q& F( H0 l8 c8 O! i! r
}
: ~2 L3 H/ L% ~' V0 }$ @; ? }
3 R3 h& ?* o5 ~0 g+ @* k if (xDir == "right") {2 k3 H( ]2 @8 t3 S# b
xPos = xPos + BallSpeed;
4 ?+ W; w* Q# m" ]% H }
/ c$ m5 o" D( K( C' V1 V else if (xDir == "left") {
# {6 c6 Q Y, M1 y; r8 t, ]5 k xPos = xPos - BallSpeed;! q. E! t0 M5 L+ N8 o) C. ]: v
}
/ V0 q. f+ P% r7 b$ Y o# d else {
% ]; c) `" R, \' l% J xPos = xPos;2 \( i- `( h" ~2 w. H$ V
}
+ r6 f) N- i8 j! i' p if (yDir == "down") {6 U1 q; l( r4 T+ U2 R8 x6 ^4 U" n+ x
yPos = yPos + BallSpeed;3 h9 a% q \" n
}
$ X% S/ s6 i, e2 L8 k* ` else if (yDir == "up") {
& R9 E. G& @0 V2 A% K yPos = yPos - BallSpeed;$ T; g" P" v, L" \+ q
}- D9 m9 K% P! i3 h O/ D4 w
else {; K9 z5 p7 J& R, @; u
yPos = yPos;$ l! |. Q9 e- L# O: x8 \
}
6 S, @' ~, V2 N }: p2 w2 Q3 |6 D \ A" U; D: x! y
+ \/ G G9 E5 I% v) \# R$ {
function hidetext(){0 K% G7 q* [; b& ~. a Z
if (document.all)
' k8 X; Z7 S$ y$ U+ h1 y! Ksupertext.style.visibility="hidden"
5 k1 S/ f) G! G. ]. U! relse if (document.layers)
/ I* z/ R# ~6 t% ldocument.supertext.visibility="hide") ~% `( M0 @; w" p: s. z
clearTimeout(animatetext); l( h# M P7 S) U, h& f
}3 M% P4 G3 e1 t
8 }- X/ f6 N4 r0 ^9 x/ _if (document.all||document.layers){
1 {: |* q5 W' i( l+ c Ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')" \* u7 \' P. I0 m' B9 S
window.onload = initializeBall;
# o: G. _5 }3 J" T1 dwindow.onresize = new Function("window.location.reload()");
$ W6 j' y6 h- R9 w- d, j- k}8 x. i1 g& F! G a ]: C5 J" Z" S
7 w; w1 |( m: f9 F( a( D+ N
</script> |
|