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

|
网页之不断弹射的文字-特效
<style type="text/css">5 X! M! a9 Z7 f9 E w; _
#supertext {# ?- y, x5 K! m6 N
position:absolute;4 W3 A6 T" S4 x+ o# U8 O8 D3 Z
left:0;
3 _" u/ i+ E8 d2 |4 etop:0;
8 i" f: P0 X( }visibility:hide;! L# ~) e7 A; r; V) U
visibility:hidden;
$ W) y$ v( _3 v! {0 J4 [* v2 r5 A}" r" ^% k5 l' R
</style>6 C/ x# I, F, x2 ^' H. `& I
<script language="JavaScript1.2">/ e- j" F( E% |1 Q7 @% g+ T
<!-- 改变下的字体的大小。颜色-->2 b. _- v/ l% Y5 L
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 x( n `3 U! }* X( Evar hidetimer='';" V% m, J1 Q. l y
<!-- 改变下的弹跳速度-->8 O; E( _ d+ H) \% u) ^
var BallSpeed = 20;4 K: N- r9 s, ]3 t2 Z
var contentWidth;! z5 J- o7 h2 Y& X1 n' g
var contentHeight;
$ d* l, ~$ \6 K5 }5 Z( ~* [& g6 \var maxBallSpeed = 50;6 F( d, N; \7 c b/ W
! [$ R6 e& Y1 L& t0 J# J
, B; A. p$ P! ovar xMax;( r* L) j6 [: T. N4 Y7 U m+ A% x
var yMax;$ {7 }1 i$ z; n9 }! `; Z( S
var xPos = 0;! e6 H( |( a. Z, i z d% w3 q
var yPos = 0;/ E0 z: i& y1 k- D* m
var xDir = 'right';& @, x% z, P! h, g
var yDir = 'down';
. { I* s# t4 x* ]var superballRunning = true;
5 `8 }4 j/ Y& F9 l0 e, Nvar tempBallSpeed;0 f& G# W N3 _+ R
var currentBallSrc;
/ @" X& J6 U5 B3 x- W# C/ Hvar newXDir;/ p9 _" i/ q/ Q! M
var newYDir;
* C7 z" u/ `5 `# J
$ y. M4 @1 g: v( \: Kfunction initializeBall() {
$ V- F- Q+ ?' ~. }5 v, R6 n/ y7 r5 d if (document.all) {, V1 N4 c6 @1 | ?
xMax = document.body.clientWidth
% R7 B/ S* V o. r yMax = document.body.clientHeight
3 j4 J' P! ?8 O/ u$ k' B7 ~ document.all("supertext").style.visibility = "visible";
+ H7 l- ]" [1 ~9 ~, U contentWidth=supertext.offsetWidth I# @ B; |% T8 b( X/ W- w
contentHeight=supertext.offsetHeight8 o' {# d2 k. E/ z7 j
}
5 `0 q6 m# o3 H' ` else if (document.layers) {
# z7 V' n1 J" k k1 a9 ~' V, o r xMax = window.innerWidth;
/ N0 d( s2 Q# d9 V- k yMax = window.innerHeight;
, ` v& V) x( O- a& y contentWidth=document.supertext.document.width
) I! h- Z+ P/ D) Q: X/ f7 D! |( z contentHeight=document.supertext.document.height
2 g/ ]+ {- }" ~+ h8 T document.layers["supertext"].visibility = "show";
5 f: ]: n4 E/ m. C7 B3 N }
# P- B& c3 y2 q: R setTimeout('moveBall()',400);
- F( q& v# ?* R) P$ T% o% e; r if (hidetimer!='')
# y' B% t" x/ p% d D3 g; J setTimeout("hidetext()",hidetimer)
) T( e6 ~/ h9 z* ]5 I }
) ]8 M* A1 s0 i2 L8 s- m: ~5 {# ~: P# J9 U% q7 c( q" j$ m6 B. ?
function moveBall() {
/ o4 T& M/ }- }3 R if (superballRunning == true) {
5 ^: Y& S+ h( A3 t: S calculatePosition();
/ \, C6 P" D" \9 [ if (document.all) {1 C L; p3 X# w6 W+ C2 ?" m& B1 C
document.all("supertext").style.left = xPos + document.body.scrollLeft;$ R" G7 W2 i: G( Q
document.all("supertext").style.top = yPos + document.body.scrollTop;, O1 q: _$ k2 K5 n, t
}$ V S5 C8 e6 i# P/ S/ c% P7 f
else if (document.layers) {' F7 Q" f2 p7 x) W) ~
document.layers["supertext"].left = xPos + pageXOffset;3 j6 _ K2 y7 j& b3 o6 w
document.layers["supertext"].top = yPos + pageYOffset;' I5 D( q7 z. Q8 D! q7 L* a
}
6 G$ @3 z. _4 q) L animatetext=setTimeout('moveBall()',20);
+ @& M3 h5 g+ r M4 u! I }
0 T, E( a0 D9 O6 ^- u }
+ G5 j$ d) x8 ^3 E, D" ~, n3 A
7 K. H* V3 f$ F0 f& I( z! `function calculatePosition() {
, a8 I0 T. @# Z* ^/ G" Z. L% F# d/ b if (xDir == "right") {9 N9 p: T& V% \1 x; S1 ^+ D
if (xPos > (xMax - contentWidth - BallSpeed)) {& S2 C- T1 [7 g! I5 f0 g; ~
xDir = "left";7 r. `6 O; f7 q' P. i: m8 n
}, N# _6 ?$ U; W( g2 z1 [/ X4 y8 M
}
9 K! i- N: C3 L$ d- O% i, W9 ] else if (xDir == "left") {
g. J4 i. F5 s2 _# O if (xPos < (0 + BallSpeed)) {7 o r! p9 s5 K1 D# S8 K2 \
xDir = "right";
& x( [. ^" H8 w, F2 z }
; U, D# J; }3 c0 C& d- I/ q } ~6 S: C* \' Q$ x/ N
if (yDir == "down") {7 i* q( f1 [+ f: O) x
if (yPos > (yMax - contentHeight - BallSpeed)) {
1 I2 d5 a. c$ g) u2 q yDir = "up";4 X% @; E: g4 P- f1 L% X( W
}
0 \3 C2 i U1 a) Q5 ` }
V+ F* P, }) ^ else if (yDir == "up") {6 A3 G; i: E/ h+ w* T, X
if (yPos < (0 + BallSpeed)) {( e' P$ _/ m0 y* z0 Q. Q
yDir = "down";
* p( q6 q4 |7 H. }0 ^0 w" k9 N+ | }; Z/ }; Q/ W; m/ B9 v7 J; Z$ g
}7 c$ u9 e4 b+ p/ W; f0 i
if (xDir == "right") {
) Q X" Y: P( [2 @ xPos = xPos + BallSpeed;
) l" x t7 X) I }
3 ]' x+ _; @$ I; x8 m4 P, a3 i0 ^8 [ else if (xDir == "left") {7 |1 p1 B& M7 r0 E* J* n2 E/ C% y: l/ r. Z
xPos = xPos - BallSpeed;
/ j0 _/ K7 v9 `5 Q }
$ X+ {& S% H a7 D( Y else {
( \6 F. B& \' f% G* q2 P' a xPos = xPos;& D- Y% p3 K3 W5 e" T! Y, I: v
}/ b$ q3 U+ {' b3 n7 _& r
if (yDir == "down") {
+ \# T" B. x% k4 j" _$ y$ r; }- ] yPos = yPos + BallSpeed;
# Z9 i- U9 D1 {5 }, O& Q) h }: [& B; O( U# b
else if (yDir == "up") {
% D& ]9 `" J7 @2 l yPos = yPos - BallSpeed;, B0 w, l! c* ~5 P$ i d
} j9 O3 a+ [. j8 F' d y
else {" \! S# X/ U' S" q% W0 y
yPos = yPos; p% E# V7 W; Y- U/ l
}" C% O6 z" u/ P7 p4 e6 [6 B
}
( ?+ I: l4 k: a8 \% n: w0 d9 F% S
function hidetext(){! m2 w9 g8 f) ]& W
if (document.all), ]% s6 D3 w2 l8 F7 K, _+ i. L
supertext.style.visibility="hidden"
& ]1 [5 |" g2 Xelse if (document.layers)
( i' N1 q" g9 X" E# E8 j" ]document.supertext.visibility="hide"- ?/ h9 H* c, H( ]: B/ W* T/ u" W
clearTimeout(animatetext)
* r$ D# L. C5 T- C}
9 U' X& z; a) D5 M0 b$ p" H
7 J M7 u, ]- q) R4 ?9 bif (document.all||document.layers){/ C# @; f( w; F
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& }% H( M8 y* X/ ?
window.onload = initializeBall;
+ t6 h: l5 {6 |0 _: L" U2 m/ Zwindow.onresize = new Function("window.location.reload()");
9 @( H, ~* C" ]}" e) t9 G$ e F7 i" I# [
( N* p9 X' T" b2 A* a. m! M</script> |
|