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

|
网页之不断弹射的文字-特效
<style type="text/css">& u2 Z$ L) b( ~, Q1 O
#supertext {& I% V+ e0 w7 U1 u" o: x% c
position:absolute;
8 A& M4 U* E1 A) q. t4 Dleft:0;
1 ~ m5 i# g, k5 ptop:0;0 U3 N( h3 @, z3 j$ r. Q
visibility:hide;
8 M- {1 x; j% R1 ^8 ~4 s1 J3 Gvisibility:hidden;/ V q. w4 R3 ~! S
}6 T( f) p: `9 I2 N
</style>
4 r2 Z* H7 t7 ]) T<script language="JavaScript1.2">
6 P. G+ ]* P2 y: V' o<!-- 改变下的字体的大小。颜色-->" y* F" s5 U2 k4 S/ u
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 G" ]$ a8 b5 g2 Q6 J# qvar hidetimer='';
! m3 K1 Q% Y5 Q<!-- 改变下的弹跳速度-->' q; `3 I! [4 i2 k4 [0 M
var BallSpeed = 20;1 s3 [4 X0 D6 w2 E, F3 I
var contentWidth;( @* J$ H( D6 g$ _' Y
var contentHeight;8 R- w+ A& ^0 }
var maxBallSpeed = 50;
0 T* S8 V4 G6 Z; d0 Y/ n: [" c U5 b
& `/ _7 V5 j! q' X, T+ h! V2 z0 `8 f) y
var xMax;4 l7 O! n+ o( P- v R4 \
var yMax;9 u0 B! i- q0 e6 i( ]$ T
var xPos = 0;0 ]) q$ Q1 G4 y! S9 X( S2 a2 s' W- p
var yPos = 0;: N4 C% O% C" x% Z0 b |
var xDir = 'right';
* I! @. W% y1 G) Ovar yDir = 'down';
+ @$ U# j2 y' S- S6 Wvar superballRunning = true;
- n- [* Z1 @6 _# J# {var tempBallSpeed;1 V- M& M d1 A, t
var currentBallSrc;4 M! V' B6 Z3 k$ A+ \
var newXDir;' h2 i) T4 M) o V% R" Q
var newYDir;- N8 p" a9 q6 V" ?$ |/ H
* M4 F& O3 }5 x# G) w2 D2 Gfunction initializeBall() {
, b2 ~* p* i( O! G if (document.all) {+ w7 T6 {7 W; K1 [) _/ z9 ?' R
xMax = document.body.clientWidth/ s* [; I" F; C' a
yMax = document.body.clientHeight8 Z6 B t; `. W" Q7 L
document.all("supertext").style.visibility = "visible";2 u7 ?$ t4 {2 B: D) `% r* \! l+ ]
contentWidth=supertext.offsetWidth
2 e5 ^* S5 c! m9 L* c contentHeight=supertext.offsetHeight
; C& [, h9 B H" q, l2 V$ O/ q }. H1 Z* n# m1 z! h
else if (document.layers) {$ P! b" Z6 \! c+ J+ C
xMax = window.innerWidth;
. T: i, Q4 v* j/ }' P2 c yMax = window.innerHeight;
u" G P! F+ E/ L- x5 |: U( B contentWidth=document.supertext.document.width
2 W$ Q! v( m1 b% W* {; f contentHeight=document.supertext.document.height$ G% o8 N* ]. x/ p- }$ R
document.layers["supertext"].visibility = "show";/ v3 K. J- Y9 i7 x9 q
}4 p9 ]2 `7 V, {' I. ?! {- J
setTimeout('moveBall()',400);( c! c7 B! |; s/ l1 f. u& |
if (hidetimer!='')
, @( T/ H' R( U/ c setTimeout("hidetext()",hidetimer)( Z& b3 D% h3 Y
}3 a" \; O3 r7 ^4 |, j K* R1 B
3 H% I4 z- i9 ?' u0 hfunction moveBall() {
) J( K; O* v( @& b if (superballRunning == true) {
. P/ `& K" ?4 Z+ M- G calculatePosition();& l, E- n$ D; a# p2 n
if (document.all) {4 N* H' u* d* `& J/ A
document.all("supertext").style.left = xPos + document.body.scrollLeft;% D( C1 |4 Q( \8 B" M' L
document.all("supertext").style.top = yPos + document.body.scrollTop;
; X( }7 t* n$ @7 A3 X" @ }8 K7 k' }: X {: z
else if (document.layers) {
/ K* y6 X) l% @$ K2 V document.layers["supertext"].left = xPos + pageXOffset;7 E8 Z: }( G; }
document.layers["supertext"].top = yPos + pageYOffset;
! A' b1 W) P- f6 z5 } }
4 A& }8 t: I6 |9 O" X* P animatetext=setTimeout('moveBall()',20);
3 x! c& v( U) A7 T }
/ w- V$ W# ]; N# r }
4 D$ Z1 ^# L! a8 p" j' f
7 |2 N3 E; p$ \; Lfunction calculatePosition() {, ]; @8 g2 m, V6 c9 e D" p# r
if (xDir == "right") {
+ I, }2 j# z% l' L! b4 t if (xPos > (xMax - contentWidth - BallSpeed)) {
- B& Y- v& s0 \1 {1 L& B9 ^ xDir = "left";* e I# i' l$ v% Y
}
; ]" f5 s" g P$ K6 i. y' F }" k* R1 h& b9 A5 a2 Q" E. I
else if (xDir == "left") {
" L: o% q7 H7 \ if (xPos < (0 + BallSpeed)) {
0 q* z3 T% G J, }8 J xDir = "right";
1 E9 c' U/ L U1 Q# Q' @ }
5 n3 P( q- B0 s& \4 U: s) {: U9 d7 E }
$ }8 R. D# a6 t2 O2 I& T) X if (yDir == "down") {
2 m2 |3 Y$ K8 ]% H( V if (yPos > (yMax - contentHeight - BallSpeed)) {% [' D1 `5 Q1 X7 B" ]6 t7 [% z
yDir = "up";" R; [$ ~- S5 W9 F, a s& F9 ?8 a
}# W! P5 m1 o- p1 ~9 W
}
7 [6 q/ j0 }3 Q. d: c% _. ? else if (yDir == "up") {# x/ }# O* E* h+ M6 O
if (yPos < (0 + BallSpeed)) {
3 r s! [/ c$ w) | yDir = "down";
8 g' d$ r& c6 U6 m! d# F, M }, a& M6 K( l9 G7 \+ w" G" v$ J
}" H! t" t' `: m. U
if (xDir == "right") {' [' U8 E; F1 ~( U7 k' G
xPos = xPos + BallSpeed;. K6 j* t% R+ q- [
}
6 {& ~, t% b: a8 [- ^ else if (xDir == "left") {
, K' s4 T3 d( s xPos = xPos - BallSpeed;
3 Q+ p1 I0 J7 c0 \8 n }; U5 }& F/ k3 i9 Y( w5 X' Q6 f
else {
; q. Q5 {* f+ K( t: ?5 J/ q xPos = xPos;" c" {7 J, _' {* t/ Q
}
* ]/ K" _- D4 j$ u; d. ?! b+ S. Y& F if (yDir == "down") {
) u9 c4 H* [, [* t( m0 {) O' d yPos = yPos + BallSpeed; ?* A8 J9 G0 _/ x3 n0 @
}
$ g9 d) p- f/ U5 G7 A5 r/ a1 _ else if (yDir == "up") {0 V' c& Y; I) b/ F
yPos = yPos - BallSpeed;3 X; Y5 h6 p. A: v8 V2 I5 a
}
2 d4 V- G2 c0 B3 g8 @% Q' V else {
) {: N+ ?& L* [. @ yPos = yPos; r- m3 _8 E. J% u; G. o8 D- \
}; P. w5 t" _4 G
}# C9 e: M. l% q) Z
! ]% H+ I- }# S i' J1 n
function hidetext(){' L- x/ M7 X: D0 x8 y0 M' y
if (document.all)# `1 x7 [- {5 O' l4 S* ^. u" C8 n
supertext.style.visibility="hidden"/ ~( f* S3 u, e q3 E% l7 s
else if (document.layers)3 _' X2 l+ b- v. A3 j- p! M3 g
document.supertext.visibility="hide"& I# G7 q* K. j* y
clearTimeout(animatetext)
- n. \. d' }+ m( y. g" C}# k& a+ h" Q& O. A
4 \; d: Z; @4 y: w# dif (document.all||document.layers){* n, ?5 O6 `& |6 d( K* e7 U
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# S# G4 k; O, S2 C" ?2 i( wwindow.onload = initializeBall; n* M5 ]! L7 `' M/ A7 u
window.onresize = new Function("window.location.reload()");
5 ^* m+ p+ R# S: b}
8 W* \) o1 B O/ u
* r8 p+ B% e) }% u4 j0 r* _5 |</script> |
|