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

|
网页之不断弹射的文字-特效
<style type="text/css">$ M! G; @0 u7 K- D$ W2 \0 R [
#supertext {
* q( |, t: W# V$ S8 Iposition:absolute; Q a* w# e& C$ T' X' }
left:0;
" E1 v$ L3 ]9 E7 N! Ctop:0;% K+ j1 I/ g( P# x
visibility:hide;
% C# u1 c s1 A, fvisibility:hidden;
, y! i7 S; S& w% q1 z+ b' S}6 W4 g- e* X* i7 N V5 ?
</style>* O. N3 H# d3 _( @2 T; P) ^9 w
<script language="JavaScript1.2">; Q$ i$ p) r" w. v/ W) |
<!-- 改变下的字体的大小。颜色-->
" [0 O9 h6 S: T, B8 tvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% c! X6 w2 t0 j- D9 N
var hidetimer='';
9 m# `& K$ H8 j& }6 R<!-- 改变下的弹跳速度-->
6 g5 C; C7 e N0 svar BallSpeed = 20;! K" {5 O2 ?4 @; L; z# V- ]
var contentWidth;
$ T$ T% E2 O0 y, \, Avar contentHeight;
' d0 G6 {" e, u9 i9 Zvar maxBallSpeed = 50;
8 l a3 B: N$ ]# u
5 W7 Y( W" H2 F* N: R
1 n8 p8 t. @1 D" U4 P1 [var xMax;. N+ v0 o% y H0 |5 `! [, f
var yMax;
4 ~& Z! y! i# ~. o* xvar xPos = 0;
) S; x* g' T5 s7 ]5 mvar yPos = 0;/ C8 V0 I w! G' {$ J) O) f
var xDir = 'right';
6 D. ?) ]- S1 h# evar yDir = 'down';
0 f" A& K0 G9 N1 ~var superballRunning = true;
7 K4 w+ B: |; Q W. {* o- Tvar tempBallSpeed;
( z; G: l- Q( g7 X: e8 ~( L% Gvar currentBallSrc;1 _5 P" ]& {. A
var newXDir;0 h% f8 d, E9 O- t i
var newYDir;6 Q; y# k' S; C/ u5 }+ F( r# m
2 l4 C: y+ \( L9 F+ g
function initializeBall() {
# J) u2 h' \" A ~( E9 E if (document.all) {( \+ q+ B( F/ k4 h( W* n
xMax = document.body.clientWidth# B( K, D9 j- k5 \5 q/ M4 X( c* x
yMax = document.body.clientHeight
$ f& A) |8 g5 G0 d; F$ E" \ document.all("supertext").style.visibility = "visible";+ o( [* Y3 E, `! Y9 N
contentWidth=supertext.offsetWidth6 ?$ l3 S$ r5 b: z: w
contentHeight=supertext.offsetHeight x* e4 C! o# b! Y% Z/ E
}: J. u9 g) ~1 k8 B1 p
else if (document.layers) {
5 z& g& t i& o c& b( E! m xMax = window.innerWidth;
( W5 k$ T9 i+ D1 e! ^ yMax = window.innerHeight;
4 k$ X6 T2 Z' t contentWidth=document.supertext.document.width
% E0 ?) J$ u! U; J. m8 f2 v contentHeight=document.supertext.document.height: Z) G8 d3 d; h5 b" t
document.layers["supertext"].visibility = "show";
1 h: W+ C5 k9 F% |& K0 ]8 W }! D# O+ X' P0 {8 a' a
setTimeout('moveBall()',400);
8 j7 l6 ]( z0 g- h, S9 d" w( U" @' U- b M if (hidetimer!='')' V) O1 `+ Q1 G0 \! N! |
setTimeout("hidetext()",hidetimer)" \& U `, P4 L1 }: {
}
- A- G2 G Y/ D8 B& |, D) @8 I: Y* R7 J
function moveBall() {
, H% b7 q4 y8 H3 l2 b U if (superballRunning == true) {
- B' N0 ^3 U# F- W calculatePosition();
3 P9 ~7 a/ _9 M: q, ~ if (document.all) {, w2 `; @+ D, G" b
document.all("supertext").style.left = xPos + document.body.scrollLeft;* f5 N* Q- W. C6 \" p0 h4 o
document.all("supertext").style.top = yPos + document.body.scrollTop;3 L } [$ i9 ~* t9 g4 e
}# n! l9 a3 \6 W/ Z, X% c; e- D# c
else if (document.layers) {4 W! E' X$ Z, n. \- ?+ G% Y$ k
document.layers["supertext"].left = xPos + pageXOffset;
) w+ I2 k0 i7 O+ z" w; k1 j7 R7 d" p document.layers["supertext"].top = yPos + pageYOffset;) Z: E$ V" H$ |- \' S6 j
}7 a/ k6 q5 x: m3 d
animatetext=setTimeout('moveBall()',20);* J) k- V& `3 t7 |4 \- J/ Q* a
}, G/ C. v2 r* R: i0 {
}
$ P6 ?; \. k2 b7 H7 w* H' v- a5 P7 W& P' F
function calculatePosition() {4 M7 h( r5 q- o6 m4 ~
if (xDir == "right") {& y6 F) }9 z, C' G* q8 `
if (xPos > (xMax - contentWidth - BallSpeed)) {+ H1 X f5 ~9 A: D. V
xDir = "left";" B, D+ L. }4 O# H0 B
}
6 H5 }" s1 e z0 ] }
) L5 @) Z* D+ {, p) z else if (xDir == "left") {
$ _+ o( h3 l; ^/ e) q# G+ i8 W# W0 p if (xPos < (0 + BallSpeed)) {
1 |* w1 t4 F8 d5 f xDir = "right";/ A5 u- L" r* I/ O5 {
}
. o# p Y& ~; f: i6 d' B }
; B: v; Q+ x% Y% t* r if (yDir == "down") {
. R0 w: b5 }( S0 z. v if (yPos > (yMax - contentHeight - BallSpeed)) {4 o7 U7 o X* s; L
yDir = "up";; W7 I' q6 B$ N) w
} F* s# D7 U- I& k, {0 r" @
}
& K# m( c2 d1 {: R- z else if (yDir == "up") {
4 P3 ]! ]$ Z1 c0 o. M! m& G if (yPos < (0 + BallSpeed)) {
3 [1 j z" p/ T/ g2 i, m$ U yDir = "down";# s4 h5 ?0 N, }* i
}( F; s& G1 \, i# g0 [) T& ?! o" m
}) r3 Z" s: M" Z4 l) d5 ]6 L: W+ ^
if (xDir == "right") { @5 }8 `1 f4 e* G; o7 q
xPos = xPos + BallSpeed;9 m3 t. N8 R, k
} _% p# c# [7 U+ _! I5 H
else if (xDir == "left") {) _. P' ?: n8 c- Q1 ^
xPos = xPos - BallSpeed;
. D' j9 w, X+ u( z) h; G }2 [0 f t+ x6 Z
else {
a4 l1 o) ?9 Z. i xPos = xPos;
+ U8 ]3 o, e! k) z8 b! R1 J: w }
+ _4 v7 e$ W! ?/ v6 H if (yDir == "down") {
c% k3 S: G! q yPos = yPos + BallSpeed;# h3 l0 `% e, |2 X5 o
}$ w9 v5 R3 B' A. D
else if (yDir == "up") {) o% h+ x* J9 e: ~. ~
yPos = yPos - BallSpeed;
' | X, ?# M+ G }
- F. P6 r9 q' Q8 G5 B; f; \ else {
' @5 ^; W! g& _: W yPos = yPos;/ S, y# [: K% |+ s/ u
}
( ]% K7 U% v- d }
+ @4 z0 b% Y$ y2 b7 n; n: ~1 H' R3 j( V
function hidetext(){3 }& w: ^ f/ H. U3 m
if (document.all); D% k' u0 S4 C4 q) F) [
supertext.style.visibility="hidden"
" o* q6 c1 h& ?* `# [0 {else if (document.layers)
8 w4 L7 d2 H' H1 [) ]document.supertext.visibility="hide". S# Z7 A$ H1 y! a
clearTimeout(animatetext)$ z1 X& Y, y+ y; ^& N
} o+ \& ]9 D8 T
/ v! J; c3 m1 X$ \if (document.all||document.layers){
, R7 h, s# l( }, n: u' |document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ a+ r9 q# a# v4 Twindow.onload = initializeBall;
' U3 L; u8 [, z, B) w8 M2 c. I+ Zwindow.onresize = new Function("window.location.reload()");0 o- e9 T+ |" T* X4 V, q
}
9 t% I# I) ]- j/ H6 B/ |' F9 t) ^5 ^& A
</script> |
|