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

|
网页之不断弹射的文字-特效
<style type="text/css">
) \0 ^2 } F7 ~5 [9 h$ t7 m#supertext {8 C6 s8 r; n* y/ S6 h9 v. H
position:absolute;
, [: z/ p* y q$ y+ o& b+ rleft:0;4 [( T1 }/ C& @2 H7 C
top:0;) A$ z: I! p1 F& u; k m# Y2 C4 s6 U
visibility:hide;
3 `" s0 X) ?7 vvisibility:hidden;
! ?$ X6 X" H( X# o}# M4 A( m; R9 G2 z! Q6 A
</style>
2 `" `! J* O0 p3 E0 T3 f( Y<script language="JavaScript1.2">
/ j2 F [8 @( e9 E<!-- 改变下的字体的大小。颜色-->
. U8 }" e% J' C' ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>' P& [! u, E" R6 u4 L
var hidetimer='';
3 Y' A+ e' l( h( ~2 b) U' ]<!-- 改变下的弹跳速度-->
' K0 r4 a% J( K# R8 @& Hvar BallSpeed = 20;+ l c; k; b' E7 U; t5 b7 U
var contentWidth;! \6 s! g$ S2 G: W' i0 v0 ^1 p
var contentHeight;
; i2 |9 c1 H) O Vvar maxBallSpeed = 50;; i* ~" h$ b9 y
8 q# A+ V1 v" v( g6 r% P
4 M' {$ Y# P/ d1 g* p9 pvar xMax;3 O5 |! w! b2 R1 r3 F1 M# P# r$ P" t+ x
var yMax;
" K# Y$ n9 ?8 ^4 x6 w) ]) vvar xPos = 0;0 b- v1 D% ?' H" s4 ~
var yPos = 0;
8 t: I' Z) e) d! yvar xDir = 'right';7 G- J0 ]7 J: `
var yDir = 'down';
9 K$ |! m/ t# Fvar superballRunning = true;3 f; \9 |. u! b; Q9 x4 Z- G* X7 o: ?
var tempBallSpeed;
- U" T. g; `, ^ @* ? j2 K/ kvar currentBallSrc;
; {0 b- s! T/ X# U: Yvar newXDir;% L- x$ ~; o/ _' D
var newYDir;
. M i" z$ @2 ]
6 i8 j3 V4 D& g" D. K: o) [. Kfunction initializeBall() {
1 |" g, ]7 g: D1 ~ if (document.all) {
}9 s+ ~: S( b: F j* B xMax = document.body.clientWidth) y/ T4 }+ V3 I z) V
yMax = document.body.clientHeight" w7 W+ N* x$ w: v9 w- i$ H5 \
document.all("supertext").style.visibility = "visible";
/ R4 D* R) G# U4 B+ b2 y+ C contentWidth=supertext.offsetWidth& E* S/ Y" v; E
contentHeight=supertext.offsetHeight
8 V" i) a+ e$ a4 q }2 ~9 \& ]0 x, w9 e; n& s
else if (document.layers) {
! o) K: Q' m' `+ w% ~8 K6 \ j; q xMax = window.innerWidth;+ i* S; N+ F+ C; K! L5 L4 Q
yMax = window.innerHeight;1 w/ w, ?' ]2 y5 e* e
contentWidth=document.supertext.document.width1 b; y, \$ X2 |
contentHeight=document.supertext.document.height
3 C' a3 {4 f) n# ^. E- ` document.layers["supertext"].visibility = "show";
2 l: m; O2 D' n }
/ d; T% g. h) B0 { C( n' L setTimeout('moveBall()',400);4 U/ D# N4 U2 {* E
if (hidetimer!='')
' U& A+ ?8 Z+ P. ^ setTimeout("hidetext()",hidetimer)- u- _; z6 U: G/ }' J: J+ \0 h
}( G; X1 `! w* u+ o9 T) ~
' W$ d& k5 o a$ d9 A2 yfunction moveBall() {9 [0 ?# T0 u" C! i
if (superballRunning == true) {
4 Z/ k! A$ r* _. Q! m5 I' Y* U" ]; g calculatePosition();
. T: X% Z0 K4 @- y+ ~% j if (document.all) {" H) r) }4 W- J9 V& {( K- o, S u$ W8 V# x
document.all("supertext").style.left = xPos + document.body.scrollLeft;1 G- `5 I Z$ ]# i
document.all("supertext").style.top = yPos + document.body.scrollTop;8 j2 l" x: y1 r- M t+ m3 t
}
4 x( G" i4 V/ G. s else if (document.layers) {
- p% V4 G. i; r& s- Y document.layers["supertext"].left = xPos + pageXOffset;8 I$ z! f5 @$ C# c- L* W8 @
document.layers["supertext"].top = yPos + pageYOffset;+ e, O. E; J. g$ J. ^
}
8 L; h$ \% N, d2 g7 N" }5 ]# i7 \ animatetext=setTimeout('moveBall()',20);3 ^- y* F* ]1 ~1 r5 k7 V: W
}* U, T, Y# R# b1 w
}
! b* n" t3 L, S! a) F" ^, Q: ?& ]1 w; d
function calculatePosition() {
; w9 t/ g) O: f2 l/ u if (xDir == "right") {
: j4 t" z, d. o) m1 ]8 i% q. H if (xPos > (xMax - contentWidth - BallSpeed)) {
$ Y* H& l7 O) g% m- }5 n: X" [ xDir = "left";: P, h" {! C( Y! S' X7 s
}
! a& F( A; e7 m. C& P, R. g }
0 n0 M# w4 A* j D else if (xDir == "left") {2 @. d6 c, f* P( N7 {
if (xPos < (0 + BallSpeed)) {7 L# n. @$ q8 h. b _. R4 N: m, r# g
xDir = "right";
G- ~5 H/ r. j6 y; M9 ]3 I( r! ^ }
' P5 y- |' A6 k Z }7 z9 b% i- H7 Q5 e
if (yDir == "down") {
, K5 [! `6 _5 O2 q/ ~6 n, ` if (yPos > (yMax - contentHeight - BallSpeed)) {
$ ~6 T& N$ k, Q9 d7 E yDir = "up";
, _# `; |" Q1 {1 G. D% ^1 ]. z }, X. Z8 e! M t: Y5 U) q/ B
}& r( N8 V* i; X1 ^; a+ ^2 ~
else if (yDir == "up") {
1 ^1 Y% C; }& w" d5 ~- u! ] if (yPos < (0 + BallSpeed)) {8 K+ R9 q, ~, D, H: A3 k
yDir = "down";* i6 ^0 K, g$ ]% a. \
}
* H* z$ t+ t0 |- u }6 G: j T; r. a% N2 ~6 ^
if (xDir == "right") {& C1 I( J' w! G4 `5 W7 d8 W2 ?) D5 `
xPos = xPos + BallSpeed;
1 K g$ t0 C9 x# m) ~; ]4 j }
, x0 P$ a# U- _. w else if (xDir == "left") { D2 Z# m' @- w
xPos = xPos - BallSpeed;2 R/ i* X% G; }5 Z
}
) d2 d( `: l- Z2 I+ q* A1 a3 K else {5 p: O/ H7 Y, `0 M" n5 [2 E
xPos = xPos;
4 B6 F, P9 W. |; p( O* a) q- Z }4 m9 J0 S/ P& C( K( Z9 J2 o$ z. N
if (yDir == "down") {
4 q: ~/ j1 C4 e6 N5 S yPos = yPos + BallSpeed;/ F1 {4 U- f' J3 w( o4 @. [. b6 Q
}7 V2 {( u8 E+ W4 H4 R
else if (yDir == "up") {
8 H9 L: y: B3 y yPos = yPos - BallSpeed;
8 m* i: K% W* u: ` }7 S1 `! N! ~% n9 L( _5 W
else {
+ h. P! Y- V u; x* k& G yPos = yPos; z. W+ r8 o( X2 G1 C
}+ p6 a2 h" n7 x+ w/ Q. |' O" U2 [
}% W( Y8 r( t8 t0 }
" F- x- y; E8 ?8 J) Hfunction hidetext(){
/ v* `2 W& i6 P) H9 u$ Sif (document.all)) N1 @5 ~% T. n9 W+ d' P4 O5 X
supertext.style.visibility="hidden"6 r* S8 L3 G0 V- O+ _& u
else if (document.layers)
5 o& a+ W8 @: y/ Rdocument.supertext.visibility="hide"
1 K9 W. d, g- u) E# `clearTimeout(animatetext)7 P# U+ Y$ R( s; Q* Q% k, ^/ x
}
/ I6 n; |7 K7 e, @8 q2 a
2 h, p! j9 {* q/ Z8 X4 sif (document.all||document.layers){7 Q! d, J* j" ^
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ G) u" m4 D! F8 S. ~+ H
window.onload = initializeBall;* \! \, u! }* \0 @
window.onresize = new Function("window.location.reload()");
/ K' W$ D. F; o$ W+ |8 H1 }}
+ R( J- R: S, q! L4 G1 t$ }! ~- Q& Y1 R* {& v
</script> |
|