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

|
网页之不断弹射的文字-特效
<style type="text/css">
, Z+ }6 _8 ?4 W/ g/ |$ J- j#supertext {% L8 z* l9 _( A; U6 A! K
position:absolute;
; |; i& `2 D" J+ x& cleft:0;
; Y* h* G6 m- M% D0 E9 |" c" ~% utop:0;
# H: x5 v- m8 I7 `( z8 zvisibility:hide;
8 ]2 H# l: U4 wvisibility:hidden;
0 z" ^7 |9 B& B L; F( k- f( o' @}6 ~& b+ K8 J% t/ q
</style>
, }& d1 y# f- t6 g" G7 D' Y<script language="JavaScript1.2">8 g$ b) e2 R0 K5 y- t5 ]8 I* Q
<!-- 改变下的字体的大小。颜色-->8 g; l1 O' \- {; \6 L% T3 m
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 b5 W' s/ Y+ q; h
var hidetimer='';
) F% q7 W+ U3 e7 R0 V6 |! k<!-- 改变下的弹跳速度-->
& }% I, P0 G1 T* I9 v* ?2 pvar BallSpeed = 20;
# c8 v3 j. F1 h, D5 o5 Nvar contentWidth;7 @+ B4 O5 f- M7 t: \
var contentHeight;
g: a: r' Z2 _7 T1 ~; Z+ e- nvar maxBallSpeed = 50;- Q! Q9 L8 V" i! F8 w
# {* R2 P. t8 m+ e
G, E' z/ B2 M/ x2 F# f8 Svar xMax;
( I) n( X& J- }var yMax;
4 {/ }, }* t. L; q: Y: {8 Fvar xPos = 0;
- r% a; C: D5 {: N) tvar yPos = 0;
6 ^0 R% [1 p' h+ G& Vvar xDir = 'right';
; m" H9 J( R$ o+ U9 S* m4 L9 Nvar yDir = 'down';( E( e; Z# m& _! v* ?! b3 _
var superballRunning = true;; b0 L9 m, N3 n8 ~& v
var tempBallSpeed;
# @ M2 W% C8 z3 L' i4 I# kvar currentBallSrc;
0 V( }0 y. f/ |% m! J; v+ gvar newXDir;
5 D+ ^; `* [7 h7 O4 T. ` Nvar newYDir;
6 U* q9 n- t/ m9 r! J1 N8 d6 d3 d- R2 L. Q: c0 j$ _+ W0 _
function initializeBall() {4 T6 w a. R. D% T" K! O2 N/ R
if (document.all) {' [) u& x. q# H6 Q: n
xMax = document.body.clientWidth
- b' i4 c* N: N* }$ k' K yMax = document.body.clientHeight7 y- p4 T* \& Q9 ~4 a7 u
document.all("supertext").style.visibility = "visible";
2 B. X6 i9 i/ K, v. p contentWidth=supertext.offsetWidth
. G. ~ E& s) A6 I3 p! g contentHeight=supertext.offsetHeight; C' F( K0 `$ w
}6 h) N) K8 h/ G r
else if (document.layers) {5 X; ~+ z* M( G
xMax = window.innerWidth;
! j. M* [; A- k. I2 u( X! a( s, ? yMax = window.innerHeight;. R; T4 e9 j, X, G* p F
contentWidth=document.supertext.document.width
. f. K h. w. Q' O# J+ d& b contentHeight=document.supertext.document.height
1 u" Y) e6 C+ ~7 f* D% T' ^5 G document.layers["supertext"].visibility = "show";* N( I! h3 I0 z6 G1 w* K
}
$ ~( S7 e" p( Q1 M setTimeout('moveBall()',400);
. l- v4 o) L! X if (hidetimer!='')
* o4 T) S" S3 J4 o8 k' o% Q setTimeout("hidetext()",hidetimer)
$ }5 K$ g7 K3 n( w2 z }! r6 w0 y) n# T
6 L( s+ N( H$ |& L1 z+ e9 l& ]function moveBall() {" n7 f5 l* O, ]8 d
if (superballRunning == true) {
. D" G4 }4 O2 u& `$ x calculatePosition();/ ~# _8 J+ L Z9 M; s5 z
if (document.all) {
1 A0 ^' Y) v: p+ J. x5 ` document.all("supertext").style.left = xPos + document.body.scrollLeft;
. a: l2 {( k1 u6 ` document.all("supertext").style.top = yPos + document.body.scrollTop;$ b7 e; }1 }; }8 t8 d% l
}$ s: ^5 k+ X( O2 }/ R1 ~* M, b
else if (document.layers) {' G% N) \+ H1 t: Y4 n3 ]
document.layers["supertext"].left = xPos + pageXOffset;
% a. H* T' l9 |5 G5 b7 ` S document.layers["supertext"].top = yPos + pageYOffset;
. i! D# @- p2 T9 D. E }" U: K+ P8 I$ O; C
animatetext=setTimeout('moveBall()',20);
) w. `1 r! [ ]7 V U }
. Q9 O) u% C3 t- S, p }' \2 Y1 ^# ?9 c& ~. N$ q7 b4 W" e
8 Z8 Z; g5 ]! a) M9 `
function calculatePosition() {3 [4 f" f! y9 D' N' Z
if (xDir == "right") {6 W6 ^/ G4 @; t! Q6 v' b- H
if (xPos > (xMax - contentWidth - BallSpeed)) {
. Z8 b0 K/ C0 C: y) h' g8 i( v xDir = "left";
% [) d5 L5 L% W" [* C }, \$ G" i+ F g5 T
}
2 C) u' J+ \- }) Y9 J else if (xDir == "left") {
# D7 s/ C# d9 `* q4 U if (xPos < (0 + BallSpeed)) {
" x5 j( W6 {) I5 c7 m! F9 f+ \ xDir = "right";
* o* b7 t9 K9 ~, n }, u- f) g3 I. ~# v+ D4 p% U
}% f8 ]0 o& f8 _* h8 a: t
if (yDir == "down") {$ a$ q* O" Y3 y; S
if (yPos > (yMax - contentHeight - BallSpeed)) {+ P7 ?2 k0 T9 h( \8 k
yDir = "up";2 R7 n1 q! Y9 w
}. u0 E4 j4 p* L, A
}2 a5 b$ e5 ~: y+ e. _
else if (yDir == "up") {
9 j9 M$ ? d3 x, N! { if (yPos < (0 + BallSpeed)) {
9 z+ ]* Y# V- |+ m7 E* Z yDir = "down";
0 L) y' }% I# a8 B9 W8 C2 t }% {/ }3 U! ^" h8 R/ ?# z' V4 b
}
]& e8 {3 q5 p9 g6 I) b" K if (xDir == "right") {
! w; ?; m5 T( E: M. S xPos = xPos + BallSpeed;, T$ [( }( M- `: W7 k
}
- ?( X0 p, _1 p, ?3 A9 b- ?+ s% T* i6 K else if (xDir == "left") {/ H8 B9 q1 K1 q6 g) u( h7 A
xPos = xPos - BallSpeed;1 Q: Y- k1 f1 m9 z, h: e
}
" h4 J! A, j8 M, {% G else {
# u' s# B i6 `: I; x& M2 C xPos = xPos;
( R m/ \# `% g2 e6 r+ E- C }
6 z7 d# r5 N5 A1 u1 R7 ]/ B if (yDir == "down") {
' z+ ]6 ?" r. x5 v% q yPos = yPos + BallSpeed;0 }. z( q1 o/ Z: k' J' S; p. l
}- y/ e9 a+ H: }; @. s5 X
else if (yDir == "up") {
- B6 p# g* r" ? yPos = yPos - BallSpeed;8 D- D. d$ |" \" b
}
s$ R& W& C* N, p$ q) O else {' x0 j H+ } n1 D4 }3 w8 h2 q
yPos = yPos;7 B7 H$ b1 ]/ D6 N8 W
}
/ l# Z' z( |2 f! t }! G( v% x2 ]2 }( S: S
`' {3 {) j" g' M5 t9 K0 J
function hidetext(){5 S7 i" u5 a% `( }' Q z
if (document.all)
: M Y! o9 h* }supertext.style.visibility="hidden"
4 G% j$ n7 O( [7 X, Celse if (document.layers): i5 I. k- W$ J8 N* {9 |1 h
document.supertext.visibility="hide"8 V* o, E" D1 e, }, Z) j
clearTimeout(animatetext)6 @% \) V2 Q* t+ _& d9 D+ H' q1 E
}) i- W; U! W% W" }& q% n) t
# G6 ~9 d+ q% [6 T( Zif (document.all||document.layers){ `7 Z/ @* X3 \$ c7 V
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# X, d3 `" \' Fwindow.onload = initializeBall;
6 I5 V( [8 `/ k# U0 g. \& w8 [window.onresize = new Function("window.location.reload()");6 [) r2 {9 e& ]1 O1 U
}! R& T& \) m* t& G
0 I- T# G* c( n' q! N
</script> |
|