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

|
网页之不断弹射的文字-特效
<style type="text/css"># @* l0 ^! m: l: u* C! T" N) R2 v
#supertext {2 a+ }# a: S' Q1 e
position:absolute;
7 F9 s" c. N2 U* q H4 oleft:0;
; O8 a& A& m, m3 gtop:0;
9 D" @' ~5 k( L2 V, o dvisibility:hide;
. c( N- R- u1 F# A7 g" P' [visibility:hidden;: N- U, Q4 O; ]; f& d, A6 p
}
* |! K& Q0 U) _# D0 {</style>3 q8 v0 p) p0 R9 @ l6 m5 Z
<script language="JavaScript1.2">
7 k9 f: `7 P; Q5 Q<!-- 改变下的字体的大小。颜色-->2 W, ^. ]+ z! b' y1 }) H2 R; S
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 |5 L! M2 U+ xvar hidetimer='';: C# J9 }) C, a' [7 E3 `
<!-- 改变下的弹跳速度-->3 |, Z4 M5 f7 o
var BallSpeed = 20;
, X5 Y! H8 `( ?; ?2 H7 Kvar contentWidth;+ c9 g) y7 P8 u8 v# k
var contentHeight;
, n! R5 I. m! k/ H% o( t* Gvar maxBallSpeed = 50;5 ?8 S0 n {# Y" I# U( y2 Y3 e& E
6 ^$ E5 h p' l
6 K8 {7 ~9 j* ]var xMax;
/ P: V" ~& X% t4 I3 @* qvar yMax;
5 m6 @# h, [5 v: g" tvar xPos = 0;+ |# U+ R2 [9 ^# O0 k) H. U' I
var yPos = 0;
1 I( G- p3 f) c$ a/ W' C& |8 [var xDir = 'right';& V5 O% X; e. u! D
var yDir = 'down';
! O& t e5 X5 F3 X. U$ m- Fvar superballRunning = true;
: J5 @2 [, |8 @2 V' pvar tempBallSpeed;
4 e% O& K0 y# J9 t- F2 u, ~1 svar currentBallSrc;/ W6 ?7 O9 U2 F5 a* k0 j% Y
var newXDir;
: X8 O5 ]& A. e3 q- P8 W* }( Ovar newYDir;' y( r e, h1 a8 @- v
2 @% @. a' A, I% ?+ P8 Tfunction initializeBall() {
3 f/ v( T/ Z$ q2 e; E if (document.all) {
A6 G/ H4 _9 D9 M$ Y" @ xMax = document.body.clientWidth' G$ x/ [; ]' I. O: g$ T$ N& ?
yMax = document.body.clientHeight9 j+ _# Y' Q- L. Z! Q
document.all("supertext").style.visibility = "visible";& Z; k' A8 |+ s
contentWidth=supertext.offsetWidth [6 A2 M( |, i' {
contentHeight=supertext.offsetHeight& f3 {+ V; i5 @
}$ Q* w0 ~" }; Q% Z( u
else if (document.layers) {$ F( I$ Y# O5 Z Q' g" q) D
xMax = window.innerWidth;/ }0 `# H; g0 Y5 F
yMax = window.innerHeight;
1 K" I) a1 e. o contentWidth=document.supertext.document.width9 e; T4 y6 j5 X: p
contentHeight=document.supertext.document.height9 z# r4 n: P3 X# P" r7 B; b
document.layers["supertext"].visibility = "show";; T8 N+ n7 j7 V% [
}9 j& f1 f- u7 e6 }5 X* u
setTimeout('moveBall()',400);$ s& `' d, d0 v6 I% s+ J' I1 h7 Z
if (hidetimer!='')
% e$ t- _/ |7 E- C* C setTimeout("hidetext()",hidetimer)+ t: L1 |; ?' {2 ^, J
}
/ e, x7 E& j9 V; q" u8 e
" f+ k! |; L1 d' efunction moveBall() {/ l& W, ^: t& ^7 P; s
if (superballRunning == true) {
% \" I7 B' F1 L% `, I calculatePosition();7 o% t, @. F, M1 O7 A8 z
if (document.all) {5 y h. F) V$ x
document.all("supertext").style.left = xPos + document.body.scrollLeft;
) ~1 {' J% D, D! Q6 x2 A$ Q document.all("supertext").style.top = yPos + document.body.scrollTop;) a% E' E# q, w8 c( d* b
}
3 ?" g+ e6 H! n% o else if (document.layers) {
7 L! w! G- n, Y+ t5 _8 ]( d/ [+ V document.layers["supertext"].left = xPos + pageXOffset;
6 J( a3 T& r0 u8 ?! h document.layers["supertext"].top = yPos + pageYOffset;3 V- R% S" `2 _0 e* V' a1 g
}
2 U8 x& d* \' R& E2 D' P animatetext=setTimeout('moveBall()',20);; c* n- Y. F$ X$ j5 Y2 M
}
6 [- o, L0 E; X3 l5 ^9 l3 \( Z }, v' S- ~/ t3 W; W) R" Q
; y1 }' \8 r% l' p3 l
function calculatePosition() {1 A+ X0 s% S. ^7 d* Q( }
if (xDir == "right") {% f! ]: ]* j, t' p
if (xPos > (xMax - contentWidth - BallSpeed)) {
) L P9 G+ W/ m4 h. L+ e# Q- N xDir = "left";: D$ R1 l; X4 j
}
* m5 E1 q8 Z# y7 N4 u0 a" X; S }( p; @: C" _0 y5 E( t* c
else if (xDir == "left") {5 ?1 T* a2 x3 ~, g& ^6 N9 [
if (xPos < (0 + BallSpeed)) {5 ]% Y# G9 L4 T
xDir = "right";
4 T) F6 Q7 d6 o7 t }
: o; g# X; I, ] }
: H& R+ T r1 F( d5 E G9 S if (yDir == "down") {
3 p) r; P5 h5 q if (yPos > (yMax - contentHeight - BallSpeed)) {/ P4 \0 m$ {$ O3 Z
yDir = "up";
* A7 ?: I5 v) L. l5 p$ F' @ }
3 v A- _ y- U1 P- f3 A* f( t }
/ n3 s2 J8 `1 K- A0 w G( o else if (yDir == "up") {% E% R: T8 ~" i9 R
if (yPos < (0 + BallSpeed)) {( b2 z5 _' w7 x: z9 e' e" d$ P7 q
yDir = "down";
2 w9 P, `8 ^; |- B }
5 _( K$ c9 y+ c2 X } C2 T. t0 S/ H1 ^, U- |; J& c
if (xDir == "right") {8 N5 d6 `1 u- G
xPos = xPos + BallSpeed;% F; h$ ~0 @; _4 N
}) j7 B- @7 T: I- t7 G2 ~- b* \4 @
else if (xDir == "left") {
9 V( Q5 f( S% r( U% s6 U: @2 P xPos = xPos - BallSpeed;
; o" v$ o+ U1 [: Y& j }
6 ] q" ^! c4 O$ ?) m, H else {
# Y5 t# L5 f& U7 c( J" n xPos = xPos;" C' `3 Q) J. s
}
, Q- s& F5 Z( U8 i if (yDir == "down") {2 Q1 G: G; t% s/ q' A. a
yPos = yPos + BallSpeed;" j7 E1 m! ~+ K' y$ D. \. V$ Z
}
2 x! a; K+ Z- D, V* h/ y else if (yDir == "up") {& b# v2 k' c$ A& ^3 d" A0 o7 L
yPos = yPos - BallSpeed;
$ ~: Q, J9 K" r. a }! V" u# Q8 D% k& f) n \
else {
: z- U, H' y6 q2 s1 w8 p; T yPos = yPos;2 |7 y3 q5 ~) R' X7 J1 f* K2 @
}( L* J# C0 M% g
}
. V2 Z S( w7 o" e- |4 u6 k4 A0 a
* e. L! \3 V. xfunction hidetext(){
6 g0 e( m. p2 M' V% _if (document.all)+ `( ]& ]! h ^7 _2 K$ A
supertext.style.visibility="hidden"4 a1 k8 n3 H! \/ L
else if (document.layers)
/ Q3 N+ h* F/ Q& v b; x: N' @8 cdocument.supertext.visibility="hide". h2 e$ C+ t( V! k# d8 X
clearTimeout(animatetext)
) ?+ q6 N- u# W3 m* y}
! F, i9 q0 g, ~# C0 V! ~- e! l4 Z" v2 @2 r$ L
if (document.all||document.layers){2 d4 I' l7 f* |0 T: p7 g
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 v4 G' Z Q7 c2 R m2 i$ \
window.onload = initializeBall;
& z$ C' L% ~( k; K0 s: a' X/ Xwindow.onresize = new Function("window.location.reload()");
; r/ k0 I) A8 m3 O}
6 G: P2 }2 x8 F- q/ N' u) ?0 w1 `
</script> |
|