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

|
网页之不断弹射的文字-特效
<style type="text/css">
' q! E# v; A# V3 ?9 t4 v. e#supertext {8 J' U9 Q* g5 Q$ o6 y% {
position:absolute;
( q/ g) |( Z% G+ x, Y2 n4 C/ h0 l, ileft:0;
9 s8 o4 j/ z4 _! l. G# K0 Ctop:0;
6 }3 ?; V% f3 hvisibility:hide;
6 G$ D2 k+ Y+ a$ S- Gvisibility:hidden;2 O- [! B5 d2 K5 J
}) n' i( i* e7 b. V5 V. q4 |3 ^" N& F
</style>
3 Z% g! H d1 N- M/ y<script language="JavaScript1.2">
7 C. Q/ d9 @7 q6 r1 M; h9 l9 R9 L<!-- 改变下的字体的大小。颜色-->
: v- l( R" }( A' F ?var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 y$ B4 T E$ q+ u! y: f
var hidetimer='';
4 T) R6 q% s5 T2 q/ W9 ^0 o<!-- 改变下的弹跳速度-->
# ?1 o/ Q' r+ ?8 D' p: e' {var BallSpeed = 20;
2 y. i: |3 G/ j7 l( c/ Ivar contentWidth;
7 N4 C2 y4 _% n. y6 ]1 _6 Z: mvar contentHeight;
, g4 H# P, I0 S# k% ]var maxBallSpeed = 50;
, }; y9 R5 Y" y5 {6 D
: h; `/ K/ ?% u/ ]( ^ v2 C* A" z6 q# w' t6 K4 j& I* Q9 A
var xMax;
2 ^: ?: p6 h. X! N& X# j& @var yMax;
( k, c2 f2 p8 h# ]) {, X. O/ wvar xPos = 0; ]0 `4 C/ G0 e/ P7 l" D" U
var yPos = 0;7 e/ D; b' M6 h$ S
var xDir = 'right';4 W, L. P; Q* c$ D
var yDir = 'down';( Y; S, ?. @8 F: N! e/ Z2 h
var superballRunning = true;
& f2 n' u( V& @2 T' }( yvar tempBallSpeed;2 Q8 U4 J5 `, E1 e3 t
var currentBallSrc;
3 }+ ?; V8 y" Hvar newXDir; y3 m ^$ i7 N; `, o o5 m' O) R
var newYDir;
3 u# R0 ^. Y- q8 X. w2 ~6 w l# E# c" a7 F- j' _9 I
function initializeBall() {7 j, h8 y& \6 d' J* c
if (document.all) {' _6 Q& d0 K8 W- h W1 o
xMax = document.body.clientWidth
9 P6 _# ?3 @1 m7 P/ x/ s% g yMax = document.body.clientHeight: x! a) a3 U6 z! l
document.all("supertext").style.visibility = "visible";
7 G- A/ y0 L( [2 t3 q contentWidth=supertext.offsetWidth% |# W7 `( D; j9 j" n
contentHeight=supertext.offsetHeight
! S- k& T% r# v) e4 o" P }0 `* c$ [( t) g/ y4 R" [" K" a
else if (document.layers) {
5 H. Q, L+ d8 m4 D6 R xMax = window.innerWidth;
4 M+ V) ?+ K Y( z$ z3 C1 s yMax = window.innerHeight;
! D" H& k5 N& ~0 m0 p6 b ?8 c contentWidth=document.supertext.document.width
( i+ M. Q- L: b# U7 ~- P" a contentHeight=document.supertext.document.height
1 }8 o9 ^4 [) ~. L8 y [ document.layers["supertext"].visibility = "show";; X0 p5 g! h% }; f
}
: c6 R E5 ]+ y+ d7 D* x setTimeout('moveBall()',400);6 k1 B( y5 ?+ K) ~ d1 y: C
if (hidetimer!='')6 t: @/ s4 n2 C7 ^2 r9 @
setTimeout("hidetext()",hidetimer)' e4 c- f' b; h4 N- E
}
# B+ ]) F* z9 w3 @! y* r
5 y. X; q; b- e0 ]5 Xfunction moveBall() {
/ P/ a$ Y0 P( Z2 e, J( N5 @ if (superballRunning == true) {
9 P, j0 x3 m" B6 K* |; v0 L* l calculatePosition();$ o7 l: W5 Y6 x G
if (document.all) {
6 D, Z2 H+ O+ W/ }+ F document.all("supertext").style.left = xPos + document.body.scrollLeft;
- o1 t' B3 o5 Y0 y- i document.all("supertext").style.top = yPos + document.body.scrollTop;
) _2 e" h" v6 m }
* ], F0 ` P! X# K! p else if (document.layers) {2 @9 V# ?: x, z9 U( Q" }
document.layers["supertext"].left = xPos + pageXOffset;% [8 Z5 e4 Y4 G, K2 H
document.layers["supertext"].top = yPos + pageYOffset;1 ^5 {+ J- k; e8 S
}5 _5 [7 ?2 b4 q8 N
animatetext=setTimeout('moveBall()',20);
4 ?3 l* z- }6 J3 M7 \+ O* |9 ]7 | }
7 M9 o! i) w; O5 c }
8 Z6 s( B# ?# K
$ c) |9 R6 M$ O! f5 wfunction calculatePosition() {0 j5 x; z: B$ |: c
if (xDir == "right") {# \& z! o- N4 Q- p
if (xPos > (xMax - contentWidth - BallSpeed)) {
/ Z0 Z- y& z/ J5 x# o: h& w1 s xDir = "left";, g8 ?9 R7 X3 u5 d4 M- i2 _+ B- R
}" w0 n0 P& R' ?, d
}' K& ~3 S. z1 Z
else if (xDir == "left") {
% Z& V. b+ C. m a8 M if (xPos < (0 + BallSpeed)) {" C) n% y& p0 g2 w, |
xDir = "right";
; e6 y5 D7 l2 N& R4 Q8 G }- r" `9 S( F8 }- P( z
}
% g" `! q: q8 ~8 s# b if (yDir == "down") {. [: i% X, w, J4 W% t& [ }
if (yPos > (yMax - contentHeight - BallSpeed)) {
, H1 W# v/ X& j; @, ~; {- ^, L: q/ | yDir = "up";' h6 J4 l6 g8 o; E( x
}
3 b! [5 b; s7 n- k } ~# ?4 i* C% {) m8 C: `( s
else if (yDir == "up") {
: D) J, d& a& O' G1 x if (yPos < (0 + BallSpeed)) { P! L+ _+ n7 o6 }! j' J8 p* y
yDir = "down";
% ~) V' C/ c, I7 _( x9 f# w6 T } f2 A0 Q, Q0 r' X! X3 b
}
! e4 r7 m# N1 P. X( ?: } if (xDir == "right") {% J7 P' \5 e+ ]+ U, g3 ]% {
xPos = xPos + BallSpeed;5 q1 |. i) I( h7 g$ K8 Q3 A! W
}
' _. V0 V1 ?+ p W/ s* g( u. a else if (xDir == "left") {0 k F& h/ h, i
xPos = xPos - BallSpeed;" W9 B" `3 J, K$ i# ^5 w; {6 `; Q, q
}7 b3 S# {2 q2 T4 x) ~6 U
else {7 x/ A) u5 X* y4 F+ K
xPos = xPos;
- a5 s+ y. K) U0 U1 C }
! p" S5 g( U) R' c# a7 W if (yDir == "down") {
1 ?3 d- V* [; U9 ^/ h) x! b- J5 b! v yPos = yPos + BallSpeed;
+ {3 `) C& q& h$ j2 c& ?# Z/ L }* R0 ]/ k: q, w4 ~: B
else if (yDir == "up") {0 d2 C0 B$ V& C9 a, z7 `- `
yPos = yPos - BallSpeed;; |% j% ~# ^9 y- x1 ?
}2 G; Y6 C) M, n' V9 Z
else {
- X0 V b. ?4 @' `+ N0 ]& q. W( w yPos = yPos;
, _4 v! A. p& h9 }) J }
5 c9 w% d1 ?. T }4 o" Z* f5 G% i- f3 N$ F
: z1 \' P8 L( |, I0 f1 y7 p S
function hidetext(){! U! ~' ?3 d# U! A0 g
if (document.all) B ~ i' W/ h, _' r
supertext.style.visibility="hidden"& O8 T! ?! D' i; Y8 }! R% w6 i
else if (document.layers)
/ e& H* H( T4 n; R# Y) H) vdocument.supertext.visibility="hide" ~5 x* c4 @; e/ ?: Q
clearTimeout(animatetext)- x. p2 O( }5 k1 D. _
}* b" x% C# O" R3 G) _6 h9 Y2 i
$ @, T1 h/ j w5 z% i! w7 Kif (document.all||document.layers){
$ L7 }+ u. c V* n7 R udocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) L8 O3 H3 Z. }3 J! ]; Cwindow.onload = initializeBall;
' D7 m$ X9 P! t5 z: m! q `window.onresize = new Function("window.location.reload()");
d- h) Q7 [8 }* U- D& @}
# \2 V& g; e; e8 p( V% g. _5 G- S8 v( |, Y6 a
</script> |
|