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

|
网页之不断弹射的文字-特效
<style type="text/css">
4 G6 k9 F' ?/ a- Z#supertext {
9 [ c, O/ ^7 w8 hposition:absolute;
, E4 D1 J: w9 U7 Y1 Uleft:0;6 U/ f4 P" ?' x2 w2 ]! j7 l5 ?
top:0;
# J5 [1 M0 M9 L; Evisibility:hide;
9 {) c& U1 P) J% O/ W3 yvisibility:hidden;
+ w% i# p4 R( y! j& v& C# l}& S, ~& u8 _/ Z3 k( y/ h
</style>5 F3 k% x7 w3 _3 |3 N# Y
<script language="JavaScript1.2">2 u: o4 l( A9 P& T
<!-- 改变下的字体的大小。颜色-->
7 i) D( ~$ L) ]7 q1 T' o# zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
/ i. s# v" h- zvar hidetimer='';0 ?! V! X- [6 \& n$ f7 Q
<!-- 改变下的弹跳速度-->5 s( i" L! F1 t; T' X/ h
var BallSpeed = 20;
- J7 `+ B" ^8 K7 H8 U6 G' m! Kvar contentWidth;5 o% |- Y; Y8 i6 S" t8 b+ H" }
var contentHeight;
8 q7 Q( t* o0 C9 H" Qvar maxBallSpeed = 50;
3 Y' E. _7 P9 B
* P9 t# J" s7 T; w/ t, _ F. V; O( v- T# X- [% l
var xMax;$ k/ _% }2 [" C6 U2 Q+ N# P
var yMax;3 U0 O" O3 G" S
var xPos = 0;/ f- }3 W+ U: X: M
var yPos = 0;
8 M! a6 K+ |6 Y+ b$ }7 h( @var xDir = 'right';
' A5 g: J8 K$ T" g' j1 Mvar yDir = 'down';0 ]. j7 V2 a/ c" {& m
var superballRunning = true;
" v+ q# S6 o$ ?( W& Rvar tempBallSpeed;
; R, }8 r( i- j4 y7 J0 Vvar currentBallSrc;
3 k. K& U t# \1 t7 q5 Evar newXDir;
3 d8 h( R( s1 ]* g4 r' Vvar newYDir;
2 d% \6 B9 J/ X5 B+ f2 d: [; E$ y
: ^* R% X7 M+ mfunction initializeBall() {
C2 o/ n; d2 G8 l if (document.all) {9 @5 ~1 R9 S" m2 l! z6 L
xMax = document.body.clientWidth% s2 ~* G) B1 f# y5 u9 {
yMax = document.body.clientHeight/ X/ {3 [$ h8 s; K! K' N
document.all("supertext").style.visibility = "visible";5 G& X& k( k" ]& X0 i
contentWidth=supertext.offsetWidth
- ?) T) ?. m0 }, a9 v5 |& A5 b8 L contentHeight=supertext.offsetHeight* _, \: o& d8 ?4 |: I
}
" l$ L& B8 n6 O+ p: h7 z else if (document.layers) {# }& v5 V% q' R( K+ H
xMax = window.innerWidth;
- }0 R7 G0 O/ F& P yMax = window.innerHeight;
9 K# ]* }3 F. D* P8 ~: G contentWidth=document.supertext.document.width
& u* x0 Z5 P9 } g" K contentHeight=document.supertext.document.height% U' h( A( B/ G' @# q
document.layers["supertext"].visibility = "show";3 x$ @# K1 J: Z- V. X% s
}: q/ l2 x; x3 n2 Q- w1 Y
setTimeout('moveBall()',400);( q8 Y& X; `6 K' `
if (hidetimer!='')+ q" g# j, k: f& J m: l
setTimeout("hidetext()",hidetimer)' i% S+ x% U+ R/ F6 V
}
6 B2 y/ Q8 ~1 F8 S9 c5 Q" W7 I$ Q! K9 M* z( e* o+ Q3 z- I
function moveBall() {
& [. t& a* T+ V/ i V if (superballRunning == true) {
; R) S6 Z) B- ?( ]! w calculatePosition();
1 i. j0 M+ ~ t1 Z if (document.all) {- i' [4 {9 ^: Z+ d
document.all("supertext").style.left = xPos + document.body.scrollLeft;+ P+ N$ |& |/ O
document.all("supertext").style.top = yPos + document.body.scrollTop;
! V9 w; L/ q+ N6 ]* L- b9 X2 @- ?1 v3 N }2 y" S, F; ?9 k: O
else if (document.layers) {
; T: w5 G% l0 C, Z ` document.layers["supertext"].left = xPos + pageXOffset;3 ~( m8 m' @* {% m; {6 Z
document.layers["supertext"].top = yPos + pageYOffset;
& L( c4 a/ V0 W) O, [) ?" Y }
' E! v8 ]4 Z; `! O5 {) i/ w animatetext=setTimeout('moveBall()',20);
5 s( m+ `8 ]1 ^. M/ J1 ] }# g/ K' U4 d/ z: I" D% O
}" l. Z6 @. N8 n8 Y: ]: Z2 y- g
$ n1 _9 [( j; t' ^9 {" F4 j" i
function calculatePosition() {# q; w, |9 P' _
if (xDir == "right") {$ n: C& ?/ e, s: s( S
if (xPos > (xMax - contentWidth - BallSpeed)) {! f' i9 }8 i+ A' X. A
xDir = "left";
$ u* c& u f# S- S' O) B }) K0 H8 V+ P( C7 T
}
/ x! m, H; z# D1 q1 N else if (xDir == "left") {
3 V# v$ m$ q3 Z4 \% K5 c if (xPos < (0 + BallSpeed)) {
: [8 U5 G$ \# o! y+ J/ | xDir = "right";
2 M7 ^& X6 h |8 y+ z- o }
% [2 e6 v! i1 v9 }& _' x }: u2 a7 o1 q% A9 v: X# G- u @! W: U
if (yDir == "down") {
; c7 a, N d0 F$ @# w! l/ g if (yPos > (yMax - contentHeight - BallSpeed)) {
* E7 c. p) A4 U yDir = "up";
q1 o% @+ Z1 M J0 \ K }
4 Z1 m/ `/ K* Q& k& \$ j }
; P* ~6 r6 f' S2 b! f else if (yDir == "up") {( z# C; \. Y% K) h) e
if (yPos < (0 + BallSpeed)) {
. [. K* c/ }- Q# U yDir = "down";
* E( Z: w; N* K+ }. k }3 w/ P4 ^8 a6 x5 x( H. i
}$ ~4 I$ ^5 M& S7 | @
if (xDir == "right") {
4 K/ E7 M5 o& ^4 @6 e2 S! ], { xPos = xPos + BallSpeed;/ ]* P& S+ s; r7 Z# F
}
+ \. r. @0 d" f2 f else if (xDir == "left") {
; O# I8 g# o/ N xPos = xPos - BallSpeed;
# D5 P% a0 E3 o2 a `! T" | }: M ^$ ~$ S1 G+ _% V5 S5 R! q
else {) c% J/ k( ?7 S1 r0 p+ s
xPos = xPos;/ ~# B+ ?$ q! Y
}& P6 a. s1 m0 K2 D) d$ a
if (yDir == "down") {
' D/ a1 L% l% R- X/ @, j' a yPos = yPos + BallSpeed;
% S+ h% B" r0 i% {: r2 G5 Z }
' L9 U; {, _! D else if (yDir == "up") {. ]. d' d( G! z* e
yPos = yPos - BallSpeed;
8 v3 W6 ]/ q" y N }4 y6 C% p( J# ^4 h: J. q/ `
else {! w' ^' l" ]0 k( _6 E' i' I
yPos = yPos;
* ]0 c* I% J# V' I2 T# C }% k+ J7 R/ _) |# G4 h! ~2 ^* _
} a+ D$ r3 A5 e7 ^! A7 ]
& g/ ]3 x2 P( m, C9 {function hidetext(){
. y! t* B" a. j) t5 Qif (document.all)
; k) D W `8 I7 O: P/ C' h0 usupertext.style.visibility="hidden"
$ h! n: I, {! Uelse if (document.layers). L0 W" i3 k6 s) N) L0 a& F% Z) I
document.supertext.visibility="hide"
- ~: p: X* {, k) H y$ Q+ w2 B ~! o' Q# f/ }clearTimeout(animatetext). z9 A9 L% s9 ~/ U, Q
}% _# k7 B3 X0 p2 e* q& L& V
9 ~# [1 L& W; G" g5 I# E4 C
if (document.all||document.layers){# J4 H+ ?% g6 G8 J- P9 i& q2 P
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 C9 z2 _, d1 u
window.onload = initializeBall;
8 W) U7 ^1 U" y3 r2 Awindow.onresize = new Function("window.location.reload()");
. U4 _, {+ T" Q, m+ B) T5 W! d4 r}1 i0 p+ f, g, ?, n
) w9 C; m7 Y: I, v6 q+ Z2 k</script> |
|