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

|
网页之不断弹射的文字-特效
<style type="text/css">
+ |$ _: ^# t6 J/ ?#supertext {6 m/ R5 g( R9 l- r$ c
position:absolute; W- q- g1 o* v& _
left:0;+ J4 {$ e! p7 `% Q2 B' ~- g
top:0;9 |( V. p) z9 P# q0 e0 _& `1 u0 ?
visibility:hide;
" x% d/ L: S9 k9 Bvisibility:hidden;
X9 U; L( A/ Q: x}+ a. t+ R/ @- p* J2 U
</style>
! e2 T& K& n! }, U. C |<script language="JavaScript1.2">' t' Z' z2 y2 e9 C; P* N9 f
<!-- 改变下的字体的大小。颜色-->3 b5 z$ n) G+ b0 a. ?
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 m5 z# |" N G- d1 Ivar hidetimer='';
5 ^3 q$ T0 E) N5 Z<!-- 改变下的弹跳速度-->
$ {% L' @, E% U. I5 J( I2 n b1 r) vvar BallSpeed = 20;
# C* c" @( h! u4 `. pvar contentWidth;
, B- S9 @ O0 X) b kvar contentHeight;, I9 m* |: M/ O
var maxBallSpeed = 50;) S, N" k5 r: C) A3 L
/ x ?( T& I8 K" k! c4 L
# Y, ~- d+ K! Dvar xMax;
3 l5 K! g0 v D3 b& tvar yMax;) r6 [. C6 l! K5 ?
var xPos = 0;
# u6 t! p& S- E# |& g* T$ I. Wvar yPos = 0;
4 p( y# w& ]6 m5 e" d/ Ivar xDir = 'right';* P% Z- O; i. k6 H1 O# ~! j
var yDir = 'down';+ x9 @ F* ?6 W& S8 N, E# J# h$ `' i
var superballRunning = true;
; `* _! _5 }; k, avar tempBallSpeed;; i8 h5 E, M- M% k3 ]
var currentBallSrc;
( {2 o1 Z; t) M" V) _8 L9 c( Vvar newXDir;9 g, }' m0 n" Z* T% ]% |
var newYDir;
2 w e3 p4 R9 P, Q/ X& e! W1 Y) \' I
function initializeBall() {
: ~) a* t: l' q% O" ^+ p if (document.all) {5 r/ a1 k/ ]- q( s
xMax = document.body.clientWidth+ y3 H$ Y( T/ K, m
yMax = document.body.clientHeight# H$ H# m% l+ {
document.all("supertext").style.visibility = "visible";! [4 d8 Z6 h1 e6 Z
contentWidth=supertext.offsetWidth) l, @( i4 ] b0 p1 x. ~
contentHeight=supertext.offsetHeight3 v6 o6 c9 q+ m4 b }6 o
}
w( t& W9 e" Q" S' z+ o else if (document.layers) {% Y# R0 G* O* Z3 ]$ J" u, z
xMax = window.innerWidth;8 ^3 [- s; O1 x: y5 \+ J
yMax = window.innerHeight;
J. I! _4 N, j% a; S% s: R contentWidth=document.supertext.document.width6 h2 l( |9 K( v" J; e3 ^6 |. F
contentHeight=document.supertext.document.height+ V" T% D7 h( G2 @9 q+ w
document.layers["supertext"].visibility = "show";) g7 ~% L; y* S3 V
}# W2 r, A7 L; Y
setTimeout('moveBall()',400);
3 D# a& L) l `) l4 {/ G/ @ if (hidetimer!='')
+ O5 I- D( P3 u. J setTimeout("hidetext()",hidetimer)
( [; ]9 E2 c3 n5 ^7 j }
9 P% `5 ?( _7 u0 Q
0 `+ `+ u, K7 k1 A( u9 }0 D3 qfunction moveBall() {6 P7 y7 t$ f, {* |
if (superballRunning == true) {
/ l' V4 e: A( T- h% j calculatePosition();4 M- q1 `6 Z& y. d
if (document.all) {
$ r4 H" D) W; H7 s, R" l( V document.all("supertext").style.left = xPos + document.body.scrollLeft;5 t7 W: X6 w5 E# e: {: k
document.all("supertext").style.top = yPos + document.body.scrollTop;& b0 `# F0 E' {6 a+ c, P+ c+ I
}
) f6 M. V1 P3 R1 ?) u else if (document.layers) {
* b% P/ j1 I% \' M( e: I# p8 t document.layers["supertext"].left = xPos + pageXOffset;
4 O8 z! T- C/ m; } document.layers["supertext"].top = yPos + pageYOffset;
' N5 c( h3 P0 ^# [, K" `: K }
0 n; S' D& T% e: y2 u# c9 c, M animatetext=setTimeout('moveBall()',20);8 \. M t- e1 y4 J |
}7 }9 V" I4 k* H7 s8 y% m
}5 {' o, _! }1 m% Z% t! ]! u
9 m, c. p1 w; T' `) f+ ]
function calculatePosition() {; }8 ?' d4 d2 D. z, C0 q
if (xDir == "right") {
Z; _3 S# P1 w( G; w, w if (xPos > (xMax - contentWidth - BallSpeed)) {
! |) u" y1 C0 O xDir = "left";
3 a9 j* A2 H4 N6 m0 C }- H! C5 \. H) u4 ]. Q: U9 c9 A. G
}% J# a$ D% v: U3 E! d0 S
else if (xDir == "left") {5 `) i% \: q9 w: E
if (xPos < (0 + BallSpeed)) {5 |3 y% L0 A) `/ ~( p. ^0 E
xDir = "right";
2 d5 B7 L! C9 S* ?3 a+ l* r9 @) G }
$ P2 D! V0 \1 t3 o1 w* g }
6 M9 f7 ^1 [* P% r7 ` if (yDir == "down") {6 v. L3 E- k2 }* C3 W
if (yPos > (yMax - contentHeight - BallSpeed)) {6 y6 C- E5 d9 U2 X( B
yDir = "up";3 L3 T) s1 s, J/ B7 c; ]
}8 e# J# \0 d: G. P+ M3 ?% Z4 X; X
}
8 p2 F* f# q0 A) C) f else if (yDir == "up") {! F+ \$ ]5 z3 b, e9 c
if (yPos < (0 + BallSpeed)) {0 W* D4 h* Y% j6 V4 i, L
yDir = "down";9 Y4 j: g9 C( p+ e* f/ ~6 }% A7 f* W
}
' C( u8 r( d \3 G& T g }
' n$ E% F! f* W! o! U# D* r if (xDir == "right") {
( C5 g% E2 A( z$ X, w6 l xPos = xPos + BallSpeed;6 ^3 |! H( Y8 Y7 m8 K
}0 q$ J7 ~) m, J. @9 N: K2 e% @1 t: G
else if (xDir == "left") {
! _; W* j) b) p6 X# } xPos = xPos - BallSpeed;, O2 Q" A, [$ n& l! g' u
}/ V2 ?* A+ R, D, u& Z
else {! l6 F- o0 t* |" K% ~! ]: _4 ~
xPos = xPos;
9 h3 e" q0 H) k }- F0 F3 [7 `; r' h5 }* t- r7 ?
if (yDir == "down") {& f. z! d$ Q) C2 h- m7 n& V
yPos = yPos + BallSpeed;5 R6 W5 ]1 `6 D* X
}
: o' w4 E, D9 K( C else if (yDir == "up") {
/ _/ x# P3 ]9 }7 ~& U8 q yPos = yPos - BallSpeed;
( Y8 Y% w, @* y* Z }# F% X4 R/ d2 v" c: I
else {* T" P c( p, A! A
yPos = yPos;0 s5 v1 J* b1 Z: |: |
}$ |! @. W. ~4 N. C9 _( T
}5 u \* h: ]0 x; N+ l, i2 u/ _
5 _) Z* I# P+ T1 I, K6 Jfunction hidetext(){6 |( l* h) \4 X s1 }# h4 Z* ~
if (document.all)
' S+ D3 r1 H4 ?. L& Esupertext.style.visibility="hidden"# G5 F: n6 b, z
else if (document.layers) o1 c7 I% e6 v1 P7 B$ m/ F5 @
document.supertext.visibility="hide"
1 M/ l T& J9 T8 ^! ]7 x3 \clearTimeout(animatetext)
' n9 @' O2 K( }9 J}
& A R# }, G3 R8 l) ~* g9 C+ Y+ X. ]
8 t1 k. A1 w1 A( Vif (document.all||document.layers){
5 r" a% M% Y" ^) U- w1 Bdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
4 P# c l7 @7 ]1 N: |3 ]. O8 iwindow.onload = initializeBall;
' p2 m+ W: \- xwindow.onresize = new Function("window.location.reload()");
6 d$ l0 s2 P' Z/ M D}( a: t! m W8 k. S3 D
# J; e u3 F" m/ {8 M
</script> |
|