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

|
网页之不断弹射的文字-特效
<style type="text/css">6 ?: J. Y$ ?) Y$ Z% y, r
#supertext {0 f' H7 l, g" l" f0 |6 w* r( {9 @
position:absolute;" d+ m- M V; {
left:0;$ z. J8 ?5 f8 V) E, m1 Q K; q8 w; s
top:0;
7 Y3 e, G- V* @7 Y2 }! ] h6 L- Mvisibility:hide;, h2 h. ]( Z( @1 n6 ]* [/ R
visibility:hidden;2 B R4 V$ U7 O+ a- }1 I
}
1 A9 O2 Z( f/ X, d- Y9 [</style>. v8 n+ \! K! X1 W( `# S' q0 K2 r( z
<script language="JavaScript1.2">0 B8 u" m# l& a
<!-- 改变下的字体的大小。颜色-->" M4 D: m1 o* X" V- H; V5 ~2 u* t1 G
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'' ?" J% W% P y+ `
var hidetimer='';2 g5 v% R+ L( e3 K% J+ C. I5 U5 G
<!-- 改变下的弹跳速度-->
* B/ I1 y* c5 z( M% i4 fvar BallSpeed = 20;
& L" K1 O" h6 v+ J" Evar contentWidth;8 U( [3 X$ t' t( h+ _( c
var contentHeight;
6 G" A) ]; }+ J' j: Q; T; Hvar maxBallSpeed = 50;) c% @$ K, ]! \6 |
! e+ u r6 _ X. ?
' l# [' h" k1 Z: ?6 ^var xMax;
: z% U0 l; |/ q Jvar yMax;
9 m( L! E$ z6 Q* [8 w* ovar xPos = 0;
0 w( ~; g t" A$ |# Y8 t( Lvar yPos = 0;1 K9 C% W. d$ m& t9 O: e
var xDir = 'right';' }( ?. U; G$ A$ ]5 ?2 T' {2 `; T
var yDir = 'down';
9 O4 I, I5 ^# o: k/ ~8 B9 Svar superballRunning = true;
8 D% W2 r; T/ A: ^9 Q/ F: Qvar tempBallSpeed;0 M! [9 E+ f" c" K
var currentBallSrc;# X3 y7 `& k8 g
var newXDir;6 t- J& x0 O1 O2 ?; |* l/ q* X
var newYDir;" ]& E% u& P `9 y% x( t" i
9 b+ j# ~3 G+ X E' Hfunction initializeBall() {* d; z. I* M' X) X0 I3 v
if (document.all) {
1 E: | B8 C0 u$ E j. t/ u xMax = document.body.clientWidth
$ P$ C8 w9 d& h5 E8 M/ L3 l yMax = document.body.clientHeight
2 W& p/ Q: ^$ q4 n6 f3 E5 v document.all("supertext").style.visibility = "visible";, G k# a! ]8 i4 [
contentWidth=supertext.offsetWidth1 Z* B) l* f+ j6 D8 z* }$ i
contentHeight=supertext.offsetHeight( |8 Q+ ^& X, f
}( \1 i5 Z3 m9 n$ T7 u7 K
else if (document.layers) {
, U% C4 I9 ~3 p, U xMax = window.innerWidth;
* R# i" {- Y1 s1 L& I8 e# E yMax = window.innerHeight;, f9 Z+ V. Y" K" J- W, t
contentWidth=document.supertext.document.width' t2 W) T$ @( w# w. ^
contentHeight=document.supertext.document.height
% ]5 u9 j, c4 i, r% v! Q document.layers["supertext"].visibility = "show";' c" i- J1 P2 ^8 j, B
}
6 a, E, R2 D- M4 G$ E' v+ m: C setTimeout('moveBall()',400);
6 G9 r1 n8 |) G. b0 @/ Y4 ]) t$ k' n6 u if (hidetimer!='')
( W6 B) w- V) f$ H* h# J4 g setTimeout("hidetext()",hidetimer)9 j) v! V6 ]. Y( L0 H3 F
}
! X) _" y0 W% n- R7 }! }( ?" e/ | e0 U, r8 c p4 ?; b+ K) q' E
function moveBall() {8 }% c6 w1 Q7 h y/ O6 D/ k, s1 q
if (superballRunning == true) {5 ?4 A- \+ ~9 u4 D9 e# h4 A
calculatePosition();3 r! @( O s- M o* w- L7 A
if (document.all) {* u; C8 l/ M0 n* G- N+ j5 P
document.all("supertext").style.left = xPos + document.body.scrollLeft;
- g! ^! y; Z' s, y* y document.all("supertext").style.top = yPos + document.body.scrollTop;
8 k/ i y! Q0 }* {3 ~ }
/ C) I6 v U) Z8 L" ` else if (document.layers) {; O; ]$ b# |2 W* u s& U
document.layers["supertext"].left = xPos + pageXOffset;
1 b7 R& K' I# U; x$ P+ C document.layers["supertext"].top = yPos + pageYOffset;, Q9 W# _. C4 ?1 F5 L
}' I `$ p0 w7 C) H% k0 c
animatetext=setTimeout('moveBall()',20);
$ c1 |4 _0 f5 ^. l, i! ?: B }
! z. `$ ?: D0 q }
; `! J6 l- v# S$ G7 z0 _
2 I! k! Z9 T ^: b% o% rfunction calculatePosition() {% m! y+ o% i% [
if (xDir == "right") {: k; \- j6 f2 c3 j
if (xPos > (xMax - contentWidth - BallSpeed)) {( ~7 t3 l3 O' {. R% T1 y; t
xDir = "left";8 ]! Z+ F1 F% Z! \( M) P+ H* t
}4 W- V- v x' E7 D
}8 d4 B) h! n* C
else if (xDir == "left") {- J1 K. A& W! z9 }8 c
if (xPos < (0 + BallSpeed)) {
: \* T3 n8 X+ B, ?6 r t U xDir = "right";' a0 K) f$ Y: [1 T
}: o* n+ c: B$ T2 h
}
6 `9 U$ A5 c& r% C9 V( D& q5 N if (yDir == "down") {0 Q/ W; f; M$ T% i5 g6 G$ O6 D" P
if (yPos > (yMax - contentHeight - BallSpeed)) {) K2 G8 R% K! B" S3 a* x) i4 O/ n O
yDir = "up";
& _. ^, L9 D8 p5 v+ G* E3 {& o }& K0 P8 y% E @2 ~5 q
}4 R$ q# h4 ?, Z6 B
else if (yDir == "up") {
% |3 e; N' ^. O' o9 l if (yPos < (0 + BallSpeed)) {: S( w6 ~5 c! j) ]4 a" p6 N
yDir = "down";6 b3 G) E, n4 M8 o7 p3 Q+ g
}
' V* E' ], t5 a7 Q$ u8 A }
$ ^2 Y% H3 d, E% U' E5 @ if (xDir == "right") {& J7 P9 C/ L3 W8 U
xPos = xPos + BallSpeed;
( m1 w+ k, d! L6 ]9 \8 L a4 H }: r7 \- n& l) x) e
else if (xDir == "left") {+ F0 t& A E x( Y( `) d9 x
xPos = xPos - BallSpeed;
/ ], s/ u/ K" W' D. r }
. H1 f. e. U3 A5 z: l9 P* i else { H6 n( r- y: ?' M6 E
xPos = xPos;+ \; L% U& y# {7 Y8 k& ]: G0 y. K
}
/ k& f& V7 z+ K+ M* [. \ if (yDir == "down") {
3 c' a4 E/ d6 N. [ K8 G yPos = yPos + BallSpeed;8 H' m: }! _1 v2 U2 I) @" ]
}
, J- {+ n) b7 j% A else if (yDir == "up") {8 v, \5 m& W, `( V& ~: C1 C% J2 d: L
yPos = yPos - BallSpeed;- k; r, w \9 I+ R! U
}
9 z- d0 K; N7 v% Z* X else {
# k: _3 q9 t( H7 l' a7 T, }4 ~& t yPos = yPos;5 |! r1 A3 `# [8 Q
}
/ D7 G" w* ~- N. a$ J+ R |% Y/ { }
V) n2 D) m7 m9 q( a( F7 U1 [( g$ p- `7 r2 P& Z; A& e
function hidetext(){# I, i- k6 @) C" Q0 M8 i0 ]
if (document.all): Z* W* L2 m/ i% a4 i0 N$ J$ a
supertext.style.visibility="hidden"+ A: K+ F, m8 `0 |) ?8 E& @1 @6 A
else if (document.layers)+ z J$ Y/ Y6 a$ X( l* ^( J
document.supertext.visibility="hide"
, S) V; d8 Q- [# F+ m! ZclearTimeout(animatetext). D' a" U4 L: S" T
}4 }6 P3 J- u) _) f& P
+ i' \/ F6 I/ @+ l. a. gif (document.all||document.layers){3 B u0 s! E* S+ c- j; A0 {/ T/ U& b
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 ~- Z) n) e u" [& Nwindow.onload = initializeBall;
% Z2 J) S" y- f( n' Qwindow.onresize = new Function("window.location.reload()");2 O: i* Q6 J& k. C8 M" i; q
}+ c0 N. m4 Q9 L& ?8 M' x
, l; M* @! @3 H: X. r</script> |
|