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

|
网页之不断弹射的文字-特效
<style type="text/css">- P7 u( D* f+ v5 Z
#supertext {
3 i" ^- U$ _/ X, t+ q. h v$ cposition:absolute;
6 ^4 W6 e9 z# M7 @+ a7 o5 tleft:0;" ^! @8 U( R; P
top:0;2 {& ]6 X5 h' L& Z3 h9 s, K. x8 e
visibility:hide;4 a, z9 Q/ A& |/ {
visibility:hidden;
. ?6 @; s' C& P7 B+ ?( r0 [) A6 y" ^, Y}
; o/ y, L9 S: x8 S! L</style>
8 H7 M& |0 ~! B |$ J3 u! V% B9 x<script language="JavaScript1.2">
" v. k- T/ S- U* o<!-- 改变下的字体的大小。颜色-->! N9 N; o! N9 ~2 E
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'- S t( f+ ^6 ?( V( m5 D
var hidetimer='';
4 T& p# O5 j3 a3 N/ }5 T& K<!-- 改变下的弹跳速度-->
, n: T, n8 P, ]: h$ x7 t- Evar BallSpeed = 20;
+ P: p% x" i! tvar contentWidth;
5 q, {* f# V9 @* m. R: Evar contentHeight;
& e$ D( S8 y) y- bvar maxBallSpeed = 50;1 V% M, M. c$ U7 W. R+ h
' y9 ], j+ \# [) c$ {. `1 y( X+ E9 {- b7 O; l9 N3 S0 U
var xMax;) l3 Q/ }6 _( E' {( f/ a
var yMax;
# h" Q! {- G! \4 b3 g) Wvar xPos = 0;- w _/ M( a# V4 Y4 L. c, i% d
var yPos = 0; U; g, r, S; t' D+ h0 a' M9 [
var xDir = 'right';0 V- T3 ]5 K# U5 c* Y, f0 Q
var yDir = 'down';
. w# k1 }0 O1 n1 {* q2 qvar superballRunning = true;
& W; e3 k8 j5 Lvar tempBallSpeed;6 X- J$ B3 b* O8 c: {6 m/ l" w
var currentBallSrc;: V: Z4 j# Q; b( @9 ~
var newXDir;" h' Z3 I8 Z" g' L, d8 V& A
var newYDir;
5 s5 {9 d# b, Q: `1 i' S+ r. i4 ^* e
function initializeBall() {: F7 `1 W4 T1 U$ s7 j
if (document.all) {
. q/ O$ s! a/ w) [, R, r" r2 s, J xMax = document.body.clientWidth
b- y, T( Y/ g7 Q9 A3 B yMax = document.body.clientHeight$ \ A, H7 u. H
document.all("supertext").style.visibility = "visible";) {' M+ O- z Z0 `" V# w
contentWidth=supertext.offsetWidth
, v l7 ~ C- J9 Y, i% \9 } contentHeight=supertext.offsetHeight
. |2 @$ w% a# h* P; T9 Q8 j4 o }; K9 O) s. E0 S5 M4 n2 D
else if (document.layers) {
- N0 T7 G8 D! u% V$ e7 y4 }$ E" D* v xMax = window.innerWidth;
" f1 A8 x6 { J4 T/ d( y1 Y yMax = window.innerHeight;
$ G& I% ~+ M' v z4 H4 g contentWidth=document.supertext.document.width6 h1 u8 U/ U/ F! J; x: \1 C# A' O7 q
contentHeight=document.supertext.document.height' y$ U) m+ j$ K. j, Y/ a
document.layers["supertext"].visibility = "show";1 Z3 ^; G7 a2 r, s
}% Y) r- b$ ], Q6 [& V
setTimeout('moveBall()',400);
7 L4 E' {+ `) F( A if (hidetimer!='')3 `/ f9 S( s7 Y" p& s2 e: _& M* t0 S
setTimeout("hidetext()",hidetimer)
) x. \; ]. c! j3 R0 ]' ? }
7 A0 f, C' x+ t( ~8 U8 l$ q* }8 S# V! l O9 N5 x; ~; e
function moveBall() {
* J9 U* @# I) h% I if (superballRunning == true) {
c5 G" b# o# i* g0 k- J calculatePosition();
: R$ t8 X) i% u" y2 s$ G4 r if (document.all) {
2 O6 O9 {( n) ]; w document.all("supertext").style.left = xPos + document.body.scrollLeft;
. o* C8 R6 ?# e: N! a5 @ [ document.all("supertext").style.top = yPos + document.body.scrollTop;
" J# ^* g" M8 u: r. ? }& L7 c# ]$ a Q
else if (document.layers) {
5 u$ d* H# k$ ]7 f D document.layers["supertext"].left = xPos + pageXOffset;: z& ]" p' B2 t4 S8 \/ y7 Q
document.layers["supertext"].top = yPos + pageYOffset;
& p9 \4 S" @- c5 }& p. l }9 \) O* l1 {# W
animatetext=setTimeout('moveBall()',20);
, M3 @' X2 D" P! X }5 ?, K% [6 R/ \) \) F& m
}
' o2 U# S+ @; M0 ^! L$ Q! u9 r
, j; X" X$ T! r' M5 O: O) @function calculatePosition() {
8 B- l$ S/ D7 k* l- t if (xDir == "right") {
0 P- l: A# J1 u7 g0 a- c if (xPos > (xMax - contentWidth - BallSpeed)) {( D/ Z j% F0 a9 q
xDir = "left";, e/ a3 c: F- k5 M9 E0 L" s9 ]+ L
}
/ o# g8 t9 g9 i8 Q9 J }
7 R9 m! X7 ]7 ^* Q! } else if (xDir == "left") {
6 r8 B5 _- T( U+ t4 D if (xPos < (0 + BallSpeed)) {
7 I8 N1 G+ W' t$ K5 W' k7 f2 m xDir = "right";
) j& V! m" j! c* g% k }: ?' _6 P8 s2 g! t6 }
}8 n6 n, [( A9 O7 [1 [8 }8 [
if (yDir == "down") {; u$ Q2 _3 y2 ~5 |5 t+ |
if (yPos > (yMax - contentHeight - BallSpeed)) {& G& z, w7 N* w/ z Z. |) \# E
yDir = "up";
8 R6 Q9 f- }7 A. S }
8 g1 n7 i7 f- }- b' K9 y }
2 \! g2 g Z% Q: i" n6 v5 k3 e else if (yDir == "up") {3 l5 D1 f: n5 K9 Q4 y
if (yPos < (0 + BallSpeed)) {
D( F6 n, g- ^6 S; X yDir = "down";
0 l/ D* g4 R6 _/ p9 _ }
6 t% W" ?, y- h$ } }
1 U( j/ s7 Z' Q }& v. X if (xDir == "right") {7 k5 ^" w: D" Y" H
xPos = xPos + BallSpeed;
2 O+ p! p" ^, V5 ? }) q5 ^8 F2 }& ^
else if (xDir == "left") {
4 D5 I7 ^3 j B! Z/ _, W xPos = xPos - BallSpeed;
& G% G, Q$ Q5 n! W3 u }
5 R* O) e9 F9 C( O# B* C else {
8 d* t. B" L# ?# h0 i xPos = xPos;2 o, r# d b' F- Y: q/ S
}
' D0 `% W+ H3 P0 ^; G if (yDir == "down") {
& y9 L/ E, k7 ^3 }( o* G yPos = yPos + BallSpeed;- q$ ?/ a5 V+ K
}
* Y+ y& q h* \4 t6 a else if (yDir == "up") {
/ v! Z" c: g% q9 W1 o7 h4 j yPos = yPos - BallSpeed;- S( `% B/ V, U1 q0 N
}7 o8 f/ d7 k& R" A
else {5 v/ U! _) R i1 p6 U% }6 }
yPos = yPos;
# A) \% U0 Z( A- [ }( G! ~# ]9 j+ C) o5 f2 I0 U# R# P
}2 R/ w8 r8 a+ h( x5 Z5 m5 i
; ^) F' z8 S7 ~ m7 c e# o. B; b$ gfunction hidetext(){' ^, K/ N' |3 C5 c9 h
if (document.all)
/ |7 \& y/ h1 C, Xsupertext.style.visibility="hidden"1 x* r2 `; t+ g2 w: D
else if (document.layers)/ }: h" P7 H3 B- k; Z
document.supertext.visibility="hide"
1 x) F2 R: n b( UclearTimeout(animatetext)
0 k2 @4 S; s$ G3 a) H+ \} D- i t, T, |( p
. W) B- c/ m- `+ c8 Bif (document.all||document.layers){
4 a5 c! O# W8 _( tdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'); H" a+ L3 o8 Q2 E$ ?& {/ s
window.onload = initializeBall;
2 Y" @. f2 Z6 L5 ?) ?- _* r7 twindow.onresize = new Function("window.location.reload()");
6 ^ a4 V: J# q9 A) ?}$ }8 h3 k4 ?8 x! d$ S
0 q* ` N0 ^# Q% j; L
</script> |
|