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

|
网页之不断弹射的文字-特效
<style type="text/css">
+ e2 t; P$ c9 K! @ t0 M4 h5 a#supertext {
) t( o' Y- A- k4 `" l7 U8 n* i! Wposition:absolute;
! ^5 e* f* b. v0 F# Cleft:0;
4 m) U7 k$ C' jtop:0;# K( h; p; X6 m. f! T
visibility:hide;
$ M1 Z. S4 ]/ a3 }9 Y% R+ I; ~3 Gvisibility:hidden;
: o: ~! \( J! _. j}
$ L4 b) Y, B7 p</style>
' J E# S" ]9 c+ V5 t8 m5 X; E+ j. _<script language="JavaScript1.2">
3 t# [* t& F- r. r' m6 m i: R<!-- 改变下的字体的大小。颜色-->3 f! M0 }, S& T# ^- R k- o
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 V# w W8 _, zvar hidetimer='';
6 F- ^4 a c: y<!-- 改变下的弹跳速度-->
. p6 s! ~) b( L2 \( Y; zvar BallSpeed = 20;. V7 @* s1 y- ~. Q/ j) H1 B
var contentWidth;
7 J9 |" y4 n' I5 Kvar contentHeight;
. m' o/ @/ g. \var maxBallSpeed = 50;
+ e4 z$ ` v# h+ @1 Y9 E4 g0 |7 s* z* ^! m* i
6 O! {1 s; B& ]6 e
var xMax;' D, R1 s) s3 Y! `8 M: I N: }7 Q
var yMax;
8 t8 O- z) h, nvar xPos = 0;$ {7 ^' x% o1 m, `: h) b3 W; u
var yPos = 0;
# n5 V8 l) d! }/ evar xDir = 'right';
2 T+ E, e1 W$ a; W% D7 Wvar yDir = 'down';
4 D3 G5 D1 {5 Svar superballRunning = true;9 H! r: {" l; `1 i K/ w6 u
var tempBallSpeed;- v5 c! _$ r9 h
var currentBallSrc;
& B; g: P7 j3 b5 Uvar newXDir;
, g6 Y2 m& J0 l. W2 m" K+ m' ~var newYDir;! Q, C0 C2 Z( g& Q& }
9 h4 Q' H. y* t; f
function initializeBall() {
$ G9 u& D, v+ r+ G if (document.all) { }$ q! w5 k Y: U& d3 L+ h% o6 r
xMax = document.body.clientWidth
6 w6 L h+ `& B6 g, e# Y5 U8 E; o yMax = document.body.clientHeight, |. {: j& H$ u- c( Y+ n
document.all("supertext").style.visibility = "visible"; k5 e( }& i) r1 j
contentWidth=supertext.offsetWidth' m9 W8 z; n" h) N) s+ ~
contentHeight=supertext.offsetHeight
8 Q7 @/ J5 {) s3 I) e( ]! C }
M V' {+ W% P else if (document.layers) {
# {1 @" @, }$ R5 r xMax = window.innerWidth;
% e$ a6 Z G$ @8 u7 e yMax = window.innerHeight;) A1 ~! i7 F$ _( z5 X9 T7 U
contentWidth=document.supertext.document.width% c( _8 a' j! C8 n" ?# g
contentHeight=document.supertext.document.height- W% l& \. |, c7 q) l. j
document.layers["supertext"].visibility = "show";6 e ?5 B4 R6 v A3 ~
}
0 c9 e" q# u1 @ W& a; a0 | setTimeout('moveBall()',400);
" S3 a- Z7 p: g( y) A9 Y if (hidetimer!='')9 s5 ^/ e9 M$ [
setTimeout("hidetext()",hidetimer)
# u$ J3 U- {( c4 o/ v5 O7 c }
' Y0 }( b1 [) q# k
7 ]7 t5 K: t; I5 v. Z0 Ufunction moveBall() {
# ]1 Y+ m& f! h) M1 A if (superballRunning == true) {
' f% \! r0 h+ \7 z% d+ x9 N: H calculatePosition();
( M" a. r' ]9 ]3 H% E if (document.all) {- ?5 i8 r0 n5 F0 V9 Y0 n# N
document.all("supertext").style.left = xPos + document.body.scrollLeft;1 {" C# \* x& \
document.all("supertext").style.top = yPos + document.body.scrollTop;- w/ c$ c$ r6 F' a( _2 t! f
}$ _0 m8 v, Y9 J" V$ C$ j
else if (document.layers) {
D- f$ J" ?, j7 H2 B document.layers["supertext"].left = xPos + pageXOffset;
d3 C8 ^+ J- v* s. I document.layers["supertext"].top = yPos + pageYOffset;
$ b% n- _) N; C0 ~. ?7 } }% q* I5 l; ?3 l5 Z5 C ^
animatetext=setTimeout('moveBall()',20);4 R+ g+ V; S* {6 T5 N/ S/ f
}" ^ X2 U, ^, k! r, W- s" o
}
/ E: B$ N: w9 y, J
; r9 _7 V9 @& u T- e- [% d! v' cfunction calculatePosition() {
; ]+ P( J! N- ?4 |8 Q4 |' E if (xDir == "right") {( z/ i; v* U* A
if (xPos > (xMax - contentWidth - BallSpeed)) {! O1 W1 [& {% N' {) \: e( M
xDir = "left";" n* J4 Q' Q, r& @3 i9 O1 v2 T
}
g& h" A( s7 E0 M: _; X# h }
g% h |. | A* ~ else if (xDir == "left") {
/ m- l) G g+ }% L) D if (xPos < (0 + BallSpeed)) {" Q5 h# w2 g$ P$ K, d! l3 L. ~$ x
xDir = "right";
. w& N9 o6 W& g: h$ K6 _6 p }
" K3 G G2 C. j' I }
$ T( \$ n8 K, ?; p9 A' s if (yDir == "down") {' h' i9 _6 A Q. x- |0 h
if (yPos > (yMax - contentHeight - BallSpeed)) {
+ P0 d( u; j6 y# j- B yDir = "up";8 l5 [0 A; [4 f; L* y
}
: A, ?& w# j2 G4 ?# ^9 M" W }
7 t8 s. A4 D9 T | k$ ] else if (yDir == "up") {
" E( \# ], v0 `: T if (yPos < (0 + BallSpeed)) {: `2 [ n) V% R
yDir = "down";
8 K+ W5 n( Y, b) J4 z B$ G }7 p& G4 \6 {, m( F3 P
}
& G" O$ y2 ` ?; {/ Z1 [ P if (xDir == "right") {
! t5 J( C! R2 r xPos = xPos + BallSpeed;
- X( A% p" Z3 v1 J3 ~+ ^ }: G. O3 F9 Z* a4 O! O8 d% X( y3 g
else if (xDir == "left") {
. q2 _1 M' Y- H# G xPos = xPos - BallSpeed;) U* m$ c5 A) [& r0 \
}% L! q- x) w- k. k# G
else {0 G7 C- p) N( {5 E( A
xPos = xPos;* E L0 P3 c( c$ M. Y5 `
}
5 P+ S* V; D+ e if (yDir == "down") {1 h* F; `/ R8 U( N; u2 \
yPos = yPos + BallSpeed;
; {5 a5 e- T5 X' v' a. M }5 {' U2 l# i/ @: j+ r
else if (yDir == "up") {9 G j/ N1 z$ X4 Q* I+ u; M3 E, N
yPos = yPos - BallSpeed;. u+ v5 }: W. {: P/ c& z/ m
}
8 Q: V' Y6 H3 ^- {" x5 [: v else {
5 Y- h6 v: {8 F1 b- B1 | yPos = yPos;
& T0 T9 L% m/ W2 N }
% K% ^ f" e8 P- f7 } }8 u! q2 u1 b2 Y/ H
4 |6 j3 [, o$ X- R W% u$ e1 dfunction hidetext(){
L: P& F0 W$ Z1 x4 S# Hif (document.all)& w2 ^5 V d+ k. H2 q B( h
supertext.style.visibility="hidden"
6 I$ c4 F) P4 D/ K% ]else if (document.layers)) K6 D# B" c- H0 I! |# q
document.supertext.visibility="hide"& X. c2 b% T- |# W$ W0 p3 ?7 U
clearTimeout(animatetext)
3 k- f! {+ n8 s l7 e}
K! ~+ b& c7 T8 n( M$ `" r5 ^- R$ s
if (document.all||document.layers){. r' G5 ]2 c/ t: A- t( P" J! t6 z
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
2 Q& K: i) G1 v2 Q0 Q# z! O$ Z5 _window.onload = initializeBall;2 ]% b0 g9 L' O/ E$ ~/ f
window.onresize = new Function("window.location.reload()");
- P) f ^: _7 D}5 C8 O8 _0 @) x3 d; }5 E3 p
8 P5 k' ?; u' {& G3 A4 y0 h
</script> |
|