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

|
网页之不断弹射的文字-特效
<style type="text/css">
, w g ?/ P" h: L) f#supertext {) }2 v# Z9 \0 m% K
position:absolute;: ^0 e3 K5 u: }, P# }# ?: W( C1 C
left:0;
8 u- ~3 }8 d* B9 {; l5 T0 wtop:0;# z$ u. h+ C! u2 e2 L4 @
visibility:hide;
3 z! c1 S" A3 n; h, _8 I! Jvisibility:hidden;+ B; s+ Q) g3 t
}' t4 {, I# N- o6 s% W5 d
</style>
# u+ ^9 x9 G) m3 ^5 o" e, y<script language="JavaScript1.2">
/ B* ?% c* z' i<!-- 改变下的字体的大小。颜色-->
3 R! ?2 s8 S7 t& j2 @8 e& Gvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ N/ j8 c* j) S2 l7 C$ c; q; i
var hidetimer='';+ }9 S! ~9 S! K F: n
<!-- 改变下的弹跳速度-->
" C _- Q# t4 nvar BallSpeed = 20;
4 c( [" J8 ?2 m% fvar contentWidth;) b9 L! o8 }$ F1 l
var contentHeight;. Z6 \$ e0 o- |( x5 c6 J* ?
var maxBallSpeed = 50;
* C! G' c w- J6 i) d& X) c
: s$ L! m9 {$ e# |; X, t5 L" u
- }, q; K- S; f2 n% K) ?var xMax;
: K! n. P! `$ s5 L. xvar yMax;: c% r; Y) O) ^! j' k( w
var xPos = 0;
5 v! M1 x1 N; k) S8 U0 I+ d, \var yPos = 0;
. f$ `+ ]5 e; J& \var xDir = 'right';
* ]8 }- v, j' W7 F- z# B, B# Avar yDir = 'down';# a* K1 D* u, X
var superballRunning = true;% @; Y0 c/ t$ b+ p& y) h8 S; u
var tempBallSpeed;, d( }4 P# D1 A9 Z5 y R$ y4 i
var currentBallSrc;" r' f3 s S! L5 {) C0 G% c
var newXDir;
' `0 F* z* A8 H6 K% h6 d0 S0 ~* H* ]var newYDir;5 Z& \ D4 n* A
6 Q1 k- s% U) g# J- }
function initializeBall() {
0 n. L) w% t/ c# ` K if (document.all) {$ V5 L/ v3 J& S3 C# q& k2 n' c" H1 r8 x
xMax = document.body.clientWidth4 K* x% k' e+ {3 {! ~4 N
yMax = document.body.clientHeight, p: {. A+ U1 X9 |; e: ?9 A; E2 @
document.all("supertext").style.visibility = "visible";
/ S1 Q* X3 }0 O4 K9 ?! W contentWidth=supertext.offsetWidth
& |5 U5 I3 O5 a8 }0 O/ c contentHeight=supertext.offsetHeight
5 F4 A' `# v1 \, K" Z }
" \: F4 F% m+ g/ v2 O1 K else if (document.layers) {0 g7 q3 I9 y- S4 R* y
xMax = window.innerWidth;. w' x W7 r; |* b# C
yMax = window.innerHeight;
4 b. p& z9 i' }7 `+ B- E+ Q3 } contentWidth=document.supertext.document.width% U3 P0 J+ \# k$ Z! ^7 _' G. b" p# X
contentHeight=document.supertext.document.height
' }4 E' A) G- I0 s. ]- K1 S0 M document.layers["supertext"].visibility = "show";
) ]9 q% N. h7 S5 T4 f8 n: f }
) ~8 L3 y4 k8 ^% g1 h/ i setTimeout('moveBall()',400);4 \, X) n2 G+ @/ v
if (hidetimer!='')
" O* R% |8 s. D/ g- a0 A setTimeout("hidetext()",hidetimer); L' v! q, L9 e# {0 B6 i
}# J$ i7 X9 ]8 N7 Y
: Q. l* L+ w4 `, c1 U
function moveBall() {5 V* ^: N) g4 ^
if (superballRunning == true) {( S% r# k- ~+ S3 D# v! H
calculatePosition();
8 R' }" l$ e1 ]. U if (document.all) {
+ ?& s9 t' g! D, L1 F6 \4 T document.all("supertext").style.left = xPos + document.body.scrollLeft;( z, h1 k' [) d, Y
document.all("supertext").style.top = yPos + document.body.scrollTop;
; n2 r2 N$ j* B* T% p: x }
: Y/ G& C' k r) o; Z else if (document.layers) {
1 @* [+ Z) E7 `) T a document.layers["supertext"].left = xPos + pageXOffset;
9 N. z. n' T, K+ L2 }& G/ W. L document.layers["supertext"].top = yPos + pageYOffset;. t0 w" M. a2 N& d7 P9 d( }
}7 k# i" n4 {' J! r3 k( C
animatetext=setTimeout('moveBall()',20);. l6 h; v' {4 Z6 M% a6 \
}) T4 ]6 l u) S1 [! I# f
}2 I5 w9 i+ ] h3 f* r4 E
; F" B! a5 u# R* b# ?
function calculatePosition() {
9 i; |' A+ ~+ ], O if (xDir == "right") {
: ?9 h7 w" v$ n6 @; n8 q if (xPos > (xMax - contentWidth - BallSpeed)) {; Z' u p: w6 }4 |
xDir = "left";6 M% ]5 Z" A7 D) g
}5 n( d7 P* ?$ T; [( I. k8 @7 u
}
: R5 i' a& q6 Q: n9 ^9 s7 k else if (xDir == "left") {1 ^) c3 o5 u% U
if (xPos < (0 + BallSpeed)) {) t h: Y6 X2 r1 Y
xDir = "right";
N$ e5 E/ d! G' q# E: h }
1 s* A( o% ^" `- y }0 }9 B3 N0 s" A2 }0 L. s& k
if (yDir == "down") {2 d: K% d+ i1 X8 A4 P2 B4 F
if (yPos > (yMax - contentHeight - BallSpeed)) {0 Z( x; Y7 ?6 W% M
yDir = "up";
0 A) E% p8 k: A+ v" \ }$ ?* x! C0 y& r, e6 P
}
7 O u# h) a; G& _2 @5 f# ` else if (yDir == "up") {) m# p- d. j! Q5 l: X
if (yPos < (0 + BallSpeed)) {
& x' k. e+ W- g4 ~) b& ^! i4 f yDir = "down";4 i# c3 z' R) y9 X! C
}: {( y2 y6 @: H' ]9 B1 Q
}
8 h+ r) k z, N3 o3 i$ `% w if (xDir == "right") {3 U& `" P0 u2 F
xPos = xPos + BallSpeed;1 v: u/ h# P% g) E2 }+ o* k
}& b3 U: K4 U& P9 L: \
else if (xDir == "left") {2 u" g6 E6 g1 |* i9 j* R5 F
xPos = xPos - BallSpeed;3 H+ x& D$ G4 n( u+ S; z8 [, ?
}
' w& r- x3 ?8 T: J: B9 k: i% f else {4 P3 D* n" k2 \- \) g0 s% J3 {6 g X- |
xPos = xPos;4 O6 T1 D( F L
}
a5 t: ^& U3 ^% n. D5 K if (yDir == "down") {% P7 ~+ \3 q, \1 O) |5 s. X
yPos = yPos + BallSpeed;
' {( c: q& P6 W2 a+ {' w5 O' s0 W }
+ M" @) ]3 \/ H3 E9 l( G else if (yDir == "up") {9 q' ^' Y2 U0 S2 M
yPos = yPos - BallSpeed;
4 ?. x- ~ L- t }
, Q: c# Z( p+ v1 j0 F else {0 g4 }2 g: X& A- [' h* K' G4 m. f" C( \: o
yPos = yPos;; @3 D/ N( `5 ^& L& L
} S+ i) q& W8 d4 V0 {
}, `8 m4 u+ C1 }* @! N. g) N
7 n1 M7 T; n% t: Y- J& J) Ifunction hidetext(){
2 _: J$ ?3 d7 y6 I# dif (document.all)
* p6 l" B6 z- D/ T' `7 qsupertext.style.visibility="hidden"
) a6 b0 \! c6 B5 C8 w+ |* Xelse if (document.layers)$ R. K. v5 W; S- i
document.supertext.visibility="hide"
/ b7 V! w. i% H. OclearTimeout(animatetext), [: s0 t/ R2 N
}
7 w9 p4 o. E8 x* ?. ]+ M" O: T: A0 M! H! f' m1 U6 v& Y
if (document.all||document.layers){; v& ~) A2 Q% |8 `3 A
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ Y6 d5 T( a8 H3 |9 @4 W: U5 L" G/ o( Fwindow.onload = initializeBall;
8 R; U! E2 a- [- m4 M2 C; Q' ?% T4 Xwindow.onresize = new Function("window.location.reload()");
( y) q6 o) I# ^1 d1 M6 [4 j}
) R7 s. [5 H; y$ F( A( w) y* E, _1 f
</script> |
|