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

|
网页之不断弹射的文字-特效
<style type="text/css">
- O3 M0 y) B; p; }8 T$ k* U#supertext { V M/ k; @$ ~, i
position:absolute;
! R2 R0 `' ^3 X' Pleft:0;
5 M0 B7 {5 U, C, N- Rtop:0;( E' M3 L0 U8 b1 w3 w6 E
visibility:hide;
$ B$ z! w( `4 g) o/ c9 P: z# mvisibility:hidden;
5 h: k! w6 }) r7 _% A, _) `}; d s/ j* T1 ^! z6 a
</style>6 n+ P5 f0 I5 ?" q8 t
<script language="JavaScript1.2">3 m8 }0 f; s, E$ Q/ b7 l6 P5 W
<!-- 改变下的字体的大小。颜色-->( C; A8 `# S- e9 M6 s
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* c) g2 ~8 _# ]. a$ _7 c' r# Yvar hidetimer='';
' z, K: J% k8 h) {<!-- 改变下的弹跳速度-->
4 ?' X% w: U; ^3 s( @var BallSpeed = 20;/ g6 b9 j8 \& \$ G2 \
var contentWidth;
, M4 O [) A- Yvar contentHeight;. P4 w3 T& W9 C: f. h& ?
var maxBallSpeed = 50;5 j. d" U& d9 m6 g! g- {) S
# G. W0 W1 Q. p6 o: X# K. v( n
; ~1 ]* ~4 {2 R4 T) M. bvar xMax;
! S$ b1 `" Y) x( yvar yMax;
% `; M* X( O! C6 ^/ Q# tvar xPos = 0;
% b, R' T9 x' Fvar yPos = 0;7 H1 N o& C, c
var xDir = 'right';6 p9 {% P$ Z* _; W2 s
var yDir = 'down';, F, o |0 O y L- G5 g* E
var superballRunning = true;
; D. y1 p; Y6 ]' o8 ?var tempBallSpeed;
/ i) b( \" D/ I" rvar currentBallSrc;1 x {2 U8 L5 q
var newXDir;
% G8 K i) I; f+ Mvar newYDir;
- }7 b4 Z) b: G) N2 O. E5 j$ y. q6 J$ Z q6 e
function initializeBall() {
: L0 p6 ]: c$ ~0 H if (document.all) {9 _; v# X. R4 y( L1 k+ O% H
xMax = document.body.clientWidth
" s! ?" h$ s: a0 C5 G# ?: a yMax = document.body.clientHeight% h" N" u" P; c& d' J" w
document.all("supertext").style.visibility = "visible";
9 M& s7 g7 _& a: l+ C contentWidth=supertext.offsetWidth
% O- Y0 ~2 {( A. _0 m) Q" ] contentHeight=supertext.offsetHeight
: F5 W% b% w& O) j2 z; }8 m @ }: g! R9 }9 v5 G* s+ F) ^& Y) c7 l
else if (document.layers) {
0 r- @# z7 q/ e3 O# \6 @ xMax = window.innerWidth;, C g8 a/ ^" R7 Q% a8 W
yMax = window.innerHeight;
* X1 q* o+ e( @ contentWidth=document.supertext.document.width
' }! o6 j8 k- w" j1 i" J8 V contentHeight=document.supertext.document.height
r6 n( s' M! a: V+ b8 R document.layers["supertext"].visibility = "show";) e7 j5 G# o, r0 ]% A/ N5 t
}
6 I# [5 m9 t D, T. N7 A' b9 k setTimeout('moveBall()',400);
: Q) {) ~2 m" [3 W4 u" n if (hidetimer!='')5 E; D7 O; s) Z2 @/ V( l* Z
setTimeout("hidetext()",hidetimer)3 y4 x2 O6 _# ~- t6 y) Y/ O/ S0 D
}
9 ^) j0 l/ [, M Y1 j1 ~2 P0 ^9 N+ c* E. I+ Y2 x4 ~
function moveBall() {
$ ?8 N6 h- H/ W# |2 _; Q" c. w; k if (superballRunning == true) {1 Y3 n+ i# l. @4 w; K" Y
calculatePosition();
5 A: S1 m+ D. @0 m6 R6 X if (document.all) {5 h9 j2 j; @: `$ @; i# F1 }
document.all("supertext").style.left = xPos + document.body.scrollLeft;
& s3 S+ H* ?5 |! j8 _8 w9 g) O document.all("supertext").style.top = yPos + document.body.scrollTop;- p' z, ]% o; R" K* r
}
* D5 g3 ] M6 N; ? h' b: I, a else if (document.layers) {; ~( u. [5 c) J+ N
document.layers["supertext"].left = xPos + pageXOffset;
2 `7 Q& Y& m- Z! I6 K6 d6 d& n document.layers["supertext"].top = yPos + pageYOffset;! `2 e7 N& ]: B0 \& x$ e
}# h! B* C) l" V8 N Q; K: v: E6 w
animatetext=setTimeout('moveBall()',20);
! h+ U" c5 H2 G5 a' ~3 H; q }
* k. _; X. P, K: ~' o }( b) D$ f: G$ A( i! Y+ `
* t' A" q3 n5 E0 [3 qfunction calculatePosition() {' i" S0 h9 E% I
if (xDir == "right") {
1 c6 Y7 e; Q. i' h1 |2 G if (xPos > (xMax - contentWidth - BallSpeed)) {
3 r' c" S/ |0 G xDir = "left";
2 Q* A, l; `4 E* x/ C$ Z" h }6 a S: z8 R2 |/ t
}
- R$ q6 I* M4 U$ } else if (xDir == "left") {
. @2 }5 Y; \( q1 T8 P$ n if (xPos < (0 + BallSpeed)) {
x+ Y# b+ n& f' Y+ E xDir = "right";( D) F8 `; z% g/ P7 D
}$ ?1 d/ M2 _2 ^
}0 t: R' c0 [# p! Z5 M; F
if (yDir == "down") {" V0 C7 v7 h7 f
if (yPos > (yMax - contentHeight - BallSpeed)) {
& b+ c1 I; Y2 y' N7 Y5 Q yDir = "up";
) t2 v4 w, Z+ R3 @5 [2 \: | }3 x% s: r7 O' F* z+ X
}
% ~: ^; h; w4 ~ else if (yDir == "up") {
$ y9 s |8 T$ E2 A4 A( m* C if (yPos < (0 + BallSpeed)) {( j, F+ k4 g m) _2 f6 m
yDir = "down";- ~7 c d! M+ _( ^4 p! Y2 W% q, o
}
1 s% \' B! l: N T; E }
3 B/ v- ?. ~( n" ^ if (xDir == "right") {8 I& r' ~$ y$ h+ _" c% F+ L- z
xPos = xPos + BallSpeed;8 b8 Q& b. v+ `0 i* w3 q- K; q* L# R3 c
}
& l1 \! J' _2 Y/ F else if (xDir == "left") {6 R+ f2 P; X$ r, q) Z
xPos = xPos - BallSpeed;0 r* u \8 V6 M9 U# W7 W
}" u4 M: w5 K* E) J+ ?
else {* [( ^* ~$ U$ e$ Z' ]
xPos = xPos;" H: e) M0 D8 R
}
G0 \5 ?* i% n+ v! m if (yDir == "down") {6 k) q8 ]$ _+ l. P6 i# e8 T
yPos = yPos + BallSpeed;
8 j }' @! s& f* p& Q }; {) ?( _! m$ V/ \
else if (yDir == "up") { u0 B3 }# o! a2 e# c" E4 t
yPos = yPos - BallSpeed;. m, |8 { i* L
}! I, E5 \* e% R! n6 _8 z0 D
else { E4 G- P' U8 D- i
yPos = yPos;/ V& c- A) _3 J! b7 }4 m5 C" k6 Z
}2 n2 m9 M: y& n8 S: }
}) ~+ s# [7 o# B# ?( P$ A& _
& [0 c) H) u( m& Z, h/ ~# a) }! L
function hidetext(){+ \, K# h" Q p
if (document.all)+ c( n7 n: N6 i7 S/ b) O$ n
supertext.style.visibility="hidden"8 B) t$ O3 Y% b+ W4 ]* R3 g
else if (document.layers)3 v9 ]9 P( B# M8 j
document.supertext.visibility="hide"
8 F: J* Y" f9 Z+ ]% l3 S& j# O6 i. JclearTimeout(animatetext)
3 T9 W q3 C) j3 g2 |}
8 k/ n: ?3 R. J$ m& ]; r" K
) X6 g( R2 L( }3 d3 b, }* mif (document.all||document.layers){
" e: _. ~' ^4 z8 c, adocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 U0 {* Q" w2 N: J
window.onload = initializeBall;* i- E" D: A4 }2 f
window.onresize = new Function("window.location.reload()");1 w7 Q3 f+ I% m. J5 t6 p$ |) o" j& E
}1 y/ l, V2 }0 L, E" ^ m. d% r8 C- ~
]8 }3 s( l( \, J8 n) x
</script> |
|