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

|
网页之不断弹射的文字-特效
<style type="text/css">
$ v: r' u+ Z! Q( M; P3 p1 j. O( y#supertext {* c' o. _" |' _, `* Y$ k, ~- f
position:absolute;9 E' u: O: h% G2 T3 u; q2 n
left:0;
4 m9 J. q& _4 W+ ptop:0;% w5 `2 g4 j; m z6 u
visibility:hide;, u- X3 W: i( L3 I. G, b, S
visibility:hidden;) F' v+ f/ d( Q& D, Q& c
}
1 \0 L- I8 ~- X0 }7 \</style>
9 k+ Y# k+ e2 c<script language="JavaScript1.2">
" @2 B- ^. P# y* o N<!-- 改变下的字体的大小。颜色-->7 n" \1 n7 U- s! Y
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% g- l: Y7 q2 L
var hidetimer='';2 D1 t7 c' @* M- U6 s4 b
<!-- 改变下的弹跳速度-->
4 `. F0 C1 e; v) ?' Yvar BallSpeed = 20;" ~) C: d* n# P: l' D
var contentWidth;
* y5 f; Y# \+ l$ C5 d7 @var contentHeight;
7 q: H' z2 ^6 I. [3 \9 t* Cvar maxBallSpeed = 50;# @, x3 Z) |0 I) r& v" u
1 g' V8 _+ L8 w$ m
- p; L; C# m `1 ?
var xMax;% `' M" \( T, @4 G# e) f
var yMax;% A5 y& P: V: r2 X" {7 F/ ^
var xPos = 0;
% I% I( J2 x9 v. z t+ Wvar yPos = 0;
: s. S& z0 E% w2 t& Ivar xDir = 'right';
$ T2 r! d0 _9 J4 _& ~var yDir = 'down';" ~0 r. w& O& f. {
var superballRunning = true;
; v3 L( V% T2 m1 \4 T4 ivar tempBallSpeed;8 S9 e& V6 B* X4 W& t
var currentBallSrc;
+ `+ W& a8 x( Z- yvar newXDir;! ~0 m* K M7 h q# x/ |
var newYDir;
% m1 w, N# |5 s0 ~/ G0 a; y" h3 U, I5 h9 A6 E
function initializeBall() {' P/ n' m" \' ?5 T& r
if (document.all) {0 ~% H9 S4 { L
xMax = document.body.clientWidth
: w0 n0 r4 F* \3 n& f/ m# S, C yMax = document.body.clientHeight) f# Q$ u3 R+ q6 C
document.all("supertext").style.visibility = "visible";& j, k' H) Z. j) J+ \3 Z
contentWidth=supertext.offsetWidth
8 l1 q \& Y- t' @) R7 [1 ~# [ contentHeight=supertext.offsetHeight
( V* {3 N9 B* i, \8 M4 P+ ] }% @+ k+ u2 K' j8 v* z
else if (document.layers) {
1 J: N1 W/ j, b7 O( k xMax = window.innerWidth;
- J" S1 J5 y3 B! \- z: L2 N! t yMax = window.innerHeight;
+ L2 V5 }: w) }# q contentWidth=document.supertext.document.width
; K6 e; L/ C! U1 W contentHeight=document.supertext.document.height1 W2 L( f' T& S- x2 c6 G. W
document.layers["supertext"].visibility = "show";
; _. ?- G! [, J0 k }# H3 v) B( x7 F) ]3 L* N8 j
setTimeout('moveBall()',400);# u8 a# B+ ~2 M/ h& G+ V- S9 b
if (hidetimer!='')9 l$ J7 j. i K, N
setTimeout("hidetext()",hidetimer), S( G" T, q, X6 p+ f1 {
}2 w2 V* [1 @; M4 H
: ^ U3 i2 i3 I, `3 zfunction moveBall() {" A+ h' {6 z7 }' t. u2 |
if (superballRunning == true) {
9 g1 @& Y/ N+ W) a0 |2 z calculatePosition();
7 N0 p% W+ ]$ v, D g if (document.all) {4 d5 y6 S" n# \4 m/ y3 @
document.all("supertext").style.left = xPos + document.body.scrollLeft;" Z( C; _& E; h+ b8 u$ R# N
document.all("supertext").style.top = yPos + document.body.scrollTop;
. }! \+ O* ^9 R. ~5 H }
$ G9 q5 Y8 [( w, P j else if (document.layers) {. j3 D6 Z9 @! z1 L; j: T6 Y
document.layers["supertext"].left = xPos + pageXOffset;# s* G2 G+ {" |- V: N) e
document.layers["supertext"].top = yPos + pageYOffset;6 V7 \; U; o5 F2 H4 n/ l, @
}
7 [( d/ |9 u- b. z8 O0 i/ ` animatetext=setTimeout('moveBall()',20);
; K1 l+ W2 w+ P4 M" I }
- `+ m/ v- l& ~: r1 A }' |, P. g0 G# K" w
) K/ I; f, N- k$ B8 O; K
function calculatePosition() {
/ f. k7 z; j4 g: Z3 o8 I if (xDir == "right") {' X3 `9 c2 \8 s
if (xPos > (xMax - contentWidth - BallSpeed)) {% [5 M+ W' n: o# S0 O0 q9 _% y
xDir = "left";1 ^, b3 G, h9 ^* f' }
}
5 c6 k5 d& n/ r: E }; I ]8 `" P) v- h# F$ X
else if (xDir == "left") { _" ]7 k6 `, x; i
if (xPos < (0 + BallSpeed)) {
! b2 J( h0 q$ G; m- t$ V6 W xDir = "right";
# V4 V7 u8 K, T7 \ }
l$ A. h' b }5 o }
' n# G7 R( y7 B f+ Q if (yDir == "down") {- f2 B7 y2 t* I2 }& s1 K
if (yPos > (yMax - contentHeight - BallSpeed)) {" E" F8 v" g/ z6 ]3 X% s4 I( N) h
yDir = "up";
# s1 j8 d6 Y. h* T }0 G7 x( [* r% p
}
e, H: S$ O9 c9 L0 I; f! O- f) b else if (yDir == "up") {
. q% j% h1 P; Q4 y( p5 A if (yPos < (0 + BallSpeed)) {. y( _4 s% w4 m- D% Q: ~
yDir = "down"; l& U7 ?, e: N+ k! Y
}. I' ~% Z' Q- W5 Y/ w& z8 j: H
}! S+ U- X1 D" R; Y, Q2 j
if (xDir == "right") {
. a' s1 l- {# V xPos = xPos + BallSpeed;+ i; _0 C( W0 V& K, ?
}" N3 d% {" T- y1 a4 B4 u, h3 S
else if (xDir == "left") {$ j: J3 w) H* X9 Y$ p, ~8 `
xPos = xPos - BallSpeed;: F% [; Z' O6 }4 d$ J3 V
}
: s5 U% w8 H- w2 z2 p else {4 Y0 O0 R2 F% U5 R! j( A
xPos = xPos;
. S; c! U6 ]+ p8 k' E% F2 k/ S) _/ {1 Y }
4 B1 e& U4 k5 y2 W& B! v if (yDir == "down") {
. {* Q$ w- k$ V: Z! K3 y. o yPos = yPos + BallSpeed;0 Z4 I% `) H' e3 u5 q8 l8 J* f8 |
}5 X3 L: g# K [8 L
else if (yDir == "up") {7 p1 u ^; T3 p! H4 X! m
yPos = yPos - BallSpeed;3 b9 K6 A. y& h, H' y; w
}8 j5 x5 V" Z; G* ~7 t
else {
* n) J+ I, y4 D8 ?3 o yPos = yPos;. S* N. \' {' y" l- g# }7 w5 d
}- v! X$ C3 p" q2 u
}
6 |5 o% Q4 |5 l9 m( F3 J
% L& W. A2 }* i+ O+ V% J0 Y4 dfunction hidetext(){
% g+ q5 L4 q3 V& L2 dif (document.all): W, n# ?$ G' Q' r
supertext.style.visibility="hidden"' ]+ { r+ L# {* E9 G& k
else if (document.layers). i% W3 U1 J* `
document.supertext.visibility="hide"2 O% C/ e" c/ u/ S, m7 o/ d
clearTimeout(animatetext)7 l, U" u; d+ B K
}
2 `- ^5 N0 K( Q/ @5 Q) `8 _
' ?9 E' y+ M R& tif (document.all||document.layers){
3 B9 _& a3 U6 t2 ^3 O f- Z! x; gdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')7 l+ s1 K* w% {9 D: D& V. N
window.onload = initializeBall;8 }- r F, A3 T# X* N1 P) a
window.onresize = new Function("window.location.reload()");& f) B: }6 P# x+ p
}
+ k# C# ~5 y7 \. A8 o% @" Z" h, N3 g a" \! @6 z. o
</script> |
|