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

|
网页之不断弹射的文字-特效
<style type="text/css">3 n" H+ x% k% Y1 v$ M% u3 H
#supertext {
7 Y% {3 |& M8 o9 N9 c! Pposition:absolute;' w" _& u$ c8 n/ ]" N, t: t5 H
left:0;
, q0 i+ M! I5 T j( V4 n+ |top:0;
0 B4 n, D. ?' p3 a$ T& R) u% Svisibility:hide;
& D( Y1 X3 w7 H: uvisibility:hidden;7 ~6 T4 g- } O8 [, L
}
4 V5 F" p/ A& F: a! l</style>5 j1 n; A7 \: r" H
<script language="JavaScript1.2">
$ l! w) u8 O! b, J! F<!-- 改变下的字体的大小。颜色-->7 f, H( {- `6 z: H, m
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% T' W4 S5 \0 ]) m: s5 g) j) Avar hidetimer='';8 v+ @/ W9 J% ?3 t4 f
<!-- 改变下的弹跳速度-->
- V& v) H6 B$ V- hvar BallSpeed = 20;
# B+ n# Q( h7 P' k& Pvar contentWidth;( D2 u. x- { b8 w4 }4 R9 _, y
var contentHeight;
! ~. O) K, w, F4 \, ?0 f4 ~" M3 Jvar maxBallSpeed = 50;
! ]( M0 O Q. Z, B+ `
- W; K4 }3 U7 ]: c/ S$ {' V, g& r
" R B' r* A; b, W% [8 Q8 uvar xMax;
- c; s/ G! ~+ g4 I- G& C8 z5 @var yMax;% e: Z! T7 x5 _. C- i2 P# U# x& B8 D
var xPos = 0;8 A9 E$ h. y8 }1 z! C
var yPos = 0;3 Q0 u& [: v3 q2 \
var xDir = 'right';
* C; Q; f5 x/ [) e3 U y1 Jvar yDir = 'down';) a/ R( v; I% F5 g0 l$ u
var superballRunning = true;8 ^% d2 N, C1 F& v" U% \ O$ p
var tempBallSpeed;
8 S- l3 J3 Y. r: e: t: V; ~+ wvar currentBallSrc;
+ ]* e: X, i" r% N$ F( Avar newXDir;
2 D8 u5 {5 d: d4 @7 ?- F& u1 [var newYDir;$ L4 O7 p. i+ V/ e: z9 B1 n
0 Q- m+ ~- o2 B. i. e# v% B- [( i* Mfunction initializeBall() {
. E" R+ Y% x6 e& j/ O; ]" B: \7 L if (document.all) {) W# L0 ~8 H2 w( \* f
xMax = document.body.clientWidth( e; x" n$ v5 H2 [' l0 ]" ?/ Q1 M- ]
yMax = document.body.clientHeight
: F1 T& `+ ]/ l2 w. O document.all("supertext").style.visibility = "visible";
4 X m, k3 Z( [8 z- _! p contentWidth=supertext.offsetWidth
& {! t6 B1 R; l% i, b7 p7 C contentHeight=supertext.offsetHeight
, _+ Y- Y* L# |1 `9 k: s: j }. m0 H5 b: c$ L0 V, P& U2 V
else if (document.layers) {4 Q# _* ^: ]. r/ [" i# Y
xMax = window.innerWidth;
8 B4 D1 s: {: i- M% Z9 S. l yMax = window.innerHeight;! E$ n0 }5 M5 L0 R
contentWidth=document.supertext.document.width
e3 G* m! V3 O' N2 n" u contentHeight=document.supertext.document.height/ ` d. Y) I( L9 Y5 h
document.layers["supertext"].visibility = "show";6 s+ U8 e V+ |
}
9 W% ? y% H. ~/ y, |/ G( o- @ d" ] setTimeout('moveBall()',400);" X1 z, R8 A& V& E4 }
if (hidetimer!='')
/ d9 f3 w& K! @) K setTimeout("hidetext()",hidetimer)
% a+ Z4 a" ]5 y# s! }% h }
' V7 a+ ~* I( \2 t+ D8 A7 _$ w& }' p- ?4 n0 D+ {
function moveBall() {
" e* M* c7 r4 s7 v if (superballRunning == true) {% n1 x8 W( e( Z: t2 L$ C( B
calculatePosition();
8 i, S/ \; Q6 X$ Y if (document.all) { T) k; N+ c3 {- i( D5 `5 [5 k
document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ } `5 o" A8 j& P+ u document.all("supertext").style.top = yPos + document.body.scrollTop;" ]3 ^3 p9 M( P$ x; m6 _
}: F6 W, J2 w$ z! y" q
else if (document.layers) {& M6 d7 Q; |; q; H
document.layers["supertext"].left = xPos + pageXOffset;
0 R( P! _3 T: w$ i document.layers["supertext"].top = yPos + pageYOffset;" y3 S( v5 F Q* A5 Y, X6 t6 j3 _
}
" e T" [* q% U3 o6 I animatetext=setTimeout('moveBall()',20);
1 U2 t6 W9 Z4 z( y3 R' R7 n! R }
# n( r) |0 q& I O6 c4 N0 v! }* \ }
, d- l# O1 P0 w0 p$ w+ i9 D
$ L+ v, D* Z4 |; c( afunction calculatePosition() {
2 i3 ^2 f( U+ Q2 T if (xDir == "right") {
8 r, K: k/ e( { if (xPos > (xMax - contentWidth - BallSpeed)) {! H; `' y" y; S
xDir = "left";
' l5 A( R! S! y }
, K+ v/ L9 e8 x" P2 b) F; B9 Q0 i }( W' Y0 n" X. p2 S% ?9 c. Q
else if (xDir == "left") {
( a4 T$ R& C; G% y; L if (xPos < (0 + BallSpeed)) {- n6 g' w2 f* d7 b3 k) Y( `* U Z1 V
xDir = "right";
( x6 T% K# H( @ }
6 h- {, Q# b, P2 [8 U }
- f/ k( e! N/ I1 ?$ P if (yDir == "down") {
& E0 o! ^5 h% w' ~6 Y% b if (yPos > (yMax - contentHeight - BallSpeed)) {$ U4 T1 Z* i2 Q0 f' [" P. \
yDir = "up";
% G7 S8 j: m) b. F7 _0 C& x }( d; {# D0 B7 e3 \- P( D
}/ n" m- o! M; K+ d+ N
else if (yDir == "up") {: U" ?8 p' p/ d) }. B6 Y( C
if (yPos < (0 + BallSpeed)) {8 K% P3 E' F+ Z& Q; g5 i4 e5 d- v
yDir = "down";) b8 V, a& t! E1 F/ i0 P5 D) ~: c
}/ y, s9 u9 @/ Q/ C% g" _
} I( \1 a/ y. g) C
if (xDir == "right") {% ~" d$ t# o9 w3 D
xPos = xPos + BallSpeed;9 U- a, j! h+ ^' g7 g& ^
}5 \4 _" }4 B; R& U4 k" K% `
else if (xDir == "left") {
1 O( i; [% B+ `! n+ ~ xPos = xPos - BallSpeed;
' _) x% j6 _, B" f/ b/ e }, p/ w2 S6 z* s
else {
) A1 T) u1 U: F$ v, a8 i xPos = xPos;9 g/ i5 u% p! y9 d4 g
}
' N6 i0 }: w8 S9 ^. i' Y9 O if (yDir == "down") {) d6 N0 A" d$ Q" v
yPos = yPos + BallSpeed;
7 L# s$ _/ N8 t# |0 m; p, L }! B/ W( U- O% L7 @
else if (yDir == "up") {! Z; D1 T6 ]( E) g( B' t0 @
yPos = yPos - BallSpeed;
, j C: {$ o% q1 Q0 U2 n0 B: G1 a }
* T* O6 R4 U" [& [, }8 q* N- q- U else {* I4 o- C3 m$ U" F$ p
yPos = yPos;% f5 q3 g: w4 h0 A1 m) Z3 A5 x& S& P
}
# I; B: ]! z. n7 B; K+ R8 Y& I; D }/ M6 N& y* Y D$ p3 l
- J/ Q$ G; }7 E$ j1 W: ^' S- D1 b1 w+ tfunction hidetext(){
, H' [# [4 s" Y8 lif (document.all)
2 c8 N2 L. v- {1 {6 @, t, Nsupertext.style.visibility="hidden"1 ]8 _( z) v) J6 M
else if (document.layers)
+ J- Q4 h9 {9 V* I& m Ydocument.supertext.visibility="hide"% y5 s- k7 M, T) A! _# D1 Q; d, T
clearTimeout(animatetext)
4 D, S9 g, [! E8 N4 n$ U! |}
' `: M& y3 {6 a) V
( A) Z* G8 ~8 K! Gif (document.all||document.layers){
7 x( R, Z( I* O* O: Qdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'). [, t9 J) e/ O3 c- }$ Q
window.onload = initializeBall;# M3 X7 h7 j8 s+ N+ _
window.onresize = new Function("window.location.reload()");
4 i6 K+ P: g/ s8 Z* i, u}- z$ b# ]% s4 Y+ B
1 h3 V0 {) [1 ?. ~3 g' U4 y
</script> |
|