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

|
网页之不断弹射的文字-特效
<style type="text/css">- Q& ?/ h# [* `# r
#supertext {
2 `( |" R( c0 s* B4 a5 zposition:absolute;
" }( @! O# s6 k% Z3 T- Fleft:0;
! I* q4 ?7 m+ \/ ?4 N. v, A2 @top:0;2 W: F) D/ C/ h5 C/ C B
visibility:hide;
7 X; C5 k+ z$ w v. Evisibility:hidden;( p4 z, d1 f: d! D9 C
}# I N; X$ u1 t' \7 g
</style>
, P3 [; G+ o( t<script language="JavaScript1.2">2 o' n3 t+ A7 e, e
<!-- 改变下的字体的大小。颜色-->
C. ]- f6 G# V9 D0 P9 ]var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 C! }& L$ \( i( Z$ g: Kvar hidetimer='';# f9 o# B& ~) N
<!-- 改变下的弹跳速度-->4 j6 M- s: x; J Y" w" w# r
var BallSpeed = 20;+ A* i5 X: w: q- ]' U/ G
var contentWidth;3 s0 n/ K2 s/ [
var contentHeight;% C7 b& v) }( S0 @1 l
var maxBallSpeed = 50;9 H% L. ?4 V8 ]# H, E m: `4 n
- |3 y0 n7 E3 m, f1 ?, L1 v N9 M" j4 g H8 w. P
var xMax;' Y: L% ]# p, r, Y% ^
var yMax;- i3 ~" P. ?1 ?" F
var xPos = 0;
3 F5 L7 l+ a1 Pvar yPos = 0;% K' _$ @8 ?: u( L, X% ?
var xDir = 'right';9 \2 a" C! j4 w5 F Q8 z
var yDir = 'down';
$ J) S& R9 |/ k4 z- h. kvar superballRunning = true;; [: V: B, N2 E# g
var tempBallSpeed;
5 B K& K& ~1 I* U8 U" ?& b$ xvar currentBallSrc;
1 a4 w$ ]: X3 Cvar newXDir;
5 d' {8 n6 \# p0 @var newYDir;5 Z. b3 K- ?, W7 Z) {
5 Q2 Q2 \# q( I. {+ o- [
function initializeBall() {* v- D; w' S5 N# _' o8 C( q$ r
if (document.all) {
X6 K+ a$ K0 G xMax = document.body.clientWidth8 R: w8 t+ S ]9 J# L# f
yMax = document.body.clientHeight0 D4 O/ d! ?. t7 z
document.all("supertext").style.visibility = "visible";
9 o0 C/ d! z( H4 S. k! z" W/ r contentWidth=supertext.offsetWidth% B% z- O! d1 K5 O, Q' d: r6 C
contentHeight=supertext.offsetHeight/ O' C' ?/ i5 s% j( _, C
}- M% s0 H; m1 k* l; R: |
else if (document.layers) {
1 O' }& d# ~* { xMax = window.innerWidth;. u p, i o; e& J
yMax = window.innerHeight;; o$ Y6 i a1 j( G. R9 c2 @
contentWidth=document.supertext.document.width! V( C% |; D; @. a' S
contentHeight=document.supertext.document.height
/ w: z- H" D" c2 r" H, C8 ]2 ] document.layers["supertext"].visibility = "show";2 J4 j& F7 N: r" V, `
}2 j8 C% e! w; I
setTimeout('moveBall()',400);
$ s& c" O: l: i if (hidetimer!='')
% {7 ]2 ~" U/ ] setTimeout("hidetext()",hidetimer)
: g- B/ G. R4 S$ _ }
7 w/ Q7 j5 z& x5 ~9 p. f% u
+ @0 a5 d1 s, u* e+ G ^8 Ofunction moveBall() {
% {, V0 O: k3 h5 I( ]& D if (superballRunning == true) {* J; }4 ^ g. ?6 S0 O
calculatePosition();
3 N' j2 j# I7 E( f% \2 M9 b if (document.all) {
+ g; J: R' X* q+ P0 T ] document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 H5 O0 L8 X; [" m document.all("supertext").style.top = yPos + document.body.scrollTop;" T- x0 @5 n; v/ O( p, j% d
}8 I( K* l# g0 Y4 L5 r
else if (document.layers) {$ u$ l2 L' f' P4 e
document.layers["supertext"].left = xPos + pageXOffset;
0 S) S3 h4 c2 u: p* W% k document.layers["supertext"].top = yPos + pageYOffset;! h& l- q2 r+ x6 j
}$ m2 j% x4 _2 I# P! g) @
animatetext=setTimeout('moveBall()',20);
8 F- {' z0 j+ Z( d }4 C1 i' M$ e6 B% }6 p7 r
} y( ~9 t& z% S1 S' b( T7 G
# k9 }0 Q: p, W! b$ T* ]function calculatePosition() {
+ M; w6 l7 ?5 K, w; s5 q& f if (xDir == "right") {
2 M' |8 d* v# d$ c2 E if (xPos > (xMax - contentWidth - BallSpeed)) {
; Q4 f" m# R* R% y- w xDir = "left";
+ O( T/ e E1 T }" I: S. _ ]% W5 u1 b6 j2 _+ n
}
- F# p8 n% C0 P* {: ?+ P+ f& r else if (xDir == "left") {6 F# F2 l/ i& j/ E4 [1 T
if (xPos < (0 + BallSpeed)) {6 n# H' [ U2 G7 i% m" h/ y
xDir = "right";' |/ [4 T O' }. l9 t' `# V
}
8 |% {4 ^& F }' \0 E& j }( `% A a9 L( I' Q! |
if (yDir == "down") {0 x: R6 c6 a# [7 }* z0 V# g
if (yPos > (yMax - contentHeight - BallSpeed)) {
! H! N P- ]5 J/ z; _% ] yDir = "up";5 j+ u n( y3 s0 K
}& d- ~' W' H1 s( w/ e
}
& E" q8 |2 u) E0 X else if (yDir == "up") {; m8 X4 W O+ Q( t! i! H
if (yPos < (0 + BallSpeed)) {( X' R8 Q1 ~' e: N
yDir = "down";1 i% K( I, Z6 E2 ]- s* W5 t
}
i+ z$ p3 I/ V1 `! y( A }
/ T# n& N1 Q" z' s8 d% w* r if (xDir == "right") {+ M" N2 B! O+ m' G6 c. c) f
xPos = xPos + BallSpeed;' x+ ~! y! @6 S( E P/ w2 t, }" C
}7 P1 V7 ]. a/ ~5 v
else if (xDir == "left") {
/ n4 Y4 Z: G, t$ p3 p xPos = xPos - BallSpeed;
1 f* J F" Y5 v. h" h* F }! I+ x2 F3 E4 U7 M# _+ a) g4 N& \" h
else {3 R: k; o l! g" S
xPos = xPos;3 |. [: P* |; [+ H s
}
9 X8 Q# t: x" e* ~. d4 Q if (yDir == "down") {
' i6 m/ [& S4 K/ R4 A yPos = yPos + BallSpeed;
8 }4 V! s m5 I" E& o }
6 T8 C. b" P3 ^* ^5 @: _ else if (yDir == "up") {
" a* f6 V2 F% ]# M# t6 g yPos = yPos - BallSpeed;% y* j& J1 A) l$ r5 J
}
' m& e2 f4 U0 W& h# ~) H, N. | else {
1 U+ f3 Y8 e! S2 X+ u yPos = yPos;
" @5 \% u4 l6 E; ~3 U" J6 \ }) r0 p3 y7 n" _: g- }2 D
}
" |/ ^! V0 G" d+ q4 D& [2 n5 o) w8 [2 e4 V
function hidetext(){
: F. p. S" C3 y: @# Aif (document.all)
. o) j3 [3 A% o9 m8 m# h: T0 ?supertext.style.visibility="hidden"1 D* \7 y0 M9 K8 C
else if (document.layers)
) y; v; V8 w0 H: f* y' adocument.supertext.visibility="hide"
9 X6 I. Q/ K+ P0 W( U5 M( BclearTimeout(animatetext)
. r0 L3 ~- n$ p- J' g}$ q( ?( T# j1 r+ a1 R, ^
: t; c4 V5 i1 l% b8 C
if (document.all||document.layers){, L3 k* \, g' d7 o u" Z w
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& `. V* v2 D4 `+ |- T
window.onload = initializeBall;
% d/ C( b) P9 vwindow.onresize = new Function("window.location.reload()");
5 U4 ]: S; H9 C8 B7 p}+ p% f( ^7 F1 |+ y% a* E
8 X2 m0 j5 `4 G" c: {</script> |
|