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

|
网页之不断弹射的文字-特效
<style type="text/css">; K+ i7 R. F, s* J5 U2 m7 s& H1 W# W5 o6 V
#supertext {
' `. Q/ J2 ]6 [; qposition:absolute;
a% r( |7 F9 R0 C- w3 Ileft:0;) b' \6 _5 Y9 _5 ], N/ ]+ D& @% C
top:0;8 x8 E! d9 j2 ?2 N% }
visibility:hide;
' ]+ I+ ^9 ?0 [- gvisibility:hidden;
. X6 \/ `4 |- i+ ]- N" ^2 Y}- \5 q( k6 W8 _' ] _6 X/ [
</style>
5 u2 t2 K/ N3 X6 H7 v<script language="JavaScript1.2">5 Y+ ~& i, r8 h+ y6 i. K; ^! X
<!-- 改变下的字体的大小。颜色-->
3 K! O$ ^; q5 m& Ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( V) L/ I& k3 t% J$ A5 g. e; qvar hidetimer=''; Q' ?( j t) Q! \
<!-- 改变下的弹跳速度-->
2 h* p& r7 W- j h% C1 hvar BallSpeed = 20;
( l) I; H6 E0 }0 N; B% e' Ivar contentWidth;& \ p. i. r4 s$ ^: X! R
var contentHeight;
: @ P, q/ H8 Tvar maxBallSpeed = 50;- v n4 k4 Q; o" i$ _
! ^' ]# ~ e# l: D& A$ I$ T( u
: m& i" h# U! @- V6 X3 i Lvar xMax;
1 L5 V7 N! F: G7 C9 s3 Uvar yMax;% ?3 m5 u8 ^0 ^0 {* \, W5 e) Q6 v
var xPos = 0;. L) b# s2 @2 ^* X9 ~+ f" N
var yPos = 0;
7 x2 o1 u4 i! p P: g1 Xvar xDir = 'right';& [3 k, Y4 L+ {) f$ ^+ Y' T9 T
var yDir = 'down';: @4 {4 j$ D& ^: i q* y
var superballRunning = true;) I( E# \) c3 r$ Q1 m. l2 j
var tempBallSpeed;
' D! V" I' g% H- Z- u) cvar currentBallSrc;
6 b, s7 N( o% b* c7 P* o evar newXDir;( Z$ b) m6 ^0 P& k
var newYDir;
; K+ u/ w" V3 t6 x) V. D% I
5 v) n- g+ \$ @. g+ ]+ sfunction initializeBall() {( I/ O7 _, W1 }( o {1 M
if (document.all) {
' W" ? A% |( m3 G3 d2 L1 j xMax = document.body.clientWidth6 z. Z. H+ i& P5 p: I5 @, ^
yMax = document.body.clientHeight9 a) F- V4 V) e) V
document.all("supertext").style.visibility = "visible";
: L2 h$ ]6 ?& x. P% H contentWidth=supertext.offsetWidth
1 c6 ^8 ?. |, d, e) t contentHeight=supertext.offsetHeight: d8 w6 K3 ]1 X: j' g. ~0 R" b
}
# L( h8 F7 ~- _: n( G) m- e else if (document.layers) {2 _5 ^. h8 B7 M0 r" _* q
xMax = window.innerWidth;
( s4 m9 j8 Q% r yMax = window.innerHeight;) _# A5 K6 W, U
contentWidth=document.supertext.document.width
, A' J2 _6 n/ E, X' w' ] contentHeight=document.supertext.document.height3 x' c$ V( z7 @: v+ z
document.layers["supertext"].visibility = "show";6 q5 O! g0 _! A! A8 P/ k8 r3 `
}
9 n$ w( k+ O+ W( @0 `% `) [% L setTimeout('moveBall()',400);
/ v) A" z5 z3 ^9 b if (hidetimer!='')
) K2 L0 k+ c+ }: s setTimeout("hidetext()",hidetimer)$ ^! s9 ?6 x+ W. o3 ]
}
' s+ R( G F( R( r
6 S) u0 {5 h, ~6 x2 |* W' z4 efunction moveBall() {
9 }5 }, \( r5 @ i if (superballRunning == true) {! }& O4 w1 X; F+ y* u
calculatePosition();% R7 z# P3 X# i
if (document.all) {
- U$ ]" ] X: G6 J: o( y document.all("supertext").style.left = xPos + document.body.scrollLeft;
: R+ P1 ?. j$ f: U" D2 p document.all("supertext").style.top = yPos + document.body.scrollTop;
" ], v* ^) |. E6 q- F( V! ? }4 c9 p1 m' x7 f. k$ |8 l1 j
else if (document.layers) {
0 n; G( U! z" K; Q7 e( I document.layers["supertext"].left = xPos + pageXOffset;
% k. g# H; }' r2 P M3 f document.layers["supertext"].top = yPos + pageYOffset;
' M0 @. @9 C4 {1 C0 f }& k3 ^) a( ]$ c. j% w0 G
animatetext=setTimeout('moveBall()',20);
* v" z6 P d6 r( v2 L+ [4 @2 W3 f }
f5 P3 W& x. D# D6 Z! E& l }
8 T7 T. i2 G3 y: Z/ N+ O- @* L# ]- \/ m! a0 F6 ?; a) Q& w
function calculatePosition() {# o4 K% y ?+ b' ~7 V* N
if (xDir == "right") {
( t* M" X, H7 T2 C if (xPos > (xMax - contentWidth - BallSpeed)) {& R; v. x3 R' v4 I9 l: j/ ~
xDir = "left";. K# j6 s. [% X0 [1 m
} B# }3 V) ~1 W4 l! L1 H+ c
}
" q6 x; g$ S/ @' F else if (xDir == "left") {; }3 |* D; U) } n& F1 u9 ?
if (xPos < (0 + BallSpeed)) {
5 z3 C# A- v/ t Q# y xDir = "right";: [8 i# M- D: `
}
. x+ L) |+ x: X" D( X }
& u' }5 r: c1 T9 d% G; o. c8 o if (yDir == "down") { ?& @/ Z$ F& E6 J, N- W
if (yPos > (yMax - contentHeight - BallSpeed)) {
6 y6 ^/ T6 k3 r5 V [" w( Y- W( O8 a yDir = "up";
- e- W/ N0 G7 a6 C$ K' R }
- c) I7 K, z. J } c* E- h' ]1 J6 d# e6 R
else if (yDir == "up") {
$ b: k3 o; z2 a5 k if (yPos < (0 + BallSpeed)) {
; b4 g9 V. h! z% |4 u5 U+ L9 M7 v& D& R yDir = "down";
, d' y3 h" p$ Y- y7 K }* p6 ?# z9 Y/ Z4 O6 w
}
7 [* d4 d! u# n( ^5 t3 } if (xDir == "right") {% {+ ]$ a% y+ c) y9 K: z4 P/ q9 B d: o
xPos = xPos + BallSpeed;
+ w5 E8 Y/ s% L2 { }
0 E1 t: r% o2 e1 @ else if (xDir == "left") {& v' T& ]4 K- A" j1 u. D `
xPos = xPos - BallSpeed;, h$ a U: ^6 ]' _6 O- [9 X. _, \
}; O4 g* e5 S! w7 ?& V- l
else {
: s: U& D; p' ^0 F7 v$ R" h& o ] xPos = xPos;
; ?, u; w1 ~* E Z) t8 a: A+ X }
# d/ g t8 M9 y" f if (yDir == "down") {
% i7 v" i o. o1 M. N% Y yPos = yPos + BallSpeed;$ H Z/ {" i: ]' e# I% _
}5 Q T! P" A' Y$ v) g1 F
else if (yDir == "up") {
% v+ P. ], u* B! h* @ yPos = yPos - BallSpeed;
: V! @3 t1 K. q; j3 z% q* U }5 H9 ]- `% D9 z/ o) ?) f% l9 M: S
else {
& _' L+ C" @) L+ t3 I yPos = yPos;
# f! s& ?8 Z* }, Z: m }9 p+ r7 W* {* [( q' c' r' x" s* N
}; Y) G, m* L" Y; H' u% G/ e! S, A4 Q
: _8 |7 f8 j* w8 Z& s5 o8 |/ t
function hidetext(){+ O! o% S4 H- P9 K5 P5 a
if (document.all)
0 Y# \' A3 q% y5 J# X5 {7 Isupertext.style.visibility="hidden"
3 t7 z3 D0 `9 Y; Y; v5 Z5 `else if (document.layers)+ h) u# w. ?3 o2 j" j7 J- m6 f! f
document.supertext.visibility="hide"/ b9 A1 P. r6 W8 m3 @9 {
clearTimeout(animatetext)
, J8 Z# N& ~) x7 y/ |5 T1 u}
4 s/ C, G5 l( i: ?! O
5 t* k' F5 ?' ^9 ^+ g7 }8 dif (document.all||document.layers){6 Y+ e$ i8 K6 I( J5 M: V! b
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
, X# D9 B! c' N, J p. ^6 gwindow.onload = initializeBall;# m: H0 P0 j$ ^
window.onresize = new Function("window.location.reload()");0 p$ y0 E. S+ j) B% h1 E
}
2 G+ @7 K# R3 n4 H5 Y, s& j& p0 Q# O" Y. V8 u4 ~1 s
</script> |
|