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

|
网页之不断弹射的文字-特效
<style type="text/css">" {& E! }- D- u, x) [
#supertext {
& {, s8 j% `# I5 k, `& F" s2 kposition:absolute;
5 @5 r- C) P) s, y# X- Rleft:0;- C5 X2 k( V. |/ K' e2 X
top:0; I5 U( @' z7 W
visibility:hide;$ X" v3 Z( P- v% D
visibility:hidden;& B$ H0 m, s5 m& g& Q# |
}
* q' b' ]* x" @$ o* p- z% T2 r</style>
- ^4 i+ @# _% g& A, A6 l<script language="JavaScript1.2">
: y3 W! s; o, E6 K' U<!-- 改变下的字体的大小。颜色--># U v2 y# Z |0 Q. \9 d' I
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>' U1 q! L2 Z5 _- |
var hidetimer='';- h. Z- P6 y [( ?
<!-- 改变下的弹跳速度-->
: W/ M/ ~/ I2 z3 t; Dvar BallSpeed = 20;
- x( S0 k: j- [var contentWidth;, z* _$ w5 U( \# C
var contentHeight;1 X: V+ o# ?( n# H& l3 [2 A& W
var maxBallSpeed = 50;
8 {% f/ W/ B$ y6 ]( k2 v+ ]" {3 s; \+ i/ Y3 x
5 c J. [/ T) z) a, `. V! Q
var xMax;
p0 z" D1 D+ l" v7 U: Avar yMax;3 o8 {0 A5 v( J, G, }
var xPos = 0; a7 Y1 I( m, t# p+ v) e' F J8 G: d
var yPos = 0;5 a; w/ v) S4 a, |& y, z) D
var xDir = 'right';3 e* ]8 n' J0 {* d2 W& ~. Y
var yDir = 'down';, N, l- a- c! e; _4 b& F, s
var superballRunning = true;- D& `6 Y% s& G2 |( K* n, J
var tempBallSpeed;/ m+ z0 a4 h0 L% }, Z2 ^7 b
var currentBallSrc;
& i3 @& ? X# K5 X; u0 Hvar newXDir;9 S' O& w' I) Z- n2 O
var newYDir;
$ |. s- u& h8 c G; P* E
, `6 |6 J: u) Efunction initializeBall() {# n! I+ t6 n+ X' K
if (document.all) {
3 e. K$ T- n3 q6 h$ Y/ l4 y xMax = document.body.clientWidth
1 C$ P# Z. [. v1 I' K yMax = document.body.clientHeight3 _2 ?) A5 J- y) B8 N1 D
document.all("supertext").style.visibility = "visible";
" t; @3 ^) q& u1 s5 J) k contentWidth=supertext.offsetWidth- H) W* r9 w1 B
contentHeight=supertext.offsetHeight5 U% L; Q; j" C0 x9 r
}
' A- I4 x- A# i P else if (document.layers) {$ r+ S [2 ]* I' x, B
xMax = window.innerWidth;) i9 l& q, @( L! x0 ]4 ]
yMax = window.innerHeight;9 V4 ~2 }! |% J8 _9 `5 y: a! g
contentWidth=document.supertext.document.width
$ z1 g j2 M4 p- r1 v; t contentHeight=document.supertext.document.height
5 W8 g+ v, y) v# k( I% d document.layers["supertext"].visibility = "show";
3 L9 p( r' k) C+ L }
( {1 D3 l4 R8 Y2 G setTimeout('moveBall()',400);
" I0 z( \5 d4 |( F4 o) ` if (hidetimer!='')
! W$ O5 c0 c$ _2 I setTimeout("hidetext()",hidetimer): S; t" f/ n& F4 ?/ I
}
' A) | B2 u G. m
5 ]$ I# u( S& n/ K8 Ufunction moveBall() {
Z; l6 @ n) P/ c2 E$ X if (superballRunning == true) {6 L/ v F2 Z8 t6 g0 t% M7 f
calculatePosition();% J6 g# i: P4 E/ G8 ~/ `
if (document.all) {
" g; x8 G+ \# M document.all("supertext").style.left = xPos + document.body.scrollLeft;* L7 x0 \, a! q- s. {) N; f
document.all("supertext").style.top = yPos + document.body.scrollTop;
1 a$ D @4 L# N" P3 X }
5 q, J X9 m: Z9 i! U else if (document.layers) {
1 u. g8 s' m: o" [( o/ K0 z document.layers["supertext"].left = xPos + pageXOffset;0 U0 M# K/ |3 S- c9 c
document.layers["supertext"].top = yPos + pageYOffset;# t' Z8 V! K+ ^' G: W6 o$ C
}: P3 p, K7 g3 ?, S8 ^7 f' q5 N/ F
animatetext=setTimeout('moveBall()',20);% g. J; \5 O. }! b2 h
}3 ~# L* [. [! k* {9 w5 N; @, D. P# k
}
4 G- X4 p. `+ \( I! K0 c& y4 e; `5 U6 G1 E5 E8 w
function calculatePosition() {
' W: |3 b5 D5 K2 E9 U if (xDir == "right") {
8 d$ q- y# O4 ?) u) k if (xPos > (xMax - contentWidth - BallSpeed)) {
) b1 C9 K. R( M, k0 K xDir = "left";- B/ u: p5 ~6 i) C1 p% r+ }, I
}% z6 @# I) Y3 g4 q, b+ P
}) k3 g0 B1 H4 }* c4 Y2 V
else if (xDir == "left") {
% i) H4 \3 o: D0 v if (xPos < (0 + BallSpeed)) {0 h6 E! n& W U6 w H
xDir = "right";
9 [+ ]* `% K, u) w& I. h/ `8 w }
8 U0 l; s: f& n# Y }5 O$ B' ?* v) B; m' T
if (yDir == "down") {$ T+ K n" i5 j
if (yPos > (yMax - contentHeight - BallSpeed)) {2 [- U& Q. j" c$ Y$ L) d0 F
yDir = "up";6 x/ \( ^9 | l9 x9 B( s
}, ] I4 L3 f0 W0 ^
}" X! o0 i* L+ v; D3 F& ?% D
else if (yDir == "up") {. u3 t8 w/ `7 o) b
if (yPos < (0 + BallSpeed)) {
0 P0 L w" ~( I1 {/ a# I0 p yDir = "down";
3 p) \( |. [. h }
|! R& x: Q, P/ C }
/ q7 t$ o: ]; i0 N" O% Z* {. ?4 t Z if (xDir == "right") {
! }3 [' j ?/ `4 [) j, K* P8 @ xPos = xPos + BallSpeed;6 Y& a+ z, s: R7 `7 r
}$ X+ D) ]: r+ h9 Z" D& ^
else if (xDir == "left") { w$ F4 ^& k! a1 W
xPos = xPos - BallSpeed;7 n( m6 x6 c; b; r! y; u. Y2 Y
}: l& ?. z/ o6 s) E+ g
else {$ u9 C0 O. K! k! ^
xPos = xPos;
/ W. R. a6 j% ~9 y# O# }3 a }
, E' e& s" P/ @$ m* v if (yDir == "down") {
( M; r7 K- f5 l7 W$ d! S" s yPos = yPos + BallSpeed;
9 N( u8 L1 Q% J k' o# u1 F }3 h) E% b, B5 W
else if (yDir == "up") {
+ c) E8 S1 r3 J0 t$ v& E yPos = yPos - BallSpeed;8 c1 `5 a8 o A/ u
}" G! [ ^9 s. H1 y
else {
: j* s, O3 b7 G/ ` yPos = yPos;. D; @: r1 Y/ S- b+ }! o* m/ T1 ]
}7 j) I6 q1 k& ~& `7 X {8 i2 S
}
1 Z6 T* z1 X$ H% d5 G' b8 c3 l* t# [6 C: N4 K
function hidetext(){5 g" m1 Y3 Q. p# E, V0 c) R
if (document.all)
, L- J# T0 v' D& [$ V4 Ksupertext.style.visibility="hidden"0 @/ w( i2 [. L. F
else if (document.layers)- N6 f! I/ D6 W4 e
document.supertext.visibility="hide"( x& a7 O; E! e& P9 @- a' G9 P6 D
clearTimeout(animatetext)0 Z6 A3 _9 T; t3 a- a' Z5 H
}! @0 S5 p0 ]( X p0 k* J2 X
! A0 [% v9 B5 ]- v( b3 t2 aif (document.all||document.layers){# e! {5 @5 E" q' \# z
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 F+ s3 k0 `( B) i% ?window.onload = initializeBall;
3 ?! Q$ z1 q4 |% J, b- uwindow.onresize = new Function("window.location.reload()");& W& G0 P. _. ^ \
}& O- o; L" Q% H- `
2 i' x% X0 @2 a# V$ d
</script> |
|