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

|
网页之不断弹射的文字-特效
<style type="text/css">; S; x, ] T+ C4 p
#supertext {2 c7 B/ s; X% `- x- O8 R, Q
position:absolute;
- r! x" x) f0 mleft:0;
3 X5 n2 K, _) ^top:0;
. m6 I+ @3 U1 S/ F6 mvisibility:hide;5 L7 Y) t: s+ J+ m5 S- h* Q0 D/ p/ A+ M
visibility:hidden;
2 c8 T) [1 p" h1 G- H7 e' S}
) Z, _8 X0 `3 S6 i, [: w/ m</style> n3 o5 x/ z& ~9 ]' @" K
<script language="JavaScript1.2">
) o- V+ [* J2 o<!-- 改变下的字体的大小。颜色-->$ {6 I2 X7 v, H6 F0 O5 A4 l
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
$ V% M3 R! Y1 ], W! P9 gvar hidetimer='';
! ?+ @9 d8 F" o: F7 V: r<!-- 改变下的弹跳速度-->' b Q! h+ U% }6 J; K5 M
var BallSpeed = 20;7 Y% @ ~! b& r# ]& i; @3 P
var contentWidth;
6 q& c; l' p: D' h! v* ovar contentHeight;, ]% d; o+ w: h& A, O! U4 s" |
var maxBallSpeed = 50;) O. y, f: ^8 e9 J, `& f4 a k
2 q! V# k7 D: {
5 s( {5 u- \: o; |var xMax;
: ^% k. \+ k( Gvar yMax;# E3 U w P% J+ \2 f9 e/ E
var xPos = 0;
! V* s( i* X* E. _var yPos = 0;% p, U6 T6 O# G7 i( U* h
var xDir = 'right';6 \( o. |! Q- ~6 U" Q# i+ v
var yDir = 'down';
, ]; E1 q. p" Hvar superballRunning = true;) x1 F8 ?) C# ^. M$ L
var tempBallSpeed;, r* }# Q6 }+ Y( ^2 ?
var currentBallSrc;
$ M& T* p9 \. j& z" Fvar newXDir;
$ @% B2 c, `* q' k8 ?$ dvar newYDir;: q5 i+ K6 D8 h' e6 U
6 B7 @# t1 J7 }0 ^& lfunction initializeBall() {% d6 B/ f' Q7 _6 h2 m: g
if (document.all) {
6 P3 T% g0 h1 c7 E9 J xMax = document.body.clientWidth5 @# ^- ]7 W4 O% T
yMax = document.body.clientHeight
3 J k( x1 V% }# v* Q7 Y% E6 E3 y# L document.all("supertext").style.visibility = "visible";8 |$ y2 t7 _0 n8 G9 U
contentWidth=supertext.offsetWidth- e# d5 x3 K6 ^( I# h
contentHeight=supertext.offsetHeight5 O9 \/ j$ [( d: _9 d
}7 e. u+ o6 b. G3 T+ U2 m
else if (document.layers) {
- L' Y" P4 R9 U+ M xMax = window.innerWidth;% q$ x/ z; p8 g
yMax = window.innerHeight;
' E3 _6 I4 H+ E" x! X! x& w( k2 d" K contentWidth=document.supertext.document.width+ K! u$ I0 @0 P
contentHeight=document.supertext.document.height
7 G$ R5 ~+ h, M document.layers["supertext"].visibility = "show";0 V/ ]' j$ w' v" n
}
( c: g. z- V: e" Y. S setTimeout('moveBall()',400);$ s" H9 }" T$ a3 C
if (hidetimer!='')
5 }2 F$ i. {4 q% \ setTimeout("hidetext()",hidetimer)
! P$ `9 }1 b5 X. I; h/ u }( a, T5 b2 ]7 ]# W' }
! Q. R/ f# I4 ?* ufunction moveBall() {
0 B* O3 |1 ^( q5 Y9 J if (superballRunning == true) {
7 r x4 ?" s' P" K calculatePosition();. M7 Q6 _ ^/ S: @; W: I
if (document.all) {
" G* w& y1 k/ D l$ x! Y document.all("supertext").style.left = xPos + document.body.scrollLeft;! c# s3 H6 ^: m* G& Y
document.all("supertext").style.top = yPos + document.body.scrollTop;5 j( x# R, j! Z8 [' H, {% Q. y5 O
}
1 O( e( w0 [3 u2 q else if (document.layers) {
@) L( m- ^ m+ L# A. a document.layers["supertext"].left = xPos + pageXOffset;
. s$ H! a, ~- F' }/ G' x& A document.layers["supertext"].top = yPos + pageYOffset;1 C! J+ s3 ]- i3 r' L
}+ @4 j3 c- W4 e7 e2 u5 G _3 _) {
animatetext=setTimeout('moveBall()',20);/ K. m# l( i6 w) }
}& H2 r- k' a2 [3 u, k1 | t- z
}
3 {8 g8 S3 ?+ m- X V$ U
' k! O& ^& Z9 u+ O1 jfunction calculatePosition() {
2 r) v. ]- c& r l, m) ^7 @- n if (xDir == "right") {
7 T5 ]% {0 W, Y D( s" m5 W if (xPos > (xMax - contentWidth - BallSpeed)) {
6 g/ q; a7 @* a xDir = "left";
; R8 X' |" u5 Z2 { }4 x' m- r1 @# f7 J. D- e `
}) V6 q+ J, h4 H0 D. P: b2 a
else if (xDir == "left") {4 q, f; l/ t- u9 m' O% R
if (xPos < (0 + BallSpeed)) {' G6 Y8 k% i6 L/ x4 _* q
xDir = "right";8 ]/ e; n9 l4 v. W m
}% u) H. _" H- m& |/ j" e
}
0 M2 d! x; d$ O1 R( z- P if (yDir == "down") {' @# P/ Y; R0 d) `. N
if (yPos > (yMax - contentHeight - BallSpeed)) {# Q; R, Y/ }$ F* L
yDir = "up";
" r6 W9 W6 I `$ y, Y4 o6 x }
' Q5 B# b9 `6 E1 N0 b, S }
6 e/ e8 w U7 w% v else if (yDir == "up") {9 `, H+ w5 }* i4 N
if (yPos < (0 + BallSpeed)) {
a L7 H+ b5 l; {# @ yDir = "down";
) V) h8 B R* b0 a9 L Z }
/ h2 d* A& U& o& \" T5 H0 R( k& a9 b } W$ `9 C) c" j% H9 [: ]
if (xDir == "right") {
9 I2 f1 q% D3 [( X% s4 W. o0 R" z xPos = xPos + BallSpeed;
# L& S/ m! t2 @. @ }
5 z/ a w' B2 \: |0 N else if (xDir == "left") {! p( O' f2 q3 |4 Y) a9 t8 S9 ?# k
xPos = xPos - BallSpeed;* R% m3 P R3 ~! G9 |
}& Y. f% V, v( `/ u. s `. d
else {5 v! l& |9 N9 {$ B
xPos = xPos;6 {; W. X5 o S4 Y' y, V# K% s
}5 m! @$ A$ J0 I. x
if (yDir == "down") {3 {! o @* z5 R: y5 b
yPos = yPos + BallSpeed;/ \5 q2 C" ]' A3 \) E! r9 F1 q5 x
}" Q. N+ {, H6 j$ l5 {! Q
else if (yDir == "up") {; o& V3 h9 x" ?1 \3 g0 g7 m- b& n
yPos = yPos - BallSpeed;
2 Q4 l" g: z3 |5 V }
7 C( r: j: ?) v! o3 T9 U else {
1 `: `/ E1 q P( K# `& u yPos = yPos;
) j! v! N5 `( I# `4 O3 `& c }
* `- O- ^4 x- k }* ^$ \/ h* R1 ^; ]- D
! W, C- v, S1 A/ M- Z
function hidetext(){, Z! c; e4 h; {: R# w5 J) A4 l' m
if (document.all)8 l5 T W! i# R- M( C
supertext.style.visibility="hidden"0 Y% d+ a. i+ }8 b8 b
else if (document.layers)
8 O9 g6 x, w/ f& Wdocument.supertext.visibility="hide"
& D; [! z0 P l q8 R* qclearTimeout(animatetext)! }; ^/ Y4 b# O5 V" c- E* p
}
7 D. M4 ~$ N$ i. I& o' A9 C* ^" A4 N$ _' t" X! a
if (document.all||document.layers){
8 \: V/ S3 b8 t2 M6 ndocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
- l( m- z6 G5 z# m' t0 `, H" Awindow.onload = initializeBall;
, d6 c) W$ `# ~' |2 [window.onresize = new Function("window.location.reload()");
/ T2 c: H# Z, y8 L3 G/ l6 m- i6 F}
2 V m" `. S7 Y" R0 u& U" `* Y7 b* K: L1 }/ W, v
</script> |
|