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

|
网页之不断弹射的文字-特效
<style type="text/css">
+ N! a: A; N+ @8 b8 @#supertext {$ d2 \; E* q' C! s
position:absolute;
) F% n6 m/ z+ N6 Z' oleft:0;" E0 e% C% | y; Z: u2 ]2 g/ F* a
top:0; g4 y- ]) y$ W2 p! [. M
visibility:hide;
2 l+ H2 Y+ q. m0 l( vvisibility:hidden;' i, ~0 h/ ^) V5 k M( I
}9 |4 K1 o& ~( O7 m3 A' ~
</style>1 g+ g& H6 T! y+ i7 g' P& t
<script language="JavaScript1.2">
3 L; L' n. ]# r% n* x; H' S2 Q<!-- 改变下的字体的大小。颜色-->
+ u5 L# t- Z2 T: A, ?6 Rvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
3 y. f5 G* G/ ]4 |/ ?% x( p5 Lvar hidetimer='';
* l" ?% ?# u) y! O/ ]<!-- 改变下的弹跳速度-->
{1 D$ l3 v) {1 {, x' C7 R( Nvar BallSpeed = 20;, {* \$ ^7 {2 J, v# A
var contentWidth;, [" r/ N2 g% f6 q( B* s! S
var contentHeight;
0 B' [4 L6 b0 ~* x, m' A8 n0 \var maxBallSpeed = 50;
" C% t* Y7 b; E. ?% O/ F' G9 j2 X: {% K2 Q" I/ j2 V! e
- }5 r8 C; C5 Q' A" u. x3 I2 L* kvar xMax;* f# Q: M. \0 k; s" z" f5 r
var yMax;4 W z6 e0 A4 W W! F# m
var xPos = 0;1 C7 e) X6 C( b, F. \6 M* i
var yPos = 0;) @4 Y$ v) W: e3 U7 j6 P
var xDir = 'right';
0 F& C; x0 E! ]9 g g/ wvar yDir = 'down';/ [& s( a: X% s/ F6 S! L
var superballRunning = true;
. g, B$ j d3 ~0 T) p1 O+ jvar tempBallSpeed;
; l# n7 e$ Q' m2 u8 X2 ~3 xvar currentBallSrc;
I2 R7 D1 h8 Y5 C; z: ?var newXDir;
% N6 K5 x) v N8 q% ~7 q; bvar newYDir;- W& E! J/ _# P+ Q4 p. R
3 c8 q8 d6 v% A, }function initializeBall() {
$ L# o8 }; Q/ P if (document.all) {
" q( l I* A4 I' \ xMax = document.body.clientWidth* m' \( y$ R3 i7 R
yMax = document.body.clientHeight& t, I" P4 s- \0 |" V, X9 X
document.all("supertext").style.visibility = "visible";
$ I0 y+ k* U M' f- ^" z; @% c% M contentWidth=supertext.offsetWidth. b/ L) V7 x8 m" X8 u
contentHeight=supertext.offsetHeight0 m: O) ~& K% L) v
}3 T5 [0 y" W9 x4 m$ Z+ }
else if (document.layers) {! N0 o, T- X# F, `% R, ^* Z
xMax = window.innerWidth;
5 U; t- m" D: E6 i yMax = window.innerHeight;
" |1 d' K* I1 o. E contentWidth=document.supertext.document.width9 @/ o: V$ p( K3 j. c/ B+ p: P
contentHeight=document.supertext.document.height
) s3 ^0 U t8 P' Z2 r document.layers["supertext"].visibility = "show";6 x! s3 w7 R, L4 [
}
) {' D4 c8 j C+ H! w8 f setTimeout('moveBall()',400); G9 o$ s: Z9 O- |
if (hidetimer!='')
9 Z8 |0 V; ^, ?) D" w) b( e1 W5 c setTimeout("hidetext()",hidetimer)
: y1 e9 P2 J% {' Y0 @8 t2 D" d }' |7 Q, ?* n0 l( w) |
% o9 g9 V& d* y; v6 L$ J$ d
function moveBall() {: `* i6 ]% ^# ], `1 q
if (superballRunning == true) {* v6 B2 c: S; ?3 T; y# J4 A! r
calculatePosition();) C, ?* C( k3 d! d
if (document.all) {8 }. D6 f; A; y' r& M: h: e# G
document.all("supertext").style.left = xPos + document.body.scrollLeft;9 K4 @4 T- J7 A5 i$ I
document.all("supertext").style.top = yPos + document.body.scrollTop;
i& j" x9 i+ H& Y% h }7 a( B$ \; i1 f' I9 i& I
else if (document.layers) {
- u. {: J+ f8 F2 e- @( m' t& F document.layers["supertext"].left = xPos + pageXOffset;; e) J( h+ r. `* i* T: }" j
document.layers["supertext"].top = yPos + pageYOffset;* e& L; t$ L" P& @' h( n
}
9 ?" Y* o7 G# L7 m( ?# z A animatetext=setTimeout('moveBall()',20);
, a* M3 b! V: K% V0 d- V }/ [* v5 t2 ]8 o
}
* D, _& O3 W& r0 ?* ~9 m4 ^
4 r" [( `1 ?2 X! ?( z3 t( ~function calculatePosition() {
U4 [- m/ i1 j0 `5 W+ S if (xDir == "right") {
' ?1 z- F% Q% a: D; Z- [! U if (xPos > (xMax - contentWidth - BallSpeed)) {
, f) [% d' @8 g& N+ t& e$ a xDir = "left";
! l' c% { V7 E+ B# k, u8 x [6 F7 T }- I( W2 U( s2 b# f; |
}* w2 O x; b( W t0 e: i
else if (xDir == "left") {
/ }: J* k) w2 @' O if (xPos < (0 + BallSpeed)) {
( a9 y7 |* p2 _% T8 i xDir = "right";
2 W$ D# U" j( d6 |4 g }
) y& m. h4 I% A, j" Y- Q } H c' G/ ^) C; \ a8 ?
if (yDir == "down") {
" ]3 I9 p- |& o$ ? if (yPos > (yMax - contentHeight - BallSpeed)) {4 K8 V3 C9 E1 {& d/ C0 w( }" A
yDir = "up";/ I9 v7 H* E) a) P2 ]& R
}
9 r0 g/ L6 B6 P/ T4 t# g7 r }; e/ h$ Y/ J$ _( k
else if (yDir == "up") {
! s4 k1 }6 ^7 N6 } if (yPos < (0 + BallSpeed)) {
x- P1 f2 R( b yDir = "down";, u; |. I2 o/ [, ~
}0 E, u( {1 q) W9 j7 }0 n5 S: I
}
: t0 m+ K6 j2 a& H4 ~5 A) N if (xDir == "right") {
5 J6 _5 g) b) k1 o d xPos = xPos + BallSpeed;6 ~2 v3 r. Z4 w! C @" `$ b
}- Q: D6 L4 ~0 C8 p, i
else if (xDir == "left") {
% R. ]2 \: Z* \0 x+ [! D4 I xPos = xPos - BallSpeed; H( L4 K6 b y/ p* h8 U
}3 i2 e: e3 v& @
else {
/ Q& J9 }7 A4 U: s xPos = xPos;
1 \( A0 S/ @, R7 c" C! ^1 P }
6 j& p- l$ y' e8 x0 d$ s if (yDir == "down") {
+ u8 v, j& L s3 T" k' S& A( D yPos = yPos + BallSpeed;) O7 c( f5 M3 C
}
, G' d& \0 J3 q; i C else if (yDir == "up") {
. K3 [4 N- I! s; q; j9 B yPos = yPos - BallSpeed;: c# |, W2 i# j$ q+ X! o
}; ~7 N; m& H: B; ~& }! B) o3 g
else {1 @$ @" g, g* v/ \: T9 z* u! W/ x+ S
yPos = yPos;
( h, U ^ u6 w! n }' e/ V1 d& y0 J1 o5 N8 ?! [
}" V! p( P" G6 j8 V3 c m# K3 r: s
# C8 I( `, }5 I( e$ T- _. M
function hidetext(){
- l1 b" x+ e* ^5 ^! k; W% I) A/ Yif (document.all)
0 ^9 U$ y/ [- Nsupertext.style.visibility="hidden"7 |3 _& k4 m0 ^
else if (document.layers)
: R1 f K% b( h2 @6 M3 U5 y5 `document.supertext.visibility="hide"2 T8 v* a8 C: R% `' T
clearTimeout(animatetext)
. k+ ^' S+ F' P/ }; ?}
) ?% W- J1 h1 T4 u: l7 X2 p& l- R6 w7 L" P/ J
if (document.all||document.layers){
( `- k. t* K. }* J% A- Odocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! Z7 m+ `! R$ S: w% d, Bwindow.onload = initializeBall;
+ ^* j* X. e- n) _1 Awindow.onresize = new Function("window.location.reload()");. T: B- V4 Y. a- W0 V
}& {0 w1 V: P2 e8 P5 E- c x! }
! z4 ?6 v' X, x8 A- j. P# G. b" r% T' _
</script> |
|