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

|
网页之不断弹射的文字-特效
<style type="text/css">
4 \+ P/ L, m/ b$ W4 H; f9 ?7 E* f#supertext {
4 G6 [) @# s, Z. v( bposition:absolute;8 j: X% ~* [. k# z. u4 `
left:0;) U5 F7 t! W# c! ^: v
top:0;
* w- a( f5 x Q, Kvisibility:hide;
1 `# Y. h$ D) y2 fvisibility:hidden;) Y; Z3 k+ L# q: H9 B& A
}( `# i0 m! I* m+ q
</style>3 `+ e( h+ _8 @8 S
<script language="JavaScript1.2"># |% \, h9 _" m B, u
<!-- 改变下的字体的大小。颜色-->, |/ ?; D6 R9 F `/ W
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ v+ P2 d0 g# v: f0 F. [
var hidetimer='';
6 s" C- P! s7 X: T! I0 I, t) u<!-- 改变下的弹跳速度-->1 V# D9 e+ Q2 g/ [. a3 q
var BallSpeed = 20;
( c. r% Z$ W9 s4 u8 Tvar contentWidth;
u& Y; c6 r# l0 W% hvar contentHeight;4 r2 k; Q0 z" H$ ~: x0 N: M8 S
var maxBallSpeed = 50;# c w0 [2 I- A0 J
; p: _9 W4 I) f3 S7 K# ~$ X8 [# n M+ f8 ]2 T
var xMax;% W/ \ I( M: {2 i6 G: m; Y% D
var yMax;
8 f+ Z3 X9 [8 Wvar xPos = 0;
1 V$ G/ i+ x0 V8 Bvar yPos = 0;
7 s: s% N% p$ [ @9 c0 bvar xDir = 'right';
3 o6 w$ R% j, q* X; t1 F ovar yDir = 'down';1 W4 d9 \4 ?+ E3 _) U1 s
var superballRunning = true;4 |0 b' n! C4 e* V
var tempBallSpeed;
9 J+ F: p* c% N5 B) N" ~& `' ?8 yvar currentBallSrc;" ?& ]9 w: K( a! s: C
var newXDir;5 B; J0 u$ d+ K9 K' h7 q
var newYDir;
! ]4 E: G; D8 r" i/ c7 g& ~# l$ m- B8 E+ z; ^
function initializeBall() {
, k$ [- a) @( k% Z if (document.all) {
, T! J7 `& b4 s( r: a0 U& @ xMax = document.body.clientWidth0 w7 F5 p2 N3 ]& Z8 |) _& L; C8 j# V
yMax = document.body.clientHeight$ p6 c' J& I S5 I1 u
document.all("supertext").style.visibility = "visible";5 g" m- w: \/ d
contentWidth=supertext.offsetWidth, ^0 y: _' ^* U) O( c
contentHeight=supertext.offsetHeight5 M. h: j* o `5 |1 m, W
}8 c' l; L# K( i. Y7 b
else if (document.layers) {* W" q% r2 G5 O* I) s! Y
xMax = window.innerWidth;
4 P% E$ V. q4 h& _; G5 T2 ?4 L yMax = window.innerHeight;
/ j0 e/ n+ V3 W1 W& _ contentWidth=document.supertext.document.width! ]$ B6 `( y* `# D
contentHeight=document.supertext.document.height
& T" g7 r# d Y2 L2 B% H' h document.layers["supertext"].visibility = "show";9 v. z5 M9 B3 r
}
4 k0 J: ?9 V/ G0 G: e* D r setTimeout('moveBall()',400);6 c, _1 g+ ^ K- J
if (hidetimer!='')
6 O! V3 S+ F" C2 A3 l( m4 m- m+ z setTimeout("hidetext()",hidetimer)
* i5 s, q, q2 c: l; d4 H }5 _' R& @5 j& _# y
7 ~& G3 j$ z. r2 h0 {) qfunction moveBall() {
0 D8 t& Q) `6 `6 r* ] if (superballRunning == true) {. M& I; Z) P! t
calculatePosition();8 Q+ F8 z3 d9 z1 P3 K
if (document.all) {" U e# S, k* R: V( ^& q+ w
document.all("supertext").style.left = xPos + document.body.scrollLeft;# a& N7 x3 Q$ I# L. f: M
document.all("supertext").style.top = yPos + document.body.scrollTop;
- K/ c) f" W9 C4 z8 }) S H& J: L3 p }
& R+ V, u% H, V# a else if (document.layers) {/ U5 o: i9 n6 U) c; o* E/ \: b9 y- m/ }
document.layers["supertext"].left = xPos + pageXOffset;4 ]% m& L; p9 p9 A( ~
document.layers["supertext"].top = yPos + pageYOffset;
# Y1 ~8 }5 g( |9 T }. m7 N( h8 C$ G
animatetext=setTimeout('moveBall()',20);
6 J6 v1 w& Z4 _ }
6 B* f7 D/ f9 Z% B" r }) E; g% M- O* f" ]5 Y7 q, M' x
! e; }6 c- |; p/ X% i7 S
function calculatePosition() {
+ |' d( j5 z7 y5 S2 k% V2 C& e+ D if (xDir == "right") {$ O. T, n4 U1 D
if (xPos > (xMax - contentWidth - BallSpeed)) {
% }" p( h% E' O. w& y xDir = "left";2 r+ `$ U3 z& c/ p; H6 c
}
. G# m- A; T4 |- w/ i/ H }
) q* i2 n+ d { else if (xDir == "left") {% b6 R A$ v( ?5 F+ s2 @' k
if (xPos < (0 + BallSpeed)) {
9 d8 c2 ]3 t' [- z" C" t xDir = "right";
2 [+ i6 _! R* B/ ?# G4 N1 o; e }! L' l9 |; R9 o! D0 F3 N3 }
}4 U: _9 @# p# O) R
if (yDir == "down") {
% `3 v( k+ |5 J* j if (yPos > (yMax - contentHeight - BallSpeed)) { U1 b: y* Q4 c: |+ D
yDir = "up";
3 X( q5 V* b( S5 Y+ B }( [2 A; r+ S7 i) Z: L9 n0 S4 c
}
3 ]" e K1 B$ {: }0 l4 }7 C else if (yDir == "up") {
( g8 e- g+ [) o; k8 O if (yPos < (0 + BallSpeed)) {
# k" p! x& c% u y yDir = "down";( v2 \$ C# W' q d, L( W7 b1 X
}# P- u- L) }3 X Y8 @
}
) i* Y& S2 L8 Z9 w, B! }* Y5 H if (xDir == "right") {3 s- R' p/ `; L8 s6 p/ X6 }
xPos = xPos + BallSpeed;5 x8 F; r D8 e' F* o! a, C0 C
}. V z1 Y9 I s, j
else if (xDir == "left") {' z. p9 }8 p$ }* O
xPos = xPos - BallSpeed;
$ Q; q- D+ \5 M N L0 t }
, @( P5 D( a9 U3 e' [" f else {$ c# s- T$ x8 r2 x$ w; L
xPos = xPos;
# w: ~1 ^( g3 C4 j; e1 M7 ]/ w' s }! `1 L7 x5 W6 C
if (yDir == "down") {( R$ s8 i% v! j5 V) M, }
yPos = yPos + BallSpeed;, D$ I7 b- C( t
}
. y5 y: W5 p4 i! y! L else if (yDir == "up") {
, X- q) ?" J8 B/ Q' Q! h2 a* D yPos = yPos - BallSpeed;! j6 N! t. |( w, S) a+ L: @
}
* a+ c6 H0 z; O* y4 h2 w else {
) l! [' c2 i5 F yPos = yPos;" x8 i$ U; V; G2 }% f( d( ]
}
( V. }) ?0 j3 D, j! O }/ B, G7 D- s$ g$ P/ ^9 ~# E
! N# p+ |- D7 m5 Q" f! K! G
function hidetext(){" ~/ u! f7 ~! `9 ]
if (document.all)6 z- J+ j6 Q# R, G
supertext.style.visibility="hidden"* s9 G& ^; t# d4 Y G* {
else if (document.layers)6 i3 w5 q% i7 y7 Y5 ?. Q# t
document.supertext.visibility="hide"
$ ^2 N2 k3 C4 o. u5 K( @& X2 tclearTimeout(animatetext)
1 v) A( |2 \+ u2 Y4 K/ g}
7 f: U. F1 t4 e, k: z) K% {
9 J: h1 X+ v' U. I4 o3 w; d2 B Y7 Tif (document.all||document.layers){7 \* g; G1 ]4 S. z v
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! J! S$ t) Z6 y- m: B5 l% |3 awindow.onload = initializeBall;
* z& l' J2 Q& X E$ ywindow.onresize = new Function("window.location.reload()");: M& u1 d" V& j$ a( e3 Q2 X' u
}; j1 N3 ]% d; O3 x' s- }
+ J! w7 q. d" G( P. r3 n) p( \
</script> |
|