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

|
网页之不断弹射的文字-特效
<style type="text/css">5 J0 U% T& e& d B. h# p9 Z3 a9 L8 P% H
#supertext {6 S4 \+ y+ B, b* a
position:absolute;3 a: ]! [# Q! [: z) i
left:0;2 R; R; A Z$ o; b" z, E9 p9 S
top:0;
- y+ {% r4 F5 Z/ Zvisibility:hide;
- T+ G& w9 H! U' [8 @7 kvisibility:hidden;" a- I. p3 l. t' v4 a
}
" t' b" ~. h2 J1 {# U) C</style>
, H9 C/ ^$ e5 C, F5 f<script language="JavaScript1.2">' T* e5 Z' C! O( g
<!-- 改变下的字体的大小。颜色-->
3 {# J, H" T5 E" Mvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' t6 W/ [$ Z/ B2 }; |( wvar hidetimer='';/ l* B# o. x2 [/ H- n
<!-- 改变下的弹跳速度-->
- ~* ]1 ?/ X3 ` k6 Q7 rvar BallSpeed = 20;
' }/ N0 |, I7 Z7 k' j e( ^var contentWidth;
0 B" i2 Q$ L0 H Tvar contentHeight;
6 M0 ^& O9 L, O, X6 _: P& J4 zvar maxBallSpeed = 50;
4 _' Y' M$ E( I! n6 o% f: ^' Y" Z' q. m! N& O5 f O1 w2 N
1 A1 A$ ~; O& g3 U0 p: q+ P' r* x
var xMax;
6 }( S9 y) O R, @$ W/ s6 [/ Gvar yMax;
& ^ T& F: ~; Z- A" P% qvar xPos = 0;/ I7 n* y) C2 h3 X3 ?4 H% q6 P
var yPos = 0;
- e, y$ N. ] ]var xDir = 'right';! [1 }% F( |8 }. ~2 O, p' k* |
var yDir = 'down';9 {# ?9 ?: {0 h1 Q! }: {- c
var superballRunning = true;% t9 Q, i2 o" U5 y; G) a
var tempBallSpeed;
. m4 s* b! C9 _7 h; Q+ kvar currentBallSrc;
, Q) c4 Z. \# x A5 z! @var newXDir;
- m8 M$ @4 v W$ ?var newYDir;
8 [4 A, W* n6 ^/ ]4 G. P! f. k3 Z: x
function initializeBall() {' Y: H G$ T; i
if (document.all) {7 E, T& h: z! p8 \( Z
xMax = document.body.clientWidth
# ^0 s. S1 @0 Z yMax = document.body.clientHeight
: O5 B6 i9 O" M$ A8 G3 E: ] document.all("supertext").style.visibility = "visible";( g+ S8 l+ P+ b1 d( h
contentWidth=supertext.offsetWidth
' D! i% w( N" ?3 s4 V! v! T* O contentHeight=supertext.offsetHeight
+ D8 T% v' t0 I: ` }# Z- u l5 C0 e- y8 N4 ^' @
else if (document.layers) {% I2 |- E' ?) C/ {' ]+ t; B8 N
xMax = window.innerWidth;
4 u5 a1 W3 Y; G5 K# r) n yMax = window.innerHeight;6 o4 l. p/ b: f6 B2 A% ^
contentWidth=document.supertext.document.width w2 k3 f' Q) ?. [
contentHeight=document.supertext.document.height5 g3 D$ o/ v) @
document.layers["supertext"].visibility = "show";8 D1 d' Y) O/ l
}/ ]8 `3 y& I; d* R7 U
setTimeout('moveBall()',400);' p0 l, R q1 D6 w( A1 U- u: w
if (hidetimer!='')3 {* f; \6 k# a# ]- P( u
setTimeout("hidetext()",hidetimer)
: n! _6 X. F8 ?5 m5 _1 j) { }) ]8 u; n- k( f
- G. ~/ ~6 ?! @# V2 X) x
function moveBall() {
( n! |% Y; Y1 T+ D if (superballRunning == true) {
4 `# Z4 w4 L$ N. ^- {/ f5 ~2 j calculatePosition();# y4 W/ ^9 C* D
if (document.all) {
; e( y) _6 |; [+ | document.all("supertext").style.left = xPos + document.body.scrollLeft;: V3 F5 E* Z# v. t# o; \
document.all("supertext").style.top = yPos + document.body.scrollTop;
6 b- S& g/ I- h y/ I) y( A }$ T" {* Z5 C2 y7 K
else if (document.layers) {& F4 X, U" i s) m" P8 A$ i
document.layers["supertext"].left = xPos + pageXOffset;
- O+ I, m; R' z document.layers["supertext"].top = yPos + pageYOffset;1 ?& E7 s. s3 `. d# A+ a* l: ^! o
}* X; ]2 p1 r- x0 T2 n1 C, Z$ x0 q
animatetext=setTimeout('moveBall()',20);
, q0 V6 \2 A: T1 y }2 E) Q4 E1 K$ m3 R7 P3 r% Y/ C
}: L2 D q9 j2 H6 R2 g/ b, G! `+ e
0 J8 Q1 {# T! i; K8 E8 G8 Z
function calculatePosition() {
I! K+ R( @) T4 a0 g; w6 g! @% _ if (xDir == "right") {/ O0 T3 f6 V! C2 J4 H8 w4 W5 I
if (xPos > (xMax - contentWidth - BallSpeed)) {! ?; J0 ~4 u/ v4 D; k
xDir = "left";
* a! \7 C; b/ B3 _ }
/ [! M. j H# R+ O& u }) [- m7 l4 O- W/ N1 S1 N1 Q# z+ v: d
else if (xDir == "left") {3 Z- x \' {" }( o8 I
if (xPos < (0 + BallSpeed)) {
3 `% \9 v' V) _8 V, _3 W5 \ xDir = "right";4 e; }" i% o1 ]2 q$ Z* ?4 }
}1 h$ f# ^' N* C( U6 @2 ]5 o
}
, T, }# [* ]. p* b0 V+ Y if (yDir == "down") {
! F ]: |; a& Y! l" K4 ~ if (yPos > (yMax - contentHeight - BallSpeed)) {% R7 g* l* e) r" {3 x% B& v
yDir = "up";5 ~2 `7 i& w5 S' b% q& e) w
}9 }8 R/ o5 V3 V9 \, j
}7 {* o0 E$ C! u; \$ |2 W& d$ n
else if (yDir == "up") {
5 P2 h1 x3 ^7 z6 f if (yPos < (0 + BallSpeed)) {
% `& L, Q' V0 `( {3 e& ]! \9 T. I yDir = "down";: d* [9 R0 {- ?/ W: l& B
}# {& q8 F4 S( x( a. q0 P! T% l
}
* `' o# a- D/ b, _ h; U/ ? if (xDir == "right") {5 Y8 l) Q% W0 m( \/ O
xPos = xPos + BallSpeed;
# y1 ~7 ~2 O: d% u _) Y4 P }
W+ y O& n+ M4 G! K else if (xDir == "left") {2 ^. a. W% G2 g: ?
xPos = xPos - BallSpeed;& j2 o% x) n, o/ h4 V5 A
}
' Z' r& }" B. M" K% n else {
% ?7 O$ ?: |% I- s5 O9 D' H xPos = xPos;
; Z2 W+ |* [- t. W! H" n7 w }6 O5 F5 ]% m( b( d1 t
if (yDir == "down") {
$ j2 ]5 G6 L9 C9 F( | yPos = yPos + BallSpeed;
! m: |$ A; }& z/ C7 }1 g/ f; c5 g' G }+ s) K' d* k, O$ g
else if (yDir == "up") {
" D# N* M; h' _- K/ S/ n7 c' T yPos = yPos - BallSpeed;+ L/ W a' ?* r% e
}
1 B1 d, g7 f! `* m$ N: x. d" _ else {9 I1 }& \& d, u [ Y. ]
yPos = yPos;: D1 x3 q; g2 a
}5 w0 A6 F; c& b, k/ k* C$ [' Y* ?
}6 P0 y. g# p- z: a" {
, b/ a( t# n ~function hidetext(){# O1 `4 F0 y- r% M4 z# X& ^
if (document.all)! W7 L6 Q2 X; V- `% e8 B$ h+ {9 V
supertext.style.visibility="hidden" E' B2 o5 l" b; |
else if (document.layers)1 R1 p( q% X) I& d2 H# X; g
document.supertext.visibility="hide"/ B5 r" V, W3 ?4 j; y: z7 {
clearTimeout(animatetext)
3 V( ?5 k" [" n: C4 X}
. |. W: h7 L8 h' g. c2 ~3 P5 U4 K: q2 f' i$ |
if (document.all||document.layers){
4 F: h: \- m ?9 kdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')$ T% a6 e0 K0 f F* p: S
window.onload = initializeBall;2 J0 }9 K$ B! Z* G' o: u; I' v( J
window.onresize = new Function("window.location.reload()");
" `4 y: p8 [+ |: @) Z. U}* Z9 T4 b \9 ]7 `9 W" A& e
8 N% A$ o# v$ R( w; @: ]
</script> |
|