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

|
网页之不断弹射的文字-特效
<style type="text/css">
6 ~' [8 r) s7 U0 O#supertext {
) Y& U" Y# b) Jposition:absolute;+ x- c4 a! ?9 j* f& b* F' q
left:0;
0 k: W: f( ~5 O$ `; V9 }top:0;
2 H& s" X! C& svisibility:hide;7 q; K' Q" L8 m: A2 q* Y/ }7 r
visibility:hidden;
' c0 m/ K& {4 c}3 ~3 ^; p. M" N8 h) c5 R5 P v# W
</style>
5 R2 p+ S# x( v( q<script language="JavaScript1.2">
$ i4 {! G$ p7 Y; e* M<!-- 改变下的字体的大小。颜色-->
% `% @# |& p! S& V/ u& C& D* nvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', r+ _9 e' d6 Y. ~4 q
var hidetimer='';) `- a+ g/ s3 w; m* e H
<!-- 改变下的弹跳速度-->2 P; o2 i! B+ K, N) _1 ?- J/ |
var BallSpeed = 20;
& L; f1 m/ W8 U& Svar contentWidth;/ U" c4 F }) L% a
var contentHeight;7 v+ ?/ X+ ?/ I$ q$ \2 U
var maxBallSpeed = 50;
. v/ b: v9 J. L1 z
7 ^! O B/ B9 ?8 g+ c; l( ?3 w
( s \& o# ^: b: ~2 _& M" y/ ^var xMax;
) z8 u3 L9 W, T4 `var yMax;
3 |8 u, ]8 w& o! I( d9 c4 I& V$ V9 L2 Cvar xPos = 0;
1 E+ \8 C- e, P! p& m3 P `var yPos = 0;: p( w5 d' t6 v( ?' l
var xDir = 'right';
. Z; \& y% q i! Mvar yDir = 'down';
7 R( K7 H; M9 [# fvar superballRunning = true;1 I* z' j* p" X4 P9 k u' @
var tempBallSpeed;- M) N. L; N/ C) Y0 L% A, M1 x
var currentBallSrc;2 ?- I. u( S. ~% Y6 i% {" P
var newXDir;# H: Z7 [! l9 w8 Z8 n
var newYDir;. o4 [! |9 P$ E9 U4 y$ J6 I I
& n6 S/ o1 u' W c! nfunction initializeBall() {
2 f m: \1 d7 I2 D if (document.all) {9 M8 e8 _! e; p9 |) }' V, B
xMax = document.body.clientWidth2 b, l- [5 Y% o7 n0 U
yMax = document.body.clientHeight* {4 q# {/ ~/ r6 z9 M+ P
document.all("supertext").style.visibility = "visible";5 Q! `5 G7 r# W
contentWidth=supertext.offsetWidth8 R: ~( q& _" \5 S5 X+ l
contentHeight=supertext.offsetHeight
( r8 p1 C# H9 |% ?- O, s }0 R7 F& \) A$ s) q H7 n: |( { }
else if (document.layers) {
]/ t3 m/ ?4 D xMax = window.innerWidth;8 R0 s% f/ c% |
yMax = window.innerHeight;
, O- Y/ w. r g* l3 p% i' x7 q contentWidth=document.supertext.document.width
. q) E8 G3 l+ B# K5 v6 } contentHeight=document.supertext.document.height+ U9 t! J( G. L- }. |2 F
document.layers["supertext"].visibility = "show";
1 n, v$ {) ~/ t9 H7 s }% j& L7 f9 D& w, W) E5 }7 x
setTimeout('moveBall()',400);
; ~% r7 H h$ H0 m0 n if (hidetimer!='')
4 ^0 K, M q+ F$ v setTimeout("hidetext()",hidetimer)
8 t4 T$ Q; v1 X' k5 R9 X6 g* M }
; j; W$ |8 u# e, t* b3 G! C" j6 P
function moveBall() {
0 W" J& G* [9 y/ q& C1 V8 W if (superballRunning == true) {$ X7 ~# h0 y& ? j, B. v5 I; M: }
calculatePosition();/ N' p5 ~" m1 [) e
if (document.all) {/ Y/ \3 V3 D# x P: V
document.all("supertext").style.left = xPos + document.body.scrollLeft;1 _4 Q1 n0 t ^7 @" o) ^# w2 S
document.all("supertext").style.top = yPos + document.body.scrollTop;
, O6 ~3 @* `5 h }# G6 O# h# ?- S3 \- @
else if (document.layers) {& p( f- n1 c. y) U/ Q- Y/ a
document.layers["supertext"].left = xPos + pageXOffset;
$ _- {( o T C' V1 E% ?6 C document.layers["supertext"].top = yPos + pageYOffset;( [1 K( S" `9 F/ m% M
}
+ T, c8 L: D, X: _ animatetext=setTimeout('moveBall()',20);& u' |- V7 P( H' |* U6 r3 G, r) F
}
4 }" p2 H8 t& t5 Z }
4 Z# G$ ]' ]- [9 F& Q: }
3 S' T4 j1 b ]; L1 J; C, r; Kfunction calculatePosition() {4 S4 K5 _, V" W
if (xDir == "right") {0 O' Q/ ^4 L+ R$ t: ~7 o- E- n2 K8 j/ D
if (xPos > (xMax - contentWidth - BallSpeed)) {
5 }+ f1 O$ V% d/ z xDir = "left";
. O* q. d" K3 z2 S5 y, ?' W }
# c' n8 l8 _) u. q' V# h. y: K }
! [% t C: @& A E+ r: O, J' C else if (xDir == "left") {. A& G# P7 j; M: Z8 t9 Q
if (xPos < (0 + BallSpeed)) {
& m* _* ~1 n; H- q1 a xDir = "right";" L: z& A7 M1 h* u! A' n
}8 O( J; d, w# v! _' G( t
}9 o" q+ n4 K3 ~( j+ i
if (yDir == "down") {( Q7 Q% F! ~7 F1 y: K
if (yPos > (yMax - contentHeight - BallSpeed)) {) f2 X$ X9 a# ^( a; z9 W- U
yDir = "up";( m3 t! {2 o6 z& w p
}
8 B6 ~ M6 m; F5 @" [' c }
$ i- C( X1 u: \2 ^; B8 ^ H else if (yDir == "up") {5 l# E1 q* X1 O1 H
if (yPos < (0 + BallSpeed)) {
+ Z% k$ j3 u: p5 x" s yDir = "down";
, y7 q" z! ]( D5 f7 G }
! h8 t1 p7 y# i4 d. Q }
3 r6 A( L- I# C* a if (xDir == "right") {& e6 l* B; h8 z4 R; U' A
xPos = xPos + BallSpeed;5 ~: o- B. ]6 L( w6 @) D% |1 @
}
* K$ n) M8 x, d6 {3 y a1 b else if (xDir == "left") {' g6 i2 G$ I( p
xPos = xPos - BallSpeed;. k2 @! x( A' ^+ x/ f8 I5 m V
}
9 T3 { K5 n! d- z+ }( R else { {0 W3 ?! t' m
xPos = xPos;5 W b/ S; k3 Z( L% f
}, f* A, A2 |% S; r; L
if (yDir == "down") {% ?3 P! P) }+ F8 b/ l/ X
yPos = yPos + BallSpeed;
! w1 W$ l9 r' s- Q }
2 N, R, u0 ^3 Z2 U else if (yDir == "up") {7 t% f# V8 s7 x* Z9 w5 q3 n7 |) _9 L
yPos = yPos - BallSpeed;' A# y( [. ]5 _" E. ?3 G0 }
}( z, Z& ~; T \$ L; ^7 @
else {. Z, g. E9 v' X+ M# A- N5 \
yPos = yPos;: o! y0 k: R3 ~" \3 ]5 m. ?) y
}7 a( O; i$ O# [0 `
}* C( V, l) ]7 w
1 `" S& T; H V; a/ [
function hidetext(){
4 v7 E* O) m, o6 x+ gif (document.all)3 s7 V) v: j$ b/ J' a
supertext.style.visibility="hidden"
! V/ J3 E% @8 o% M0 j1 Yelse if (document.layers)
: d5 _% O5 c, ]( K$ \2 I4 }document.supertext.visibility="hide"
& _8 G3 {. e% `4 f% {3 o% j2 CclearTimeout(animatetext)
1 R" P% q( t+ W0 v}
7 V3 y% L/ i9 j8 K
8 i7 v) \* q8 w" z) eif (document.all||document.layers){6 z1 o+ m, A u7 D
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')5 W6 G/ D6 Y) \
window.onload = initializeBall;4 y! L c9 e- ~4 d: s; I
window.onresize = new Function("window.location.reload()");1 y R/ P3 u0 A" U- O) U z
}
' d& N- I) D" g# s6 U' w
& G7 U7 e) g, E8 z( d) c+ i: n</script> |
|