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

|
网页之不断弹射的文字-特效
<style type="text/css">! l; A' y$ {0 G* C4 A3 Y$ M
#supertext {
# P9 I; y" I0 U" gposition:absolute;
) _( w! W1 ? Ileft:0;
4 g& A9 t0 N" c7 ]( Rtop:0;' _5 O, Z- B* Z$ y8 T
visibility:hide;
" g& D- i3 Q" ?& qvisibility:hidden;8 R$ E9 S8 C2 I* U; p3 E
}) e5 n9 P+ j; q
</style>0 |9 ?! m8 B+ ~0 t5 c* `4 E# V
<script language="JavaScript1.2">
4 g# ^- e b" z) x<!-- 改变下的字体的大小。颜色-->
# f4 Z& Q3 `. q$ ?0 Z, I \2 Rvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
$ Q: I! ^* h+ N6 V& ], J) cvar hidetimer='';
" U' }$ P6 ^' b* k% \<!-- 改变下的弹跳速度-->2 d8 E2 x! S" p/ H c; t- y
var BallSpeed = 20;! \1 n9 F% u3 m0 t6 N4 x# w
var contentWidth;5 b- Z! J1 K- @- L% v" |
var contentHeight;
3 S& T0 w: ~, |/ ~+ vvar maxBallSpeed = 50;0 n# l( l( L! a
. @6 B# t! q8 k! S. x/ L/ S2 x1 Z7 P5 c. s, L
var xMax;1 M" g2 ~) K6 ]* T; i9 s
var yMax;
@$ ^+ P8 k: \8 D% V0 o% K! X) svar xPos = 0;2 Q* E; Y e: o7 v6 t k
var yPos = 0;
5 B5 D/ V9 _1 d/ Q" d, zvar xDir = 'right';2 O; ?; o* m$ I1 U2 X9 t
var yDir = 'down';
2 s9 k" E( y1 F3 g2 F5 Wvar superballRunning = true;* W0 X4 J5 _% I. @! @4 S5 u
var tempBallSpeed;
7 B9 m# t: `/ N3 F) u F9 zvar currentBallSrc;
# s5 v1 G( n' V9 [- I) D; Yvar newXDir;" O# U3 U o u9 m; z
var newYDir;0 @. e8 S" J1 N; Z3 y g, M
' g5 n$ _) g/ Z0 C- s1 N4 Yfunction initializeBall() {
5 N( O5 @5 X8 ?- Y7 L8 w if (document.all) {& `3 M4 f& l* K
xMax = document.body.clientWidth
0 j: Y7 `8 w1 c% T7 X yMax = document.body.clientHeight% d2 l) w8 @8 g! E' R" B
document.all("supertext").style.visibility = "visible";
/ ^% m- b9 D& H% x1 Z5 F contentWidth=supertext.offsetWidth0 P3 @$ G K/ f9 s9 f
contentHeight=supertext.offsetHeight# k/ W; ?* a* s1 M( L
}( F% z) o: |, e2 e! ^/ g
else if (document.layers) {
% L+ J" |9 M9 ~+ | xMax = window.innerWidth;0 ]# U+ b3 d+ o! V/ d7 I3 o% T
yMax = window.innerHeight;+ o' }: `4 g3 b; j; C
contentWidth=document.supertext.document.width
7 _' F6 F- e6 x1 j contentHeight=document.supertext.document.height0 `; F( }/ y1 ?" r" V
document.layers["supertext"].visibility = "show";6 Z! \- p1 c* `7 a6 s6 T
}% P; Q( x9 c+ Z: U. {
setTimeout('moveBall()',400);) c; l# x3 A; R* p9 A" H; M
if (hidetimer!='')
3 T x% f1 _$ y setTimeout("hidetext()",hidetimer)6 c) K) U: K" b! p
}: m$ O$ J- ]& a, A, Q
, S; W% E ?2 U7 h4 d
function moveBall() {0 j$ _8 l8 \+ [. N f. m
if (superballRunning == true) {
1 G* r+ ]- s& R$ X& d. l' e calculatePosition();6 ?& a6 B! L) ^% `
if (document.all) {
6 M. a3 _( h- V$ Y3 ^* W4 n9 z* h document.all("supertext").style.left = xPos + document.body.scrollLeft;5 E- F: l5 e# `1 {9 r ?: K
document.all("supertext").style.top = yPos + document.body.scrollTop;# |' i' n* ~) |: B+ N4 E
}7 n( q/ P5 J6 s+ d( ]0 q* T4 V7 D
else if (document.layers) {0 j$ v W' `3 t) N+ j2 y1 s6 {& K
document.layers["supertext"].left = xPos + pageXOffset;
6 w! f1 Q4 [) g* [: N' {( r document.layers["supertext"].top = yPos + pageYOffset;+ _6 L* l2 y; R0 i
}
7 G+ Y4 _/ n* u) N" f5 ~ animatetext=setTimeout('moveBall()',20);
: b8 m: u. J k5 F& u }+ a% |( i; ~2 U7 W+ S3 [
}
/ F) b/ }, e2 k2 y1 X$ B# W$ S1 x" X3 C L2 `
function calculatePosition() {
1 s5 l+ f' I8 \' p# _0 h* c! ?$ t if (xDir == "right") {
* w$ D$ A2 T: n1 J% H9 v if (xPos > (xMax - contentWidth - BallSpeed)) {
' {7 J/ N+ N5 ]% j9 j8 [( Y xDir = "left";
3 n! j" ~% M7 \) Q, x+ o }) i9 A) z0 S+ h. G8 Q' I, r7 g
}) z3 N6 L1 ^! k$ g
else if (xDir == "left") {
; D \: k* v& \6 L5 V3 ~2 f# F. a3 f if (xPos < (0 + BallSpeed)) {5 g& w; `: ^0 z0 M' q/ Y) f
xDir = "right";
! r, ^8 a8 }2 e" F4 Y }
! F: n2 Q8 H& F }
) n+ q4 k9 P$ q5 M o! v1 f if (yDir == "down") {( M' g4 m* h! f4 a# j1 W
if (yPos > (yMax - contentHeight - BallSpeed)) {5 {( V4 X3 Y3 R) T+ p" R( r
yDir = "up";
6 X' c+ O2 E) k% Q: `* o }+ s7 |; a; X N0 [; ]
}2 @6 A1 z/ Z# D( Q% c3 L: k: `
else if (yDir == "up") {& \' x' W; P6 f& S/ V
if (yPos < (0 + BallSpeed)) {: o/ b( o% o2 K
yDir = "down";
8 I% \& i* q2 O& Z' d: R4 T }: `7 Z9 ]% P7 ?% w6 x1 m8 v0 @
}7 n$ v$ b4 l- n$ F, h
if (xDir == "right") { o6 Z4 j- A$ d( U, G' }
xPos = xPos + BallSpeed;" Q9 M- ~# V3 L3 h$ S5 B3 _) {
}' V) i4 ~, m3 U# T/ s/ w! `% m
else if (xDir == "left") {
, \. T8 U1 n5 r$ p( K4 z xPos = xPos - BallSpeed;
% `; c! m8 F* ?3 V9 V# h: f: b5 a }
3 \; k6 f3 b# [ else {
. } B2 o( Q$ g xPos = xPos; T, e( ^0 {1 P3 {. b* R
}
# @1 R" Q: U. p if (yDir == "down") {
( S) N5 V4 w1 I5 q- j. l0 ] yPos = yPos + BallSpeed;, W ~3 b+ h! R7 D$ ^3 ]9 g$ R+ Q
}
9 d0 ` ^5 ?! O. m) ~+ G7 \ else if (yDir == "up") {
, C3 h; T1 L) q; I yPos = yPos - BallSpeed;. ^" l! X1 m. ]) J" Z$ y& Y6 b L
}/ |% n; R5 K* M0 H- `) k
else {' M/ F4 S1 K% p" K
yPos = yPos;4 B& G+ M! @% q# X9 L
}6 w2 j" }+ d1 B# Z, q2 {) b
}, Z- y) n' i; `
9 y" O4 a1 B: ?% X- \5 F& D
function hidetext(){7 x0 S* |; \" o
if (document.all) U# V, [0 g2 S7 V- E
supertext.style.visibility="hidden"
% d G! F2 o6 ]1 gelse if (document.layers)/ K. E/ o/ q# J2 L4 j3 \
document.supertext.visibility="hide"
1 E7 G* s; z* r4 y. E* A% GclearTimeout(animatetext)$ K+ {$ N: |) E% z8 M* ~" G
}6 y+ d1 _6 F5 }9 l( _* h/ B* r
/ R' u" u4 [4 |; c* U) v" C% oif (document.all||document.layers){$ m0 T g, g1 h& h* @9 {% R
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')5 f& S" l6 g+ z' B( m
window.onload = initializeBall;& n, ~3 V6 w7 B7 C+ I3 L
window.onresize = new Function("window.location.reload()");
! S8 m* X: L- ~: O" Y. G}
) h4 i. S3 x+ U, @$ X! g
8 f0 X7 X' h* p</script> |
|