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

|
网页之不断弹射的文字-特效
<style type="text/css">
1 m ]6 V' f4 y#supertext {
. {& M9 J) |9 j0 O4 b# I6 Jposition:absolute;
# Y+ H& P- A" h3 N) wleft:0;* p! ^5 |6 Y$ t; I% W
top:0;
+ b+ R$ e3 I# Y& s# Ovisibility:hide;. ], M0 B/ b9 p0 }
visibility:hidden;
5 o/ L8 N M3 D- h}1 |7 S- x7 r- |$ M- H( n" |
</style>0 ]5 S6 e6 ?: K9 m, k9 ~
<script language="JavaScript1.2">3 s& T4 f; c! R" ?& i x9 ~
<!-- 改变下的字体的大小。颜色-->+ _! a+ X* j8 p
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ J2 T0 }& x0 q* N, I+ P# K
var hidetimer='';
1 N9 f' _8 ?$ x" [4 H3 ]1 i* d6 G<!-- 改变下的弹跳速度-->
& j" _4 \( Z$ Wvar BallSpeed = 20;
" Q0 T2 D. {0 m; y0 Yvar contentWidth;
: e( L0 U7 C/ W% Q1 O; wvar contentHeight;
; ~# F$ z8 ~$ c' Y$ u4 ?0 svar maxBallSpeed = 50;5 r, E% m- t3 b8 r l( W* }
0 M1 ]1 j- R( p
" f2 J0 I0 J4 i& ^var xMax;; ] b) E* A1 N
var yMax;
9 O4 l6 u7 M3 P# X: _- Svar xPos = 0;' L5 }% L1 m; b; |5 |3 X: N
var yPos = 0;0 r, g8 B5 G! U, X: V* w/ |
var xDir = 'right';' z6 f* z j4 T$ }0 d r
var yDir = 'down';
4 v1 L! f7 k! S% n: x2 n: i8 V0 x+ u$ Qvar superballRunning = true;
- p$ ~, ?- l1 o+ t+ evar tempBallSpeed;
0 [6 C6 `+ t. u! Z% g. lvar currentBallSrc;
/ d( n- Z0 y5 r$ Rvar newXDir;
5 j7 ]: L' Z% U: f( w/ dvar newYDir;3 V# n# M0 {! ~" \# A& K
# V ]# M$ @' ^5 _3 h8 i6 Y. | R
function initializeBall() {& F4 V; `1 T2 m. m1 y: L5 k
if (document.all) {& z) q0 h& d2 ^( _( R; Q
xMax = document.body.clientWidth
9 e$ `9 _, K6 ^# [/ k yMax = document.body.clientHeight6 A( D- ?: y9 K) Y
document.all("supertext").style.visibility = "visible";
$ d# B; @) g, t; e( t contentWidth=supertext.offsetWidth
, H1 Q9 G# L. Z; V contentHeight=supertext.offsetHeight* q( k5 t& Y5 T- A
}- u/ s8 Q' i- T
else if (document.layers) {
0 z, H1 H& G) n5 S4 y xMax = window.innerWidth;6 f/ J, d, c4 i: [. K5 _
yMax = window.innerHeight;
; U k( P }4 v' y6 ]) J/ C9 G/ | contentWidth=document.supertext.document.width/ y: y* j# @- \- A4 e
contentHeight=document.supertext.document.height; b2 t# s) J B' e' S
document.layers["supertext"].visibility = "show";; T6 i3 W4 h( B
}5 x7 V9 H# D' G: J, w0 b% L
setTimeout('moveBall()',400);' e% Z) ?$ H( L$ N, s+ i5 q
if (hidetimer!='')
[4 ]3 ^+ @ E4 J$ ]4 Z6 i setTimeout("hidetext()",hidetimer)8 Q5 J$ @! C8 N7 ^2 v
}
7 ^# W% I4 ^8 i) e
- J9 j/ U7 _' V: ?function moveBall() {
2 b1 m& E: x0 w; w if (superballRunning == true) {
0 P7 |9 W( v7 c3 D/ C8 [, s3 k calculatePosition();
. ^8 P: ?, o4 i; J. ^& l if (document.all) {
: y! @8 H( p8 x' I8 C document.all("supertext").style.left = xPos + document.body.scrollLeft;
& v" O; C! |1 B3 g ?8 k f document.all("supertext").style.top = yPos + document.body.scrollTop;
) N0 A, _9 Z5 x! Q }
* J: C7 J; T2 e8 o+ ] else if (document.layers) {* j' c$ n0 ?1 X; j- p6 l8 d5 F
document.layers["supertext"].left = xPos + pageXOffset;
% V3 a; z1 l; k0 G document.layers["supertext"].top = yPos + pageYOffset;8 U/ x0 ^: U4 H, X2 b( I
}
, U+ @9 n% X3 |2 Q animatetext=setTimeout('moveBall()',20);- J9 u# r) v: O; M3 c' M( g
}
7 g4 }* z* k2 t7 _9 [1 i2 J4 u }. d: S! T2 |! x \3 L" B* S$ c
+ N: x# S" A% ?9 \; x ?! Dfunction calculatePosition() {, M; e5 \! r9 m
if (xDir == "right") {3 x$ d/ h# A' {
if (xPos > (xMax - contentWidth - BallSpeed)) {: Q/ h; }0 r) W7 ~6 {: a' x
xDir = "left";4 j- O+ z% X6 O$ G9 X$ l# \3 i1 @+ p
}
- k2 c2 N7 F7 P ~0 l0 i, E }$ O. \: a% v6 @/ G# M
else if (xDir == "left") {
! t- z) ~; H3 K* ?, ?5 N9 T# v7 | if (xPos < (0 + BallSpeed)) {
& p9 d0 r- }3 O+ i xDir = "right";# O R( a9 E+ l0 b" i
}: c; ~% W* A" n' w2 @6 l4 \
}
% B7 z0 j: e9 ] L3 L if (yDir == "down") {! \" B9 J3 Y; K$ k. x
if (yPos > (yMax - contentHeight - BallSpeed)) {2 F: ]! r7 N4 c$ J: @3 T
yDir = "up";! \" R1 H7 j/ a# S
}
0 M! V9 D% L0 H7 }& V0 Z( p" B1 B: G }
* u4 ]( x0 O& D- j& Z5 g else if (yDir == "up") {0 S+ u) o" [2 J4 s: {* w t& f* q
if (yPos < (0 + BallSpeed)) {& [( M( j0 H' T8 L3 x
yDir = "down";
: `9 I( Z! s6 T3 j5 n }
4 a" z4 K! j) Z# |" V( H% Q }
( h4 J4 |0 x" A0 V, e7 v% J# Y1 Y if (xDir == "right") {" ]5 B2 A9 I8 P
xPos = xPos + BallSpeed;
8 i2 f* V K5 Z3 I a, Y0 X }
3 I1 d% P" L3 I" U9 v1 @ else if (xDir == "left") {5 B: c: G; Z6 d9 r9 E6 S1 O( R6 g' p
xPos = xPos - BallSpeed;
+ J5 ^$ \) T+ T: t3 \/ p }
1 {) t3 s" V% I% n5 p. i. [ else {
# j/ }- m/ b1 M/ M% a xPos = xPos;9 p. m& B; b5 ]% U; _1 t
}: J4 J7 t Z; s: Q/ }& v
if (yDir == "down") {. U3 F- T+ A- P9 ~: d+ c1 x7 X
yPos = yPos + BallSpeed;# B6 _; d6 g! R0 R0 W
}& b9 [! f+ H' Q z) u; W3 _4 K
else if (yDir == "up") {& O1 f3 S# n0 C) o1 M& w
yPos = yPos - BallSpeed;/ D7 g& e( a3 n6 l
}
! u8 y8 \$ t7 E( [. C else {' p# D+ J7 }5 l. v9 X7 K, e
yPos = yPos;
( E6 d& N) J/ Z% Q" K. M+ O a- l _$ A }
/ L) {3 C/ {: V. C0 O! b3 ] }! v4 v: w" X x( O( K+ Q7 [# |
( X \2 m) Z4 g0 g+ q5 q" _- ?function hidetext(){
, [; N5 Y8 d, u7 Iif (document.all)
0 s, k; h' @6 F, q' r0 m1 C6 ssupertext.style.visibility="hidden") f! q+ o3 x' ]" X3 a
else if (document.layers)
3 w+ a: ?5 q6 Q bdocument.supertext.visibility="hide"
8 A% C. u% H' d* ]9 X+ qclearTimeout(animatetext)
; T2 b) P8 ]. W: g' }* z}; ]: Y( F+ y! I0 q! O
% t) ]! d) R; b$ M$ g- K# ~
if (document.all||document.layers){
$ h$ ~. B5 w, y/ r- l9 {" Hdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')# H# _( I8 S; D7 P* F" m
window.onload = initializeBall;$ Y4 y$ E) U4 _% f# R; x" p
window.onresize = new Function("window.location.reload()");
; }6 |) Q2 d* {+ a1 f0 A2 l% V}
8 i5 b7 Q9 A z. t" t2 `1 t9 o, K, n' D& j8 u- \* Q
</script> |
|