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

|
网页之不断弹射的文字-特效
<style type="text/css">
& W( H# }9 T" ]# Q! T A( E- b#supertext {0 Y# E" E2 C6 D& p0 U# G
position:absolute;) h' Z7 m( C3 j6 Y
left:0;
# O" U( U ] stop:0;* |( T! \. E% r& ?" T
visibility:hide;
% P2 E: D8 K( h _visibility:hidden;
1 C: n! P3 a3 V! [}' }1 m! L+ b5 g# X9 d+ a
</style>
* u1 l" |0 Z# P8 c<script language="JavaScript1.2">. [- g( G2 d% }7 h! O& W3 ]7 E- a
<!-- 改变下的字体的大小。颜色-->
. F6 ?5 s% U: v" a& f5 {) vvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ @' G: f! T3 X' g1 U5 I
var hidetimer='';
+ t% x4 i( B% q<!-- 改变下的弹跳速度-->
J! V0 \. o* }8 Q) g# l$ tvar BallSpeed = 20;
4 @1 O* f: p7 r' P U3 \0 ?' dvar contentWidth;7 c3 W% r- f/ ]2 E& t
var contentHeight;
+ A, R) [) q9 i8 Kvar maxBallSpeed = 50;
b5 P( r% f9 J: b! z& [ g6 m6 w3 ~. ~2 e. M! Z3 m5 u' H
; N8 B* j, t! ^
var xMax;
' ^8 @) \) `1 P8 [/ U" E4 v; M" hvar yMax;
6 V7 ~9 v; Y: ~0 ~* j( p6 g* Yvar xPos = 0;: H$ h) z. K. H" W- {+ z
var yPos = 0;
3 P4 T( L2 j9 ^var xDir = 'right';7 `) z+ V' e, J5 Q S# O* k3 r1 g% K7 c
var yDir = 'down';; a0 z0 W) k( r1 {, R' {- C
var superballRunning = true;4 |, A4 R, y. a5 v" C" K
var tempBallSpeed;- K3 J& J3 T7 D& Y
var currentBallSrc;! r$ Y) a u9 ?
var newXDir;
. Y' w" \$ |& @& ~var newYDir;
4 p) u* [+ }- q2 w8 O6 A7 ?( _+ a" _( {
function initializeBall() {7 s0 x8 U8 s3 m# M; A) h) Z* B
if (document.all) {9 `9 R* S; H; h) `) @+ \
xMax = document.body.clientWidth
! h# e) P3 [+ ]; t yMax = document.body.clientHeight q8 g: C6 H- @- s& N- x( I
document.all("supertext").style.visibility = "visible";
" d% n: M$ j8 ?2 s1 X contentWidth=supertext.offsetWidth+ ?- K. F o0 }' @: r( X0 b
contentHeight=supertext.offsetHeight4 S, T# M/ ~4 ~ `: W4 j
}! ~& A5 T! Z! }
else if (document.layers) {8 J. K* ^! Y, y5 z( B' H
xMax = window.innerWidth;
( k5 J3 n' F, o F" \0 n yMax = window.innerHeight;
. v/ `2 N$ Y8 l! S( q; C" D5 {* u contentWidth=document.supertext.document.width
( ?4 W3 N X2 _7 X* x contentHeight=document.supertext.document.height1 Q( K5 Y6 g5 f: \, }: Z
document.layers["supertext"].visibility = "show";
+ B. w& i% T# B5 p% k }6 @1 B' N! M# D* Q3 J9 m3 U
setTimeout('moveBall()',400);" A j# W# U: ~
if (hidetimer!='')9 I2 @ U$ T9 U7 h& \: F Q }
setTimeout("hidetext()",hidetimer)
( R# X$ t7 x' E9 E: C }
/ j' T# m2 J s* b2 |3 N* Q% Y: W& ]1 E; j, b
function moveBall() {- V: N7 r5 q/ }0 ^1 g
if (superballRunning == true) {
) ]( j* `/ {" V4 B calculatePosition();
. V+ N! Q$ x5 H$ ?. x* T" G1 D% P4 s if (document.all) {7 [# Q3 L3 J7 P4 V0 E
document.all("supertext").style.left = xPos + document.body.scrollLeft;9 _ }! \1 B/ p) K1 J1 z
document.all("supertext").style.top = yPos + document.body.scrollTop;
7 i2 c* D" `( t* f( G1 Z, K }9 F7 L+ N6 w+ d1 \6 R/ ~
else if (document.layers) {
N* G: r* w _) m3 P% L document.layers["supertext"].left = xPos + pageXOffset;' m; i" M* E' w3 s. S0 }6 Z
document.layers["supertext"].top = yPos + pageYOffset;# H4 J% N* J( o, g. N- Y# B6 Z
}
! S2 P" J( W' x: {% b1 J- H animatetext=setTimeout('moveBall()',20);
" Y3 T* y E4 ` }$ I+ C; r0 e5 Z/ l4 @
}; L* T. M7 k e N& o
: p- w- `: r/ O4 L! [
function calculatePosition() {' `( w$ d: G& b8 J
if (xDir == "right") {
3 b. C9 L3 W2 |6 }% w! p if (xPos > (xMax - contentWidth - BallSpeed)) {
3 c; L9 D/ \) w xDir = "left";
1 |+ v" _2 ^8 \7 @' d }
" l$ S' O; r% J" ~3 ^$ Q4 o }
& T5 h- }% V" ~/ ]1 E9 g" _ else if (xDir == "left") {
- b3 Z" }3 M7 n if (xPos < (0 + BallSpeed)) {3 J* y" C7 n( O8 a" c
xDir = "right";7 k9 r" `# X$ p
}4 }1 X, m# [4 W3 k4 Y" C
}
/ I+ f9 n, z, `" M if (yDir == "down") {( @, v$ w' d6 P5 y
if (yPos > (yMax - contentHeight - BallSpeed)) {5 c2 U2 }; } }! [7 U9 V
yDir = "up";
, W6 k T! A* D# C Z" e: f9 z }/ [! h' ]( m4 y# C* G7 p4 d. H
}# e# x" H9 J3 C7 \
else if (yDir == "up") {' V6 z, l1 ~% u7 `2 [
if (yPos < (0 + BallSpeed)) {- P: H1 L" M- o+ J8 y
yDir = "down";, c E, ]5 ~, f3 ]7 ~# N* H
}" ?. a I8 ?* e" g" z% y: p/ @* A: M! ], q' `
}' K+ e4 D( Y. C6 D" M' t7 h$ q: U
if (xDir == "right") {
7 V. n! T7 E' m/ i1 c) A xPos = xPos + BallSpeed;0 Z: g3 M: x( R0 I8 V
}
4 q' s5 z6 F* ]3 _! j else if (xDir == "left") {
1 i( e' j( H$ `0 ` xPos = xPos - BallSpeed;) I' v, w. h5 \9 d
}
$ Z" q4 }4 ?6 i/ p else {
! i: W- L; }; v0 Y- v xPos = xPos;
0 R0 E0 ~6 i5 r% y5 [9 {# c }
2 V6 n( Z2 H# y8 C' Y if (yDir == "down") {
, N0 ^; H! Z/ M) m3 z- } yPos = yPos + BallSpeed;; N4 b; C' o: f* N, T3 b. g' o4 I
}, n9 ?9 P- \7 {/ c) X( P
else if (yDir == "up") {
l8 _; v5 M. U* o5 {3 H yPos = yPos - BallSpeed;1 b$ B' X% Y- w Q$ A- z* M
}4 A2 v, [- q% L0 ?
else {& {/ o3 w, y" d9 y
yPos = yPos;' I+ Z! i7 s& P
}
( N& N1 n: Z f {& B }
- d4 |) N3 k. T; m2 U1 A; K. N ?" Y5 l! \* s/ V2 t
function hidetext(){
( I/ G N/ V. d" F. V. g% bif (document.all)
2 J+ Y: T4 C2 v# x L) P' Y* T5 @supertext.style.visibility="hidden"
1 e# u* W% o. l1 d: n6 H5 }: felse if (document.layers)" [ u& P: i& s' P7 W- H
document.supertext.visibility="hide"+ O' B6 G5 X2 R4 a
clearTimeout(animatetext)
' Z3 o5 N; K6 O. l" v0 `}* y5 J e) U" Z& _; L" d) @+ Q
( R1 m* a$ A/ z5 K6 |! b
if (document.all||document.layers){
, o+ V( g/ T- W3 {8 b- Edocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 @' V5 t6 W8 P1 \ N
window.onload = initializeBall;. M) I6 q5 E7 \, ?" X
window.onresize = new Function("window.location.reload()");
j5 v I, `2 q Y* d/ ^" o}
2 v% F- M, t$ A9 p' }& k' l
{' n: F% y& ~1 h</script> |
|