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

|
网页之不断弹射的文字-特效
<style type="text/css">. ]1 m" A1 _+ X+ Y# I! N9 t) f
#supertext {
! C' v$ W9 o, \% }position:absolute;( w9 {4 `* C3 B0 l T1 @8 ~
left:0;% Q6 |, p1 _# h0 z5 Q* K# p8 l. t
top:0;/ \1 P8 j, i& d- t8 b4 r
visibility:hide;
2 Z! F% @6 D% J0 Wvisibility:hidden;
i- G! b2 \0 L}" o4 |3 r, A z! R
</style># z; L; A5 ]2 @% V4 H
<script language="JavaScript1.2">
* M" M6 [! a7 O. R7 Q<!-- 改变下的字体的大小。颜色--> S3 M* ^6 E1 z$ [# U4 I8 u
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ a7 I A0 P0 u. ~0 G! _
var hidetimer='';' P t" D; w( C1 C$ I
<!-- 改变下的弹跳速度-->
9 ~% R+ `. {7 u4 a# R- `3 b; Bvar BallSpeed = 20;8 U* T+ O0 j) \9 z- z: y
var contentWidth;
& K7 l9 Y- W/ Dvar contentHeight;
% n) i. W9 K3 e7 ~var maxBallSpeed = 50;
! k. M# c9 o9 _5 f, D1 k' ?) c7 u4 L. o' L, |- i' s! n$ f
9 T6 ?- o' D w! k9 cvar xMax;- e% c E2 j, r( K
var yMax;7 ?3 u. ~* R4 O7 F
var xPos = 0;, \ z1 x+ h3 j
var yPos = 0;
3 k/ [: `" `9 j. V' Q# h4 f7 t7 kvar xDir = 'right';, m+ P4 t" l5 b
var yDir = 'down';
6 F2 R9 O! b3 u+ L/ zvar superballRunning = true;
: _; a8 u2 C1 |var tempBallSpeed;% c. }* Q, v# O
var currentBallSrc;( ]" C9 G) L, L/ f( _
var newXDir;0 t |& ^$ L+ d8 v! C* w
var newYDir;5 `# R" a2 V7 S* M! k' [, E# A4 z
6 D: I5 R ` {+ S# J3 O
function initializeBall() {) ?5 @- z' i. |0 M) ~
if (document.all) {) j9 n9 Q- z& ~7 A/ x2 A y
xMax = document.body.clientWidth$ E- \& \- h! X! \4 s6 ^+ R% n5 V
yMax = document.body.clientHeight
' m! {+ ^: ^% v$ i document.all("supertext").style.visibility = "visible";9 O8 Q0 M% `1 n" M8 ~6 P* i( X
contentWidth=supertext.offsetWidth
. n5 u2 o' P9 F7 h contentHeight=supertext.offsetHeight4 g5 M( |! @/ L7 y
}/ E# w* Y" Z; o* Y2 a( q) C$ S
else if (document.layers) {( `; f* {3 l0 n
xMax = window.innerWidth;
% U; d) c. R" K$ b+ _- V yMax = window.innerHeight;
7 N/ [7 p1 j: j! u4 T! q contentWidth=document.supertext.document.width
& E( r$ }- J- i! L+ M contentHeight=document.supertext.document.height9 U' k/ ?9 U. l j* D* {; k
document.layers["supertext"].visibility = "show"; [( m9 h( x7 f1 T( s' B
}0 u3 p) q* C ~2 X
setTimeout('moveBall()',400);
2 B: f6 ~# Q8 t/ ^ if (hidetimer!='')8 `' K& L! G- T3 y/ V
setTimeout("hidetext()",hidetimer)9 R% w/ g+ R/ J f
}
1 T! X8 @0 P* Q$ @, p; j$ f/ w: C4 R
function moveBall() {7 O( X; e+ i) y0 x3 P
if (superballRunning == true) {$ k: ` V4 l" @
calculatePosition();
: h! {5 c8 l! I; m) J+ b4 \ if (document.all) {- ]1 ?3 w: ~: |0 L7 z
document.all("supertext").style.left = xPos + document.body.scrollLeft;: S% X; k" P+ b: {3 j4 L
document.all("supertext").style.top = yPos + document.body.scrollTop;
" m0 z2 C/ Z- k4 O/ a }8 c8 V+ J- p1 N% R ?4 G; r
else if (document.layers) {
7 P: p( `1 h0 F5 ^! R% a document.layers["supertext"].left = xPos + pageXOffset;* z9 H) k, D" Y; e
document.layers["supertext"].top = yPos + pageYOffset;
# s6 o8 B+ B, N: i) C. g }
8 k& ?3 A: j6 K6 f/ {) Q3 q animatetext=setTimeout('moveBall()',20);
3 r2 Y. b: V5 V4 y }
! W4 ~$ k* N5 u1 {) z9 I" [( k }% N3 {: }5 h( Y* R% J* {: c3 N: Q
, d' f' j, N3 |function calculatePosition() {# C! l; r1 g& O3 j
if (xDir == "right") {
/ I* Z" w# O" g n if (xPos > (xMax - contentWidth - BallSpeed)) {) |" M2 M4 e. ]
xDir = "left";3 Z3 x. y L4 B2 O2 G2 `6 E9 O
}( N& G; {+ h6 @ t8 v; ^
}
6 b% t- x* O' t7 u9 |# ] else if (xDir == "left") {# { v/ _- T: U2 {/ S& l# U& H
if (xPos < (0 + BallSpeed)) {! o+ B! u6 G" A% C% n7 q8 G
xDir = "right";
, a. m# r1 p8 F2 }; o" |0 t }
0 X1 S0 R5 N& C% W }! [1 Y H+ h! \7 r4 ~3 {- ~
if (yDir == "down") {# b% h* T, k" T
if (yPos > (yMax - contentHeight - BallSpeed)) {
9 M+ s! \9 q3 f- w8 q. O yDir = "up";$ ~5 y. ~* T* b! C `2 {
}# F m$ L( |6 s$ L# r( F7 m
}" i% j. Y- E2 `& T
else if (yDir == "up") {
% W, w2 b. L- P/ ?& x7 W if (yPos < (0 + BallSpeed)) {
. g d- ?: W; y yDir = "down";: M2 j6 T8 \' x7 Y+ h: y/ M
}
1 i) F* C6 c8 C9 N" X* S }
2 D3 Q. Y7 [1 \& H if (xDir == "right") {
: _9 k& X& ^5 p2 _6 v xPos = xPos + BallSpeed;" f! T8 l" e9 c" c3 n+ x
}! l0 Q6 H; W6 i9 x4 U! \
else if (xDir == "left") {2 v5 q: ^1 M$ m- V1 V
xPos = xPos - BallSpeed;
) \, K/ Y# J# i2 y* H }! q3 r8 s; U: M0 o; r% ~8 Y! Y
else {& u' y. i$ P" Z% k8 m% x# T
xPos = xPos;& Y! _$ F# l' P$ i
}. L" q6 b9 E$ | y* [
if (yDir == "down") {
- f3 T% e: {$ K1 \: P% e" Y, J yPos = yPos + BallSpeed;0 }8 s6 ~9 [1 h& e# U. K1 _
}% w1 y" V2 O9 m, p/ V
else if (yDir == "up") {
5 x9 n) o- Z3 | yPos = yPos - BallSpeed;
4 \3 b- k5 z9 f6 R5 G. J# s }6 e! P9 d1 I0 h& M0 |
else {
* ]: P# \; s- }8 o2 `! K% m yPos = yPos;( R: u: j! T$ V8 w5 U0 Y, C/ s
}# o" A" a! @4 [+ j7 e" M
}
; g1 \ D# z' p# A& P4 @ S* e) r r# I7 r& H5 w. ~8 p$ x3 ]
function hidetext(){
" q2 c6 l( _( z; Pif (document.all)
) l" X- S1 i L! s7 y# fsupertext.style.visibility="hidden"5 J* ~; y2 M* }# d( G
else if (document.layers)
/ {8 H$ w, l8 l. Udocument.supertext.visibility="hide"
$ h7 `( R1 ?7 }( P% V' kclearTimeout(animatetext)
: d; N: ^7 v6 O# K. }7 L4 f! Z. [5 ^}
8 [: y' t g5 W" Y) P0 w" c4 I* M! e4 t
: f: d/ A8 f+ ~3 f: xif (document.all||document.layers){
2 `- F! v; M& w3 ~" ndocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 p5 B3 a, v t" gwindow.onload = initializeBall;& d3 H( R. }+ T0 X4 h2 S
window.onresize = new Function("window.location.reload()");, \- e+ o! C3 T$ w( I& p! s
}
) n( \, W3 g9 F1 c7 E, g
- C: V$ a8 M$ A1 i</script> |
|