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

|
网页之不断弹射的文字-特效
<style type="text/css"># n' @6 H5 K+ }4 B5 _! K" ], U
#supertext {
2 f- |4 M `# Z+ Sposition:absolute;+ z& |0 ^8 Y+ n1 Q9 M
left:0;
5 @5 h! y i/ O- ]$ U+ t; |top:0;. J9 l' U! K9 k- Y$ z
visibility:hide;
; A1 L1 x7 E5 s: Dvisibility:hidden;
" n0 m1 g( q% y: @* c! x/ G* N}
, Y1 @$ t' t: q8 {, Q* Y</style>
7 @3 c7 L" `& A$ M) x1 w<script language="JavaScript1.2">
: W$ b* z+ S4 L9 N @<!-- 改变下的字体的大小。颜色-->& k6 H" H E2 M% t. I
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'* N2 T' L) d6 i; |5 w
var hidetimer='';
. t# h) M, z! I) d( U# G5 g<!-- 改变下的弹跳速度-->
0 q( W/ G- k% @+ c$ J( Zvar BallSpeed = 20;
. `& ]) m+ z. x0 z/ k+ P9 [var contentWidth;" a* M1 u. v& d* V
var contentHeight;9 C7 Q5 K% z8 H% g
var maxBallSpeed = 50;$ _6 ^3 ^, S! C. m
% T/ E- [; r# v; d% _& u @- @0 W+ \
var xMax;3 a! O1 R7 I. S% i* n4 M+ u7 ^. x1 b
var yMax;
) K6 h A: Z( `9 ]var xPos = 0;/ w* Z! _6 Z l" J0 b
var yPos = 0;4 d/ L6 j" |3 ?! \
var xDir = 'right';
' b* R4 v- ^$ w xvar yDir = 'down';8 w) M* T3 @& u4 F: c; a' y# {
var superballRunning = true;/ l, S5 Y7 F! U( N7 N$ B6 R
var tempBallSpeed;; C2 D5 D. y+ n: f* l3 F
var currentBallSrc;! A9 g- T. @, M' _' W$ u
var newXDir;. J% o* A7 f8 l5 y6 g3 L! h
var newYDir;
" H2 {( N: K# p# | q! x& o9 p7 s R' [# }) \8 s) }
function initializeBall() {5 \0 Y! M% t8 k: n' p# T
if (document.all) {9 f! B! i/ S2 J1 N) a: Z
xMax = document.body.clientWidth5 q8 q0 @$ o0 Q! G5 }
yMax = document.body.clientHeight
1 ?# }+ g( e% B* ^6 k% h8 `4 s3 m0 n document.all("supertext").style.visibility = "visible";
, R( f' {" F# A( ] contentWidth=supertext.offsetWidth8 k0 D, c5 r7 l+ O& P$ N
contentHeight=supertext.offsetHeight1 w/ h/ U9 q1 ^0 s. i8 b& k
}+ A& [) a, Z8 h8 {4 z
else if (document.layers) {) e2 Q& J9 q& W; ~8 l8 M
xMax = window.innerWidth;
8 L* u) j3 s- D1 Y yMax = window.innerHeight;
5 T f6 S+ U, G/ l$ E contentWidth=document.supertext.document.width/ t' h- H" v3 o
contentHeight=document.supertext.document.height6 Y/ S: v3 k0 y7 Y& i& q
document.layers["supertext"].visibility = "show";# G H$ d0 F7 S3 \# q/ R3 Y
}" }! w$ ]% {/ o6 [( Y6 h
setTimeout('moveBall()',400);
* T! d4 @; E% S3 {' ] if (hidetimer!='')$ d$ |0 ^7 Z# }+ @% m
setTimeout("hidetext()",hidetimer)
8 D$ e* r6 V/ c9 N! S: } r# @5 { }
. z1 B3 X5 ~' U) k5 T1 e5 E9 ~3 _1 F8 G* P. t
function moveBall() {
7 F2 v; j8 w3 }1 ~' a/ d/ L2 E- ^ if (superballRunning == true) {
& ~+ x( z1 K- h& {+ ~0 S% _& L: D calculatePosition();
6 v- \; z: ?* k5 c( t, [ if (document.all) {# {: P: q5 l" r0 ^
document.all("supertext").style.left = xPos + document.body.scrollLeft; a- }2 r* k& _ n) L' I
document.all("supertext").style.top = yPos + document.body.scrollTop;6 s3 Z- k% W$ ^/ x! g
}
7 Z. q' R5 E# L, M else if (document.layers) {
" ~6 `5 ^- L+ l& J3 V5 x document.layers["supertext"].left = xPos + pageXOffset;
& Z5 m6 \8 v& T+ C9 o, _: F document.layers["supertext"].top = yPos + pageYOffset;5 Q, j8 l# t7 S! d: D+ |) S
}
" J+ B, [- V, Z, I8 E% }( L animatetext=setTimeout('moveBall()',20);
' o# K" W* M8 r; S4 J; k: _ }
+ V6 U6 p) |6 K5 B [. c# a8 V }0 Y4 J5 M- h0 o! N& n/ B6 b1 L- I
7 d. s3 x! a( }# ifunction calculatePosition() {
/ x5 X* u- H$ c( X/ ? if (xDir == "right") {( T* _2 Q: h' v Y$ ?+ I
if (xPos > (xMax - contentWidth - BallSpeed)) {
[9 p. E8 l1 W$ ]6 `7 [ xDir = "left";6 p# c! p+ Y3 Z5 K6 g
}: _# X# X; O! |; h8 ~& Z
}: t' M2 e: C9 y: U
else if (xDir == "left") {
* }0 q6 b5 J2 [2 k% l) B if (xPos < (0 + BallSpeed)) {$ B' d3 e: b! I
xDir = "right";; w# ^# R7 f. }# |- C$ g
}
5 [# n T' i7 ?5 a e0 @ }2 ]9 K- m! Q* P# B" t, {
if (yDir == "down") {& O% L5 b. K6 l! Z4 `0 D& r
if (yPos > (yMax - contentHeight - BallSpeed)) {3 d2 z+ W( S) X' f% w8 l
yDir = "up";5 N8 e& {6 {$ }/ s
}8 F# x+ k% ?/ W, s& m4 |
}
! H0 |; ^" o+ S0 A" k else if (yDir == "up") {
& P/ X3 z0 r! b9 T) D if (yPos < (0 + BallSpeed)) {
5 C i8 {: A; E4 i+ l8 n' f yDir = "down";/ e1 x, x; R& ^. Z) A& {5 H. T
}
# F. \) H7 d, r2 n, a( y# x* ^ }( z, ]- R0 d0 K- V; y% C4 b) z6 A
if (xDir == "right") {; t; l2 a r ^5 T! L" V
xPos = xPos + BallSpeed;0 c. |2 G. E+ T- c) E2 Q( I
}4 y9 m$ n& `! U1 _! }7 t
else if (xDir == "left") {
1 {# w9 A: [& I! M, }2 _* } xPos = xPos - BallSpeed;, G* k+ d' j- k; _- S8 @8 n& i
}+ \ r! Z$ @. L6 m7 E! _
else {" K. C ^2 G- ^
xPos = xPos;( W2 @! |& k# j! X
}% a& r. V3 x. w0 C" g* i; Z
if (yDir == "down") {) x7 w# t9 b8 z) G. p
yPos = yPos + BallSpeed;
$ `3 q3 S, {6 q }4 T2 Q) |4 J+ k! q: m
else if (yDir == "up") {2 i7 J$ T) g7 [
yPos = yPos - BallSpeed;
4 u2 r* h2 X& v% ?5 s }
% q3 z2 z y+ p! V( ]1 U& X" {) G% O else {1 g. C8 b2 I! [ X6 O8 L
yPos = yPos;
' F9 X/ G' E& } }
) h N6 D3 U: @ } y9 v- ~6 I- F3 k R8 Q s9 O+ X0 G
0 D7 d+ y8 M* l! d G# w
function hidetext(){7 G" Q4 q4 c- v ]! o
if (document.all)# J* b: [+ P2 p5 V& @
supertext.style.visibility="hidden"
X8 j9 x. a, g, ]0 }7 F( Qelse if (document.layers)
, L7 y7 `) L# ]( x( s5 idocument.supertext.visibility="hide"
2 B( c- @" P5 Y4 VclearTimeout(animatetext)$ F9 P" Z( @4 H3 t( S% W6 }! y; T
}/ G8 b- ]# h$ e+ e
9 F5 j0 p( c4 T0 hif (document.all||document.layers){7 E2 I% Q: F5 D# h) m
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
8 a! U& x7 e- w1 y# m" a$ b3 j; iwindow.onload = initializeBall;, V8 l2 L! q- x5 j0 n2 w
window.onresize = new Function("window.location.reload()");
) C/ W) B8 A4 _, @* D7 x ]+ ]1 i}0 j( o3 w. F/ Y
_! P7 B3 `" l8 b# k5 y$ C7 B! O6 e
</script> |
|