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

|
网页之不断弹射的文字-特效
<style type="text/css">4 _5 |; ?- R9 O3 R3 W$ n; z5 h3 N
#supertext {& ?# \7 o4 |/ L% Q4 o
position:absolute;
4 Y- d! C# Y0 d5 |, `8 J# ?# Tleft:0;
; Q' U: \- ~) Q; |6 d" Atop:0;
, `4 N. R$ H$ a G# w; D0 y: fvisibility:hide;9 J- r) N" n1 ^! i6 t7 r
visibility:hidden;
- J5 i9 n( M/ O' s}) o# ?# f8 q9 b# ?3 W: K
</style>, s" H! y# L1 g4 N: K: Z
<script language="JavaScript1.2">
( ^. A+ W( j" t9 k6 c, J- q<!-- 改变下的字体的大小。颜色-->
% [$ |. w6 q+ k9 K% V3 N# G4 svar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) B* ^$ B% y o6 K3 Yvar hidetimer='';
& O/ N+ V& e, T D<!-- 改变下的弹跳速度-->
. k3 S, y( w9 ?; n$ N" m: n; Q4 Lvar BallSpeed = 20;2 @0 m; Z2 q2 L, S" F
var contentWidth;& n. X$ ~1 Y% e8 Q ~# ?
var contentHeight;
7 h; n7 \ y7 l* m+ R4 gvar maxBallSpeed = 50;
% H: B' @5 v$ a& `8 s5 U% T6 I8 h2 n6 b4 Q* A
# q) J# U: N: {9 E/ @. X6 Y# bvar xMax;4 F' P# H) a8 d" i# k& U
var yMax;
+ f6 F/ Y1 J) Fvar xPos = 0;
+ E S+ f! L: ~6 evar yPos = 0;
# ^ b' @/ f! s( ?2 jvar xDir = 'right';
3 o2 i2 }* K) y6 S0 Rvar yDir = 'down';
2 [& K' h9 d- h" r W" P$ s* nvar superballRunning = true;
) S) [0 \ q: K+ T' v/ w& S# c, vvar tempBallSpeed;
3 s' Q9 R: e) n( ivar currentBallSrc;
* ]6 @5 F# _. W9 Rvar newXDir;% q; I4 W8 Z; @9 [! r, a% |, |
var newYDir;4 d! D, k- k: H
9 ]0 X/ U1 H( J2 V, O) B1 `, X
function initializeBall() {
# j6 f- K9 ]5 V* K0 s( Z* ~ if (document.all) {; l/ V$ C5 H7 l6 v
xMax = document.body.clientWidth2 v* ? T7 P( a/ `
yMax = document.body.clientHeight
L8 _. ~" M* W" G! W document.all("supertext").style.visibility = "visible";- s1 G$ Q2 B5 n1 B C3 ?, [ w
contentWidth=supertext.offsetWidth
" ~/ _3 `: _ P# Y8 `$ q contentHeight=supertext.offsetHeight
3 s# T0 |, ^9 Q3 s# d3 K3 j0 R }" n; d8 B4 {& Z4 H* h
else if (document.layers) {
' v- h# X$ \( o! t9 V8 Z7 m xMax = window.innerWidth;0 y5 v* m/ e0 y0 l; Z, N$ K
yMax = window.innerHeight;
) W( w+ s1 h0 X! } contentWidth=document.supertext.document.width" a1 j5 {0 w% _
contentHeight=document.supertext.document.height2 r; m$ J/ ]( n9 ~
document.layers["supertext"].visibility = "show";
: O# e9 J, k6 g4 [, Z }9 t( J/ y- ^6 q. M
setTimeout('moveBall()',400);
7 |( h+ Y/ z/ C) P8 ~2 @7 y if (hidetimer!='')
. n/ D, S8 o" K a, I, P- z setTimeout("hidetext()",hidetimer)+ i3 C! j9 L, a+ f4 R
}
1 B& ^8 y# G; T) B9 f9 D
; b$ x6 q3 `& F' Afunction moveBall() {
1 D" w7 v$ i; |# ] if (superballRunning == true) { s9 ^0 N# a3 L0 ? Z! i6 I
calculatePosition();# B; m, H2 G! S3 ?+ l' X2 T- f# Q
if (document.all) {
6 ]% |( a9 t6 `1 v document.all("supertext").style.left = xPos + document.body.scrollLeft;& F6 S% c2 Z+ ~7 d- G6 w% C
document.all("supertext").style.top = yPos + document.body.scrollTop;
! u. J) M l9 r: N1 r }% y" \ g0 L3 f& ]0 N G3 }
else if (document.layers) {
% u2 Y3 }- z' W% L, s' E7 x: N9 ` document.layers["supertext"].left = xPos + pageXOffset;
& V0 T# J7 Z9 o6 }$ A( U4 ~! u document.layers["supertext"].top = yPos + pageYOffset;/ v7 h7 ], {8 v0 H" C
}2 A2 E1 Z) @3 q4 v% w
animatetext=setTimeout('moveBall()',20);
7 w% [. e& A7 ~7 r3 V* l }) {; h( y9 V; y/ @
}. g- S% G& \. E" \$ s
+ r% y. R% E0 J% P8 zfunction calculatePosition() {
6 g2 V7 W* W# S, f* x/ ?5 T if (xDir == "right") {
3 W, u3 u7 N+ E# O& @ if (xPos > (xMax - contentWidth - BallSpeed)) {
, b+ M& b, Y. J* L4 x" H xDir = "left";; f; u& c4 l* u3 j4 V7 s% v8 e
}9 M$ a8 V3 B9 y2 P9 m
}1 l8 l' B6 ]+ ~; L. W! t
else if (xDir == "left") {; K) l. o9 `9 N. [
if (xPos < (0 + BallSpeed)) {; O( B; L1 F; X+ w2 D4 F
xDir = "right";+ W# l* H- R% x( E
}
1 m; A* A$ l2 a# C$ d* ]% e* M+ y }* C' Z! Y1 d7 o4 [
if (yDir == "down") {
! A6 h. u& P9 H if (yPos > (yMax - contentHeight - BallSpeed)) {
5 G, n( f9 `" }; `2 t$ ^: G2 N* Y yDir = "up";1 b5 A3 s0 p u3 z$ h \- k
}
6 S# _! o! w+ {% W' p8 z+ E, T }
6 C/ G9 A: k" x$ `/ q1 b. r else if (yDir == "up") {0 s, N& a: k6 j1 b4 m( r
if (yPos < (0 + BallSpeed)) {
* S: l6 K% ~9 C' ` yDir = "down";7 z1 U8 n0 k& f' y& F
}
% K( Y4 S) r5 w- ?) _ }1 `! T/ d3 X: n: a: P
if (xDir == "right") {
# \ Z( T9 K y" h! F" p xPos = xPos + BallSpeed;
8 T" Q# @! G, z- D1 ` }
* N. ^3 u" D/ Q+ ^; y5 X/ C else if (xDir == "left") {( ^0 t* [0 y6 Y3 I1 |
xPos = xPos - BallSpeed;! t7 a( c% ]7 X7 N* v, e& S3 S8 H
}, l5 u+ U4 x! Q! V; `/ g" k
else {
! X! W1 n6 [# S3 Y xPos = xPos;$ C* H/ [3 u' n' d0 u
}
& M4 q( @1 x# h: R: q6 p, o if (yDir == "down") {
2 h5 T$ U8 j# h& y& k yPos = yPos + BallSpeed;
8 ~7 W& F& x! B$ a. ~$ ~* a8 Q& P }
# s/ S, x8 P' I% H# k) V& }4 p else if (yDir == "up") {, ~; O p- |% s( A( a0 {
yPos = yPos - BallSpeed;
, |# ^# L* f: u# m T7 E% j; H }8 J A$ S* D' S( L5 C4 U5 ?
else {* t, I+ [ r! f, Z1 x$ J2 _ X. k
yPos = yPos;
* h6 N& {8 {2 v, a4 C }
" [8 _5 m4 ^/ A$ N1 s T }# D |% E. A$ w9 g2 I
8 b) Q7 H/ B5 v C) C' d$ Z- ufunction hidetext(){& ~ `- [: I. X1 E3 o
if (document.all)
6 S H) ~" O* R& o8 Asupertext.style.visibility="hidden"
3 G- v/ T3 i' q. _* C/ Nelse if (document.layers)
/ s8 {. Y* V, s1 v/ adocument.supertext.visibility="hide"! |* ~' N! y% a5 _
clearTimeout(animatetext)( ^* f2 Q. s- v8 f! c- ?
}
* V! B2 m0 S" [4 g: g: Q0 K! Q9 T1 ^
if (document.all||document.layers){$ H/ K: ^2 ?& x& L
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
+ [0 g2 ~; g3 ?& h/ N- bwindow.onload = initializeBall;
9 o, ?7 {. V& H' L+ g4 Bwindow.onresize = new Function("window.location.reload()");
$ L. N0 y* y% \2 x5 r}
9 m7 [. v" p* y+ x) Z: s; o
. {" k# q" ~. n$ N</script> |
|