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

|
网页之不断弹射的文字-特效
<style type="text/css">4 R% c" d% z1 G/ k4 }+ c' Y
#supertext {
1 u; ?' G7 H# m2 h6 dposition:absolute;0 T$ c: p5 _/ [) M
left:0;, y, d z2 u2 g( J, w/ g1 u
top:0;$ Y9 `3 o# O9 m) ]* l& X' I% a
visibility:hide;
0 ~8 Y; O1 A) f$ V7 w \visibility:hidden;
1 t* g' ]! z% `& b2 S p" G5 \}
& i( ? j) G+ S: \3 Z- r ?</style>
$ Z1 P# t7 O2 [3 j7 R, d/ F& q+ K<script language="JavaScript1.2">* Q/ ]( u1 }2 g) ^
<!-- 改变下的字体的大小。颜色-->
( C, l* u M" i/ n0 ]1 bvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% [+ H1 _+ m4 A6 n7 b
var hidetimer='';9 C @2 O8 G" U0 T8 \& E
<!-- 改变下的弹跳速度-->3 g$ E' r' B* t" O- B& ^
var BallSpeed = 20;
7 @% J' I1 G# b$ Wvar contentWidth;& \3 _$ R# e, e
var contentHeight;
6 ^- P2 B, N6 e0 S& l6 p lvar maxBallSpeed = 50;5 }0 }$ h& \2 n8 e9 G$ i$ U* R
% H( {" O, B2 i9 N' Z8 j
; _: e" T9 y( A( @4 \var xMax;
4 y- w8 x8 c! u+ I1 n H' rvar yMax;; y7 g( C! [# I& a2 r
var xPos = 0;! x4 `% v) `9 N7 B9 w) P
var yPos = 0;) z+ Y, }! @+ Q+ `; b- n, s
var xDir = 'right';# }: G! x0 t( R, X B( A- e1 e
var yDir = 'down';5 q; ^- @# _! j4 \ t" h q Z
var superballRunning = true;
& i! l+ g8 X: J) M% Evar tempBallSpeed;& v0 ^5 G" A8 m+ P4 e
var currentBallSrc;8 W4 O, _8 c+ D, r* [! s- l& D: W
var newXDir;5 ]; H f2 P8 O, F
var newYDir;5 ~& Z! H; w& i4 _- ^% m/ l6 c2 c% o
; _# m7 W& t8 G* yfunction initializeBall() {
, V# R. b. ~9 s- v if (document.all) {
* d/ i0 u1 J. m) v' l# ?1 {8 Z xMax = document.body.clientWidth
* \/ @. g% |& V: W7 @3 N8 r6 x yMax = document.body.clientHeight
# ?# |/ `) v& M document.all("supertext").style.visibility = "visible";
! m* o2 o& } W) J6 H) q# t7 q contentWidth=supertext.offsetWidth
3 L T; q% m$ Q7 x! z contentHeight=supertext.offsetHeight/ v4 r9 X- n9 C& j
}7 K# m& p) `3 [& K# x/ t
else if (document.layers) {
% o+ i- L, I5 G" M xMax = window.innerWidth;
- N* `( L. |# L- T. ~ yMax = window.innerHeight;& S/ C, `$ u- L) ^) t5 Y9 ]4 d4 P, m
contentWidth=document.supertext.document.width
9 F4 ?$ R& \) | contentHeight=document.supertext.document.height) k! `: j0 {7 O5 K
document.layers["supertext"].visibility = "show";
% F# g0 L5 F( B: g: ~4 Y }
" P' M4 Z* @( c6 Y& s6 b8 V% v setTimeout('moveBall()',400);
M1 v: n$ B, T1 c if (hidetimer!='')
- ~& _6 c3 H. {, g0 T, V setTimeout("hidetext()",hidetimer)/ G/ I9 M$ B9 b# f
}9 {) _! k; o9 h' f$ q$ s. y
" r" _4 [1 J6 x% Kfunction moveBall() {
5 h0 H! {# G3 S" P8 @ if (superballRunning == true) {
- t. |4 E4 p. ~- w. j calculatePosition();5 z6 `2 Y% v' H; n
if (document.all) {0 x9 a. b( h$ R) S) R
document.all("supertext").style.left = xPos + document.body.scrollLeft;, m- f: i | d2 X% \
document.all("supertext").style.top = yPos + document.body.scrollTop;
, G3 M/ F1 {: G9 M9 g3 F/ `+ ]$ B$ @ }
; f" ~" b3 f2 L else if (document.layers) {
3 g X; c# |, R+ x0 X document.layers["supertext"].left = xPos + pageXOffset;
; O9 O8 d; C4 I7 A+ D& s1 g document.layers["supertext"].top = yPos + pageYOffset;
5 l2 X7 k2 Q9 A* N. g0 M* } }
, q8 W j" @+ u$ V animatetext=setTimeout('moveBall()',20);) X7 s: s$ G3 E/ [, C
}: ]8 u8 w" z; y9 w# {8 }2 i" ^
}# C9 e" @" k$ W6 A2 G# q E1 k
- q- G7 b5 W& u& d7 z! b% c+ Ifunction calculatePosition() {
% E) X& t3 O, p, K/ h if (xDir == "right") {
Y( m' F; X+ d i6 M) V if (xPos > (xMax - contentWidth - BallSpeed)) {" N- M* f- i. F W% S! x2 j' t$ q
xDir = "left";( g+ \2 p8 \! ~' u+ p- z7 Y; z" Q
}
$ z+ c& s: R2 e4 ?$ G }6 A. w: X* W* |( P& `# Y. @$ `8 q
else if (xDir == "left") {
; d- }0 W, \! q2 O5 _ if (xPos < (0 + BallSpeed)) {
" |8 ?- {3 k3 J) T! u% z xDir = "right";
4 _ P7 w2 z3 ]/ S }2 [' F: t; s# Z6 I% g
}
1 H9 u4 C1 p+ l M6 |+ q+ { if (yDir == "down") {
9 J+ ~) J9 l0 o# w7 B5 d5 r, z8 L5 j if (yPos > (yMax - contentHeight - BallSpeed)) {
/ Q& Z! [* U0 d5 s- l yDir = "up";' ]' z6 ]! D' i" i
}
2 L' r$ T) ?2 u: r! c" a }+ h0 v4 l! E0 c# k7 b3 E; Y
else if (yDir == "up") {* ]5 A4 w& q; e e% M, D* N
if (yPos < (0 + BallSpeed)) {
: A `% N2 T1 n+ q$ x3 d/ q yDir = "down";* Z9 r5 ^. h8 K; v# ]
}: J K& G8 B/ B( q$ C4 b
}
& q6 ^; ]. Y# w n+ @$ Q if (xDir == "right") {
7 c$ a& N* m4 i% `1 y3 s xPos = xPos + BallSpeed;6 }: A2 V& P, q1 v2 h6 N
}
7 x+ Z2 K+ D( n E: ?$ ^1 T else if (xDir == "left") {
8 Z: e- b$ a L3 n xPos = xPos - BallSpeed;5 \3 r) i, U# d* ^! O" M
}
9 [; n' n; |8 }; o0 f/ L else {
) m9 k) p1 d6 U+ Z. a) z0 M xPos = xPos;
+ _, l$ d7 ]' n! O5 W }" B9 G9 L( X4 B( p9 U I7 {! Z
if (yDir == "down") {
2 s% S, I2 J9 I$ u6 i* z8 U yPos = yPos + BallSpeed;
- O5 t$ E% q, B6 @) P, K1 p3 T5 \ }, a0 q, l9 h% D! A$ z
else if (yDir == "up") {
% H4 A. z$ A8 p3 H" K) E yPos = yPos - BallSpeed;$ @9 }" T+ n* \; i
}
8 n- X9 j: J7 K5 k1 A$ n3 w else {
0 w7 Y% K" t2 w yPos = yPos;$ R3 n1 p" M" N
}
6 @3 Q. \ I/ e' ~! D }' u$ b2 ^0 x$ N/ x! y
& o A/ S: _! |8 [& [
function hidetext(){8 e" E# m6 V) \% I& q4 t/ U* Q
if (document.all)) h' |8 ~" b* }. V9 U) [
supertext.style.visibility="hidden"
* T) F8 ?" g# [+ w( r( _else if (document.layers): R; q0 R7 _0 @, H" n$ T
document.supertext.visibility="hide"
+ @7 P1 q8 ~0 Q Q! E2 `' E, xclearTimeout(animatetext)
" N; K: z, X% q, T+ d}* g& r; M4 `) P
2 d; d& ~$ J( Cif (document.all||document.layers){
& s9 l1 Y+ x* s& A& }/ wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')8 }" T7 F! m) O( X5 b* R) q7 T
window.onload = initializeBall;
$ N7 ^* P) H/ M1 f- @9 twindow.onresize = new Function("window.location.reload()");
2 Z1 T1 c) m6 R% x6 Z, ?}
6 y7 n% \) U3 D6 C
3 Y+ g) b' X, {% F- g; V</script> |
|