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

|
网页之不断弹射的文字-特效
<style type="text/css">
V% t" G v+ B$ Q0 f#supertext {7 k3 \1 t) X/ g- R* L3 ?
position:absolute;( } e) m3 \. A! F! Z8 }; |) y
left:0;
( ]% I# h$ T5 N( e4 [& J! {top:0;
: q0 K# o8 T* bvisibility:hide;
! }& R+ x+ g& [visibility:hidden;
$ p8 C. Y5 ^( j0 n& @}
1 {3 e+ C% N, {</style>" b5 V* x( S% z7 T5 I) ?$ \
<script language="JavaScript1.2">
1 M& ?7 F, O' u<!-- 改变下的字体的大小。颜色-->
) V+ u# I3 [9 Z3 O+ N7 G ?var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'; ]7 ~' J+ K/ Z5 w+ K
var hidetimer='';
( d+ o% B0 s7 J2 n<!-- 改变下的弹跳速度--> I! `) t+ H B3 C
var BallSpeed = 20;9 b0 e4 v5 z$ f7 \* J7 u4 ?$ w8 H
var contentWidth;
8 v9 l5 d" Q! A- _' J) p0 n- Bvar contentHeight;4 j* c# `7 W+ d1 n3 k* ]
var maxBallSpeed = 50;+ a K, f6 f* P& x$ ]1 P1 `- y
1 Y; p. D% F3 L8 o
1 a5 A+ w: Q; ^2 Mvar xMax;
- w4 O y/ K' Q' _7 u; Bvar yMax;2 D$ {( X/ S* t9 a6 n8 R, V5 k
var xPos = 0;/ W: D- n6 [8 v& Q. u
var yPos = 0; s+ L4 x$ F& |. |/ R- H
var xDir = 'right';4 { M( M+ ?* G, U+ ]; ^ [1 ]
var yDir = 'down';7 e; s, J$ y- \* V; A+ |
var superballRunning = true;: E8 ?. m2 Y# d
var tempBallSpeed;
0 a- M! R- D P; D! I/ nvar currentBallSrc;! A" Y5 c9 P7 c- D) u) m) E; ^
var newXDir;& d* K. s" f& Y) M* \5 m N
var newYDir;
) l$ X, X) R# K/ Q9 A$ v9 \2 c X
: o/ K* W7 M7 V) Y0 v+ D+ h$ Efunction initializeBall() {' u+ y4 Q; l, Z, X( T; u3 e
if (document.all) {: X0 C2 Z" D( `+ E# m
xMax = document.body.clientWidth+ t; _" N) u' m8 c" r
yMax = document.body.clientHeight* a* F, x/ U& U6 R$ Z
document.all("supertext").style.visibility = "visible";! b6 K0 M: m; A2 Z; H6 H9 N) A5 N" B
contentWidth=supertext.offsetWidth( `$ |/ G1 U! c" l! ^( ?
contentHeight=supertext.offsetHeight8 I8 F+ s* s1 P4 }6 a$ f' l
}/ I: u$ ], g3 K& x, P
else if (document.layers) {
6 W9 l, U: ^- Y( Y6 P& y$ z H7 t xMax = window.innerWidth;9 a, j% y3 F& ]) \
yMax = window.innerHeight;
8 ]9 L9 m5 M/ q/ t% ^; X contentWidth=document.supertext.document.width/ G" f. G7 M4 ~
contentHeight=document.supertext.document.height
6 D0 u, J* m' }$ I% `- j A document.layers["supertext"].visibility = "show";' z. N% `" b. e- I: v1 N# y7 _
}+ Y1 k" J5 y% V! T& v+ f: k2 }
setTimeout('moveBall()',400);& y+ ]( {- d h0 s' _9 T. i
if (hidetimer!='')
" n/ K& n' i( j/ {& m; O9 c2 o setTimeout("hidetext()",hidetimer)
6 S- D" @+ Y* h }
! {" }: k1 Q- ?7 ~5 ^ }& {; U& g
, i1 _# K n, F* \: M! yfunction moveBall() {, @2 [3 k6 N4 y' G; S
if (superballRunning == true) {
- g- z. A7 i' y( y: x" K" { calculatePosition();3 q4 K; r% _, T7 D2 {" Y4 B& |8 Q
if (document.all) {
7 R; G5 j, Z% |( t document.all("supertext").style.left = xPos + document.body.scrollLeft;
D x% I/ `7 k. a, O6 i document.all("supertext").style.top = yPos + document.body.scrollTop;
3 V$ O5 p& E" T0 C+ w) I4 M/ M }# K' S: d# `4 H1 ?4 N# j F2 s/ ^/ C
else if (document.layers) {
+ ~% o# J4 \5 A9 O1 |! m5 O document.layers["supertext"].left = xPos + pageXOffset;) x! _( x! j" {3 N
document.layers["supertext"].top = yPos + pageYOffset;
' |" q2 ]% f" { V; o$ ]/ q }
! j) r/ z' L0 O: c- q* O7 z0 p2 R animatetext=setTimeout('moveBall()',20);
5 \' J7 n- l" D# G0 r# ]* l. _1 A j }
1 P, d7 |1 F3 e ]; W& w i }
' S/ n+ H9 G, ?: U- U5 U& x
: I2 m6 O) i. Vfunction calculatePosition() {/ I* M3 X) l$ Y# W! ^1 Q& ^( Z
if (xDir == "right") {
' o6 o( ^) H% S9 Y# H+ d5 Y if (xPos > (xMax - contentWidth - BallSpeed)) {' y; ]( N- b: J" W: V* u
xDir = "left";
% Z$ Q9 D+ Q, G) C0 S6 m' J H- e }. z/ P5 f$ y4 Q5 q
}
4 P: O& [1 y0 F" M( v% u c6 h else if (xDir == "left") {
@5 ^6 E3 p4 w- @) V6 w1 ]# O if (xPos < (0 + BallSpeed)) {
* n0 H9 |4 h1 m8 a+ s4 e xDir = "right";
( ]# z) K+ L1 o9 ?- u/ k }
2 ~3 \6 D4 j4 c# u+ W }, J; a% \! J: @7 D* q
if (yDir == "down") {. D3 Q o3 v& o
if (yPos > (yMax - contentHeight - BallSpeed)) {
; Q" G. G8 B' z1 R3 H: J: A6 E yDir = "up";, D- N, D' S( i: i) Z1 E6 B( F
}, }0 y3 T: Q7 D" R# E! i8 [
}* m# x# n6 h, Q1 W* _, S) `# m
else if (yDir == "up") {, V4 \& N1 x( w) _- L# g6 ]
if (yPos < (0 + BallSpeed)) {
; j# O1 l5 i, n3 e4 R yDir = "down"; i; [: U% L3 e6 l$ w/ i6 u
}. m! h$ F% b: k7 q
}5 ?$ P6 j7 E/ M6 q9 @6 L& H( h
if (xDir == "right") {
6 Q& ]: @# r# L8 C xPos = xPos + BallSpeed;
7 A$ @/ _' J5 O% z: k }9 X) z( H/ u% R* l# b
else if (xDir == "left") {, i5 Z# l! V( I2 X- n# Z( o0 e
xPos = xPos - BallSpeed;
* ]; g9 V q$ z& [4 G* Y }. C$ y8 u1 u: k# o4 G+ m
else {
" P- C) k$ a- i8 o9 P xPos = xPos;! D" N- q3 S! q) F$ Y5 V( X8 ]
}. U5 `7 k# R8 B; B6 j
if (yDir == "down") {, p1 P! K. V# M+ p) {
yPos = yPos + BallSpeed;
- z5 b. ^$ ?6 Z- H4 }7 g& A! \ }3 C9 e5 ]. V7 p4 j, t& E. z
else if (yDir == "up") {
# f( G% k8 T) V* b( O; q5 H4 H( ] yPos = yPos - BallSpeed;
2 U3 h: U, G Q0 A5 E( d }- L- ] ?/ d2 R6 K+ Y+ [
else {
, h" f9 G+ R+ G2 Y) @+ |, _ yPos = yPos;
, ~+ k# d( ^7 l% Q% y, z( q5 P }$ L3 d! P$ r9 i! a- W
}7 @3 b1 i# r$ I% C- _
/ s7 K! Q7 U4 E* ?% E1 X
function hidetext(){9 P+ ^3 @6 A; H7 W v" \
if (document.all)
/ v9 O% S8 g8 i R5 p( Ssupertext.style.visibility="hidden"
0 \8 G7 J. v' t* L# {9 G% }else if (document.layers), ]: |- {! s" V1 |- }9 i P
document.supertext.visibility="hide"% _: Y! [1 g5 d8 i, I. z
clearTimeout(animatetext)
, N# ~* l7 t" O( m( W" `}9 l9 r7 ~$ r4 G8 r
( h7 o4 ]7 i: e; Pif (document.all||document.layers){ w' ?2 C- J" w% i2 _
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& d- V! \- l5 A% P+ ]# p
window.onload = initializeBall;
) ?: s% n" n `8 O& ^2 Lwindow.onresize = new Function("window.location.reload()");% _+ N' Z5 ~1 S0 m. Y3 r C
}
r8 k1 x8 w$ i4 j
, _6 u4 D$ o# q8 @8 n</script> |
|