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

|
网页之不断弹射的文字-特效
<style type="text/css">0 p, m3 b( d3 Z J) r
#supertext {
# l: S, B1 ?$ U$ gposition:absolute;6 e/ c! l0 I8 m6 E% d+ G
left:0;
: V- U8 I4 o9 ^! Utop:0;9 a. ] N. l5 f6 H! Z/ Q q
visibility:hide;
1 C# T8 t. f& j/ n4 f! Q" I$ T3 Ovisibility:hidden;9 ~( h( w7 [6 U6 T5 f
}
' d8 }" k8 J+ ^! T7 P</style>7 @7 |4 n, E) I* U9 N1 ]' r( b
<script language="JavaScript1.2"># G* f& ~+ r" p$ J v
<!-- 改变下的字体的大小。颜色-->
3 P, W6 U( n" A+ Q- ^" Lvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') O9 H( q1 O$ h2 S5 [) y1 R! I
var hidetimer='';9 {9 c5 H# V" c( g
<!-- 改变下的弹跳速度-->6 r1 x+ X( @& M% W
var BallSpeed = 20;
& v) N" u+ |, l" |( tvar contentWidth;$ `$ {- o! P5 p2 v4 ]9 t+ [$ f
var contentHeight;
2 y9 x1 r+ f5 n, F6 y* zvar maxBallSpeed = 50;
8 ^+ V8 U5 g0 \" P/ i7 H# J# N3 i) s, V; c. Q
% w* X3 i3 P& e
var xMax;
9 G* h, W4 y: x: z ` t3 T" mvar yMax;
2 F. ?' _/ ^4 r& n6 F5 tvar xPos = 0;3 L; x! J* c! D1 |2 h2 k$ f
var yPos = 0;7 ]' i$ \! j/ D2 N5 a
var xDir = 'right';
/ ^5 g. M3 D" u! }var yDir = 'down';7 Y0 T! |; S; S+ \2 y
var superballRunning = true;4 X8 b3 Z, b8 m! ?8 d
var tempBallSpeed;5 D2 j' h0 Z5 h# e) }2 c! C
var currentBallSrc;5 K! ]& l0 w: ]8 ?/ A3 F
var newXDir;4 b: \; ?3 S9 n' {' E# p
var newYDir;
, x, ~. k2 s+ o0 S& w3 ?- O/ Y
0 R2 _% A5 S0 C2 a& F; @function initializeBall() {
, @9 Q0 z) D2 @ P& Y* P if (document.all) {& O; H1 k) m/ ~5 `
xMax = document.body.clientWidth x" u! h4 o+ E0 ^+ p }& e
yMax = document.body.clientHeight% B0 C3 q r# i' [, H
document.all("supertext").style.visibility = "visible";
8 C9 r+ d) k3 ^! d/ s% e; x contentWidth=supertext.offsetWidth
3 o2 v" g! t9 u5 w8 n4 t! Y0 ?& C contentHeight=supertext.offsetHeight( N5 `7 o$ O! H
}; l; T) u2 ]+ q3 u- u
else if (document.layers) {
$ V/ c! z& y& {# o) m xMax = window.innerWidth;
7 f' g1 {% J' K5 z j5 h6 |" L% X yMax = window.innerHeight;
; ~( |0 t$ s3 Z, y) w* K contentWidth=document.supertext.document.width
' B! W3 x% l; F" _7 P$ L contentHeight=document.supertext.document.height
( R d4 `! }5 |* ?7 z8 t0 k document.layers["supertext"].visibility = "show";& u2 |. A( v. F* Z) w
}
! ` I/ o; k- f# | setTimeout('moveBall()',400);+ h4 V5 h" q, e2 J$ t# h$ F6 {3 P8 J+ q
if (hidetimer!='')
" |8 O9 [- B m9 j6 r. F% ? setTimeout("hidetext()",hidetimer)" s% s% s$ j5 w5 B8 \0 [0 y% U
}' t# q% j/ V* c, o
) e' ~* O0 G$ o& Dfunction moveBall() {
' Y% p3 M0 I. y& U if (superballRunning == true) {/ v8 i1 k, p9 E/ q* D0 N2 }
calculatePosition();* P0 b0 a* x7 q* h I
if (document.all) {
+ o$ c u6 r8 M% O* I3 C* i document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 C" ~; z8 M, D$ u document.all("supertext").style.top = yPos + document.body.scrollTop;( I( z/ A! n0 Q0 }" }& D% d# Z
}
5 m0 A- N* {# d% o8 N, H8 E" t/ L else if (document.layers) {
" R% x$ d' ~" W3 X, b7 _. { document.layers["supertext"].left = xPos + pageXOffset;
. J6 S1 [9 z: @ document.layers["supertext"].top = yPos + pageYOffset;
; R" t8 z6 b# z$ m* y1 H }
+ Q0 s3 K! ~. u animatetext=setTimeout('moveBall()',20);1 f/ A: }0 k* E6 Q" y# m. b
}
5 Y0 y2 o# T1 N& d2 Y6 o: O }
7 R' L5 d$ c8 d7 H( ?! f: R- I" f) o: l4 i3 Z/ d4 n
function calculatePosition() {7 s# E$ e1 m/ g% h# u
if (xDir == "right") {; V+ [! r8 T4 I9 J" l- E
if (xPos > (xMax - contentWidth - BallSpeed)) {5 F6 V# ?" l& E
xDir = "left";" ?% ]. I& R4 @# ^
}! }/ L6 g" I& ~ L4 {5 J& X
}
' l' E. Q3 B" c( k4 D else if (xDir == "left") {
3 o! A2 N- x2 F if (xPos < (0 + BallSpeed)) {0 M, f4 U1 ~/ P7 _: d$ J
xDir = "right";
0 u* x, U& ^% D( a3 I }
- w+ f: l4 _: C }6 ?8 }4 v. u' S9 S$ q# g v7 u
if (yDir == "down") {# E; {" V% X" Q
if (yPos > (yMax - contentHeight - BallSpeed)) {( j& }1 F. c& @8 f+ J
yDir = "up";
# ]) }' B: [7 N: X2 k }
: e$ s* ?& u: h }; i, f& I% ?: S4 i9 ~9 ]4 a* s
else if (yDir == "up") { {5 ]2 h5 G! Q
if (yPos < (0 + BallSpeed)) {
7 o! U, c, q p' P yDir = "down";$ V2 a4 D( G6 o+ t Z
}
; h; [9 Q, N" x* G5 o }7 N7 A: @% t1 P- l# t
if (xDir == "right") {
/ x m, E, A# }2 w3 o+ q2 h xPos = xPos + BallSpeed;
3 Z( F. b! c. i }
% W0 g, ?0 P, m. g2 K1 X else if (xDir == "left") {
/ I( \9 j. G( a xPos = xPos - BallSpeed;
' R. c1 L5 A7 {9 t4 S4 j/ z/ { }
0 n- H3 p" z9 X6 ^% | else {7 M2 c/ R, }9 Z. u5 J) e. K
xPos = xPos;$ ~! z! C! Z/ J ]
}
: \3 _9 k$ m' k; x" U if (yDir == "down") {
% P1 n' O) s3 V; E# M: r yPos = yPos + BallSpeed;0 E$ }, _% _+ U& d! j# W4 l
}* K- _# L+ {7 J3 T, w% T1 D+ E
else if (yDir == "up") {2 X# A. i: \9 l+ _/ g+ w; x& w
yPos = yPos - BallSpeed;" t8 b& H0 I5 S! F& d( H
}3 Y4 E$ y7 R# W0 i$ o8 E
else {
8 d$ h( }) P3 t5 N" g8 e" C yPos = yPos;7 e) [$ ~3 w" A$ t4 l6 @
}2 T2 }, G1 c" W' q' ^' k5 z
}
3 ?8 J4 S4 m$ B! s5 B: n Y- j2 ] w2 E: M) s1 D1 n
function hidetext(){2 ]- {+ K2 x0 {: z6 @
if (document.all)
2 ? B% n, p% v; D4 B( Jsupertext.style.visibility="hidden"
/ ~2 _, x7 x4 ] i5 o% R5 pelse if (document.layers)" @3 d+ Q2 g: L0 [1 x8 }' Y
document.supertext.visibility="hide"
. ^* d6 I/ Q0 M! e3 k' J) q9 \clearTimeout(animatetext)
7 O9 ^) U" V6 w# Q}
) y; w3 R' q2 \' m. a, }* o) w# k" P+ K2 }5 Y( Z; @8 ^
if (document.all||document.layers){
0 \/ ~$ ]- u& J7 Y7 W8 ?document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) b5 c+ _& Q8 V+ [8 l( R% Ewindow.onload = initializeBall;# N+ Z8 r% c8 B* [ l
window.onresize = new Function("window.location.reload()");
& O. j. }3 D$ ?* d8 [* [& k1 W}4 ?* q: I( K5 ~. Q8 O
B3 _/ D% _# S& u</script> |
|