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

|
网页之不断弹射的文字-特效
<style type="text/css">' X7 b* l; \. w2 d F
#supertext {9 D5 a* ?- a# e9 }
position:absolute;+ x8 I- }- I5 a( ?: J& _
left:0;
! [+ m4 k1 \5 w" K+ Y; {top:0;
. v) e9 V# j% ?4 a2 Nvisibility:hide;- ]' v$ I4 R2 Q$ u- t/ s- x: I
visibility:hidden;
7 X0 A2 ^5 O2 Z}
& C% o. g3 k( o</style>7 y; E }, U- L; Q/ j( }2 z
<script language="JavaScript1.2">" T1 x: v+ f4 h, V t6 l. Q
<!-- 改变下的字体的大小。颜色-->$ ^, w q+ @( q9 a9 {
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 }1 `* ^# [" G$ U: Y/ Dvar hidetimer='';5 Z" @7 h1 _0 D7 _$ B5 q0 ~
<!-- 改变下的弹跳速度-->
6 C& c0 `* ?4 Y7 ~' ]var BallSpeed = 20;
1 O; K! C0 t8 ]5 Bvar contentWidth;
& R& M6 ]$ E( X5 h4 p) d9 c4 Dvar contentHeight;
' R D }8 H; a+ C% \" E5 Vvar maxBallSpeed = 50;( G: M2 ]/ D( x8 O: H9 L
$ Q- W/ s" ?' ]1 X, Z. |. p/ L
1 t: d+ f2 V2 p: @var xMax;
1 c" T$ _1 T, t, B( nvar yMax;
" Q& @% z% i& t! `! w9 n, Tvar xPos = 0;& D8 z; C$ {- s. R
var yPos = 0;
1 s- O7 p0 z/ s5 ivar xDir = 'right';) i* B4 z u4 M! r7 ^- M
var yDir = 'down';
' A" {( e2 U; k7 mvar superballRunning = true;; ]" f* D `& @% |
var tempBallSpeed;# T; a9 D: Q7 h* o7 }/ c; r
var currentBallSrc;
# ` }8 J$ y: u8 A5 @0 g2 U: Xvar newXDir; _$ \, D0 f, H* v/ ^
var newYDir;7 H( X/ W2 a$ h" i
' E4 ?" J. t. N% f+ E2 C
function initializeBall() {5 ?; L5 G$ H( X& L4 _
if (document.all) {" K0 s; A$ ]/ I
xMax = document.body.clientWidth" D9 W x2 k& y! O- z7 j7 {
yMax = document.body.clientHeight% s# w& k- q% y2 _# w$ z/ W, G
document.all("supertext").style.visibility = "visible";+ H) E2 _, {9 z, j# Q* Y
contentWidth=supertext.offsetWidth
5 C" K; x6 r4 ?3 }; ] contentHeight=supertext.offsetHeight
, y; s7 k) [, @1 t) |& w3 \ }5 A" \$ ~ y& g; e( C) D# b
else if (document.layers) {, b: [# y2 X/ O# B, X( c! B, X5 ~
xMax = window.innerWidth;5 A+ Q& \ t) ?4 L' a; v
yMax = window.innerHeight;: [6 l: @" B& l4 m6 N
contentWidth=document.supertext.document.width5 s- G5 p2 y# z3 L
contentHeight=document.supertext.document.height
# i/ p- J- p+ L! r document.layers["supertext"].visibility = "show";
+ R' D6 r- Z+ B$ q5 h' {% Y }
! V, U# G- P+ G' x4 ~; {7 Z setTimeout('moveBall()',400);* y4 l- S" h% T8 \& \: u
if (hidetimer!='')
2 a) C$ j+ P$ J* {# `. [. e+ ] setTimeout("hidetext()",hidetimer)
) d, ]2 i+ i1 ]4 H. \9 j }1 Y+ `5 G$ e! ^ ]" I6 Q
" n$ M8 M& o6 E6 C% mfunction moveBall() {/ f7 T) H2 E& Z8 O+ `
if (superballRunning == true) {
/ ?, z/ C5 S" _( q, x" B" b- ] calculatePosition();% |' O8 r: Z; s# A6 {9 H* V
if (document.all) {$ d5 S$ y3 n" t, F* y9 Q7 W8 x
document.all("supertext").style.left = xPos + document.body.scrollLeft;
0 t' q/ ]; _$ _+ Y document.all("supertext").style.top = yPos + document.body.scrollTop;+ b! e* v7 v: F
}1 `. Y9 Z, w* Q7 p: Z" _
else if (document.layers) {' g3 P. o- e; W( a; ?
document.layers["supertext"].left = xPos + pageXOffset;
% v) R7 e: Q5 }) T. d+ @8 h( ~ document.layers["supertext"].top = yPos + pageYOffset;
5 e6 Z3 L" A+ K: C6 Y$ z- }) E }
1 C4 n- h# D$ f animatetext=setTimeout('moveBall()',20);
3 S9 I" ^3 ?* `* D4 o }# R9 h, ~: @) z' k- r$ q8 L, C: G
}- B2 \$ j4 H1 B6 j. b
$ n* M$ _) }2 H7 x
function calculatePosition() {
: i2 J9 ]* W# u4 q0 F if (xDir == "right") {
+ w$ n5 Y, X6 {% O% z7 G if (xPos > (xMax - contentWidth - BallSpeed)) {& o" Z) W3 s! K0 }) W3 J& g
xDir = "left";
* O- t" c- C, b7 n8 u }3 J3 U5 t& \3 ^3 E" }7 Q
}
" T& i/ N3 k- R. y1 ^+ P else if (xDir == "left") {
. c8 w2 x# b/ R- \ if (xPos < (0 + BallSpeed)) {# l5 o# P( ?6 g8 Y8 S8 g$ l
xDir = "right";4 {0 X! e( ~0 e* V8 y7 K' e8 E, |% C
}
0 C# b9 _* l& O1 m( [ }7 v' I7 H* z' V; N+ ^0 A
if (yDir == "down") {' D2 P7 t0 v5 q7 W
if (yPos > (yMax - contentHeight - BallSpeed)) {
9 U4 I; b7 W5 A' F yDir = "up";* I6 p5 I) K. d' \8 a% R
}
0 ^+ K2 L) X1 U4 ?5 V0 \3 B: n0 } }& N3 f3 b4 y* t
else if (yDir == "up") {& n) O' r& I2 O8 ?
if (yPos < (0 + BallSpeed)) {
- D- E+ U( S$ B yDir = "down";) ` G1 h9 }( ?* X9 I, ^, M; S% [
}% N% S, Z3 w+ L! O
}
& ]2 u' K! k2 y* ]/ |8 U1 c if (xDir == "right") {6 c1 o) `0 |; ^
xPos = xPos + BallSpeed;
N" D% o( a X3 r5 o) c5 l }& O7 U3 H! [( L& t
else if (xDir == "left") {, }# [# ^$ {$ ?, _2 M
xPos = xPos - BallSpeed;
( I! V& {. D$ q$ m& [ }. ^- m- Z: o r* }& |& `3 J! ^4 J
else {
3 B3 }$ o; S/ U$ X" V2 ^ xPos = xPos;2 l0 W7 o) T6 R4 l& h
}& M& t& e: y( x6 C
if (yDir == "down") { Q a, ~, @) w; l6 E E0 i4 O
yPos = yPos + BallSpeed;* {2 R. e8 |% z
}
. T2 p1 J# M: m! O c else if (yDir == "up") {6 r0 n* \ O7 v8 R
yPos = yPos - BallSpeed;
) \% ~: w1 s Z8 O }
$ Y. o+ n a; Q6 v* M( `# V" ] else {# \# [# X$ F- g' P2 \, n$ @
yPos = yPos;- E2 _6 A- j0 G
}3 r' J( G! o5 O ~" {) O7 w
}* Y3 _, L7 h8 c3 h' h& ~# n
# W& u% k/ f t
function hidetext(){
' V% X, ?$ T3 ^2 t4 B, sif (document.all)
6 D4 b- H7 @ l7 Y* l) ^supertext.style.visibility="hidden", a. O8 n1 a& P+ S, q/ K5 A
else if (document.layers)
1 w. O' w2 h5 Adocument.supertext.visibility="hide" u; z7 J g2 S6 G X( D; D7 _8 J
clearTimeout(animatetext)& G5 n, ^' c: Z0 `! \
}; V5 `- \8 J1 u) i* d% [: H. Y
9 A+ s, F; w; lif (document.all||document.layers){
$ {5 b' X. x8 G3 o" Tdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')" V. A3 W' y2 K
window.onload = initializeBall;
+ H$ F( `6 r9 j" Jwindow.onresize = new Function("window.location.reload()");
, i# n1 U* D$ [( r4 c}
7 K/ x8 Z- K+ i2 T( g! e |1 b: C) F" r; u5 [) l, Y- V
</script> |
|