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

|
网页之不断弹射的文字-特效
<style type="text/css">
; V1 n1 V1 S; e1 s#supertext {% B0 U0 E0 t- w
position:absolute;
7 m% ]# z' w' |left:0;
* w* l4 N) l A3 ?3 C# G4 S. |top:0;
" y5 {- I6 z" e2 E. F0 B- e$ Nvisibility:hide;9 M4 n4 `) a7 v4 C v
visibility:hidden;" P0 Z5 L% a4 G+ X# p
}7 t7 \$ ?8 l. N$ m$ q
</style>
8 S- a0 ?/ i @8 l+ E& W3 ^ O<script language="JavaScript1.2">4 {, J, P! X. W" S/ ?+ L" G: l* O
<!-- 改变下的字体的大小。颜色-->/ L2 E3 a$ ^' A( _: h9 H" M- _
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 V* b3 v/ ^+ c6 w8 Svar hidetimer='';
5 @+ e0 @' M; e0 R' f( H<!-- 改变下的弹跳速度-->% r, Z# t6 A4 V) F- r
var BallSpeed = 20;
# n" h5 n: ~" N: O- ^$ h* l1 yvar contentWidth;! E, H, r+ A; n: c/ g3 Z% a
var contentHeight;: q! R9 n& d5 a& R# a
var maxBallSpeed = 50;% o$ U' J _8 @6 N7 ?
1 B* @9 z2 J: A) P/ v% D
3 B8 N0 N; T$ J3 r7 q9 m
var xMax;3 W& w7 \ Y1 N; `/ b6 x* g
var yMax;
, y9 c, O8 m6 s; Kvar xPos = 0;7 P' _3 r) u/ \5 T) U/ N5 D
var yPos = 0;; H' a. T1 L' u% r) ^
var xDir = 'right';1 b f8 x# G' l" {" t
var yDir = 'down';
N) j5 B" N$ z7 i- y \var superballRunning = true;
$ ?/ @% J- t; ^var tempBallSpeed;, R" b* \0 |" l2 i- P
var currentBallSrc;
4 J5 | i. J" G, }4 ^ tvar newXDir;" F- ^& n8 |5 o7 i2 [+ ]- s
var newYDir;
9 @5 {) }+ y& b3 l" }& t% k- y; S1 t
function initializeBall() {$ m: e8 ~+ x; q) i5 m
if (document.all) {, W5 `) H1 D, ^6 N
xMax = document.body.clientWidth
1 u5 D# q* e5 \ yMax = document.body.clientHeight$ a2 P* R0 x0 w: ~6 f# S: P+ x2 J3 s
document.all("supertext").style.visibility = "visible";
9 ]1 Z9 F5 P4 o0 ?/ s5 i6 x. u contentWidth=supertext.offsetWidth5 z& C1 k ~) m& m6 h
contentHeight=supertext.offsetHeight4 X# o+ e+ ~, V# `
}, g$ U) m) A, \* }% g1 y
else if (document.layers) {* }" @6 w; r$ H3 D! k) h0 o/ |
xMax = window.innerWidth;4 V! f" a8 N9 `# U i
yMax = window.innerHeight;
9 g1 Y5 q! N' ~7 Z contentWidth=document.supertext.document.width/ l: {9 d n6 k
contentHeight=document.supertext.document.height. P: A9 [% W4 I
document.layers["supertext"].visibility = "show";6 u$ h0 v) _7 q8 g7 J5 X
}' O0 `$ O1 I3 H5 l/ I8 d
setTimeout('moveBall()',400);- K4 ^2 O# \2 @, j. N9 {' ]
if (hidetimer!='')
' T( @7 n6 c" U2 p. V! @$ T setTimeout("hidetext()",hidetimer)3 X& z( S6 O4 g2 f
}
0 n+ C5 H/ C) O, y8 ~
0 [$ x& M$ j- Gfunction moveBall() {
! L4 ?$ ?, G/ a# u6 ^6 | if (superballRunning == true) {
6 M4 l+ u$ n) y: K, G' L8 n calculatePosition();
; }9 `4 A- I" K/ z1 _) Q if (document.all) {
* L5 F1 r; [: o, g- M' a& } document.all("supertext").style.left = xPos + document.body.scrollLeft;8 }( Q2 n1 J/ d4 f
document.all("supertext").style.top = yPos + document.body.scrollTop;* `7 Z/ k6 o; X: z7 ]8 X
}2 r- u- ]* J; T+ T
else if (document.layers) {
9 V- H& g- o$ v- U5 e6 H+ u document.layers["supertext"].left = xPos + pageXOffset;0 J% d6 m0 m2 Z
document.layers["supertext"].top = yPos + pageYOffset;! y. ~: x1 h2 e' { t2 I
}
/ `$ q+ j9 r8 ?# p animatetext=setTimeout('moveBall()',20);# U5 C5 G/ p! V1 ]+ o/ K
}4 f! `" P: v: q1 ^$ K+ i
}. ^* c$ j6 W3 D6 E7 V
& d) B5 c) I+ W0 Efunction calculatePosition() {
9 }4 C, `7 C9 Z! i5 a8 L# Y; F if (xDir == "right") {
: @+ ]8 h6 Y. i) i/ g ] if (xPos > (xMax - contentWidth - BallSpeed)) {; k: M0 L) d- D* J1 I
xDir = "left";
2 g( t$ @% Q& ^1 P! m* @ }
& Y3 \4 y9 e* D( i# \$ Y }3 `$ A% W" S+ s" ^ f& s2 L C
else if (xDir == "left") {& u+ l+ Q& T9 j6 G% R( l( }
if (xPos < (0 + BallSpeed)) {
7 H& R" X' l+ }" i* C6 K xDir = "right";' H! M0 ?8 C* m1 t g/ `& j
}
& E0 o+ f# x j7 x4 X; ^ }/ J8 t. w& T8 ~5 a
if (yDir == "down") {
) a* a1 A8 l# e [+ a2 `# Z/ K if (yPos > (yMax - contentHeight - BallSpeed)) {* J" G" E* N/ S* u3 z1 }
yDir = "up";' E5 U% G4 A& Q' G9 j. b
}9 T4 o# b/ I: |$ n+ v6 J. ?5 L
}
. L" P; W. s& e$ S& \- g" @7 a- C+ X else if (yDir == "up") {
3 Z7 w+ g0 j& f$ a if (yPos < (0 + BallSpeed)) {
* k: ~1 \3 T2 O yDir = "down";, c G- o) ]: n6 B/ d: b0 n8 C
}
4 [: w$ D( q6 W1 y }
8 N. ]0 [# y: I) ]" P4 T( C. C if (xDir == "right") {
1 D' X; V& |* t" n2 v) Z* {, m' y xPos = xPos + BallSpeed;( y; O/ y* E* {) n5 O
}5 i0 ^- l8 q6 [* }
else if (xDir == "left") {/ ~- M" p; {: h; N7 J: U
xPos = xPos - BallSpeed;7 R% \8 u! ]* n+ I6 W
}& d2 a/ {4 T6 m! f' W$ s
else {! d# H, C$ [/ U, M' P
xPos = xPos;
; ]. ^) S3 V, T$ R! r5 Y }
% k1 Z" D1 c! L( U! E. V if (yDir == "down") {
9 [8 h3 V9 p) s* T2 ~0 {# q3 m yPos = yPos + BallSpeed;
! ~+ D: M) t/ ?( U- {* v }6 H% E: ]0 t4 Z5 r6 @1 m9 c
else if (yDir == "up") {7 U! z3 b9 j% M0 [! L
yPos = yPos - BallSpeed;
# _ v) B) K# K2 x& o }# Y. K1 a3 Q+ `6 A
else {
8 P: c& N2 Y2 X' H9 I0 y yPos = yPos;9 s+ h& S3 l3 ~9 J8 w
}; Y1 \6 P8 ^7 y
}; |# S# C1 S! t. E, j0 l
4 F5 s& F' a7 U4 ofunction hidetext(){
+ g- K5 P9 N! \# P* k4 W% b2 Sif (document.all)- u9 d! H1 T$ J
supertext.style.visibility="hidden"! V, O9 g6 O% @% \: I
else if (document.layers)
3 f( w9 a$ J& Y4 I) U! Ldocument.supertext.visibility="hide"
- u+ ^& b! c9 v/ {( l/ J7 ?# A/ IclearTimeout(animatetext)0 I) Z- x) J! b9 K( g! A
}1 P- @: E; A8 c5 g* r6 n
7 V! E* G' Z# T( _
if (document.all||document.layers){
! E1 J$ x" x2 ?1 ?* L5 j; C1 ?document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 L. u! y( Q! U/ _8 K$ ]4 awindow.onload = initializeBall;* U) x. P( o6 ^( d. f
window.onresize = new Function("window.location.reload()");1 K' T) v! P; H0 W7 N! t
}5 N* y; _7 b9 y( B+ [5 s$ J
, L. x1 W; o( i/ h& o$ y/ h
</script> |
|