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

|
网页之不断弹射的文字-特效
<style type="text/css">
& j+ i( v, M Y5 y, F' _" Q+ b" b#supertext {0 Y6 W) E# q1 K
position:absolute;
3 U" {- [. ?( W; z; V% ~+ vleft:0;& p$ y N( E; U; O! r! t* Q
top:0;$ d$ X9 q& B, z | [& z8 M
visibility:hide;3 {8 B2 C1 d6 f8 r( T$ o
visibility:hidden;
+ h2 L1 x6 g' i( W}) q' e0 w0 Z7 K2 G2 M2 D& W
</style>
- N, o+ Y7 e# K# v<script language="JavaScript1.2">, N4 Y- x) w4 u3 I/ S! p
<!-- 改变下的字体的大小。颜色-->3 T* g' q! v3 L# _* x6 V
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 }% z4 D% f. O2 }: S) M' O3 m' {var hidetimer='';
: v, S n+ P' V4 Q<!-- 改变下的弹跳速度-->
! D! k4 C" ?$ t6 Yvar BallSpeed = 20;
6 O8 @$ p, k6 Y7 avar contentWidth;7 p4 i! G/ I+ ?8 M7 T3 [- U+ k; K5 O" g
var contentHeight;
' v- \, ~0 @( {/ \& e* R' D3 ovar maxBallSpeed = 50;
% R. s. Z3 N& x( k% v6 I" z
0 z0 b" I. J- i9 Q! w# b! q$ }
# D9 o( q! e9 j, J4 `var xMax;
) d! H$ z' t2 W3 x7 u8 x6 Zvar yMax;* x9 g* h0 _1 }0 f8 ]% _
var xPos = 0;
' J6 K4 m# C: D9 U2 Pvar yPos = 0;
+ D: u& D$ y; I6 i- F0 d0 O% tvar xDir = 'right';
) t# @; b( z9 s( d+ W& Rvar yDir = 'down';
0 n. ?2 s0 Z% `var superballRunning = true;
. j) j/ ~1 c' |9 d" pvar tempBallSpeed;! E$ k/ j R5 d( p
var currentBallSrc;
$ F* `8 s1 c5 y6 L0 Nvar newXDir;
$ F% o$ s/ y' i( [' j( Gvar newYDir;
- W5 G# ]: ?5 ~$ w8 C) O5 v6 b5 z& U3 d! k
function initializeBall() {4 E0 G! h ]" K7 x5 v
if (document.all) {9 u D* [" f% C4 `! ^
xMax = document.body.clientWidth; V5 U& u* X4 A8 A# V
yMax = document.body.clientHeight
N, @: w2 }. D8 ^: g document.all("supertext").style.visibility = "visible";$ N2 H3 |4 M5 i# A; S2 c, a1 y6 ]
contentWidth=supertext.offsetWidth
1 r7 b: K, ^' V" x contentHeight=supertext.offsetHeight
- i( R2 K- l5 i) I4 z/ \( N# O( U' P }+ H }0 C1 l( b( ?( u
else if (document.layers) {
4 W6 x0 o% Z2 Y3 ]8 ~# D xMax = window.innerWidth;
2 s( w$ y3 Q2 y5 s& l, D& _ yMax = window.innerHeight;
' V3 v) s' E3 O0 W* { contentWidth=document.supertext.document.width
4 E0 Q, L. C8 g4 q contentHeight=document.supertext.document.height
3 K8 ~! r+ L' b document.layers["supertext"].visibility = "show";$ u L) w) P0 P# O) H3 d5 j2 Y) C
}
% H9 ^# m, |4 @9 U1 I setTimeout('moveBall()',400);2 L/ E' B8 f0 P& {8 w
if (hidetimer!='')
* J2 g- ?& ]) U+ U setTimeout("hidetext()",hidetimer)
' _: [4 d0 `3 e" L1 z; W }
9 Q' `+ H' s7 i, D2 j# T
9 b' e0 y0 y5 h' u! V2 y8 }function moveBall() {
1 {3 B6 ]" P4 N1 i% H if (superballRunning == true) {4 u# m: k% O! o( j) q. [! a3 O5 W1 H
calculatePosition();, _) A6 U6 |1 M/ d! U. V
if (document.all) {1 T0 p. S1 C9 v
document.all("supertext").style.left = xPos + document.body.scrollLeft;! K0 ~) e! H7 P/ B/ O
document.all("supertext").style.top = yPos + document.body.scrollTop;+ V6 y3 l2 r5 `3 u& ]: q; g
}
! M" c% _+ t4 K- I: p else if (document.layers) {
6 @% B+ w" i( O ^ G document.layers["supertext"].left = xPos + pageXOffset;
6 {. @* E/ ~5 c* M! M document.layers["supertext"].top = yPos + pageYOffset;
/ W( K# J5 u- ^8 q. b }0 ?7 }1 E' b1 t9 E" D+ Y8 z, O$ _
animatetext=setTimeout('moveBall()',20);
7 p/ _0 Y- o% b5 ] }
0 W G% [( X/ n8 x; f4 E* ] }
: m/ d/ U: o% y8 q5 L; d+ [* ?, u5 B8 q5 r
function calculatePosition() {3 B* d. `0 n4 |7 B X
if (xDir == "right") {4 X; i) K; z, @, A
if (xPos > (xMax - contentWidth - BallSpeed)) {
2 u7 Y( l% p' a$ U$ f* e- B xDir = "left";; p: s- b+ k8 w F2 V
}
$ ?" E" e6 Z( B! C* u/ ^4 |' U ? }( ^7 l% B* { J+ k: m/ y2 U* ]
else if (xDir == "left") {! _; F- j1 D9 ^) b
if (xPos < (0 + BallSpeed)) {
1 a: q' r3 c! H* p, M" [. Z xDir = "right";
# J6 N7 O2 [, n# x w1 K }
3 | b! J8 k& h# |, s: _$ L! J }
- P" ~" l/ x: l if (yDir == "down") {7 o$ c" v. m) X8 W: T0 l% u
if (yPos > (yMax - contentHeight - BallSpeed)) {
3 U4 h- {. o7 n1 M; E3 R V yDir = "up";& Q7 { q8 i7 K# l/ C8 R0 v, W. c
}
- z( `* i, s/ g* `7 p2 K }* A. ]+ J. K4 O( a. N
else if (yDir == "up") {% y- w2 i8 u6 A/ j+ t1 h
if (yPos < (0 + BallSpeed)) {1 P3 u) o, y8 C4 c- [; \
yDir = "down";* j7 _) Q8 h1 l9 V6 k5 r- z, U I
}
/ G! z. C/ w. [+ f/ I4 F }8 j' W& ?" ^. }8 |* k- H- n
if (xDir == "right") {
# l& O( s% [, J xPos = xPos + BallSpeed;, C" E5 O5 ~, x& k
}! t8 G7 ? a, ^$ P0 M
else if (xDir == "left") {( B) e" O8 H3 W y! i- M, G
xPos = xPos - BallSpeed;
]" n! x) J$ I2 s6 D/ U4 } }
- D4 q5 B# W& i8 S1 ^ else {
# ]/ k" f# v! }2 ~* g4 X xPos = xPos;( c9 P- I. u. ?% D; d9 X
}' j8 K9 G, V# i7 ~6 l$ j
if (yDir == "down") {
5 }9 _' @! S6 \( P! w yPos = yPos + BallSpeed;
3 I6 n, ]: b/ y9 y2 | }
( Z& w [! K8 _; w+ f ^$ H6 `. K else if (yDir == "up") {+ a0 q4 Y/ a2 r# f
yPos = yPos - BallSpeed;( A' ~/ q2 b. q% [) e5 I
}# ]. g; |+ Z$ l1 Y5 S! O7 k5 l
else {$ f# I6 g# H( Y' s$ \
yPos = yPos;/ ^1 C, f- W8 C1 I+ V+ o) O
}
" g" M% K) J; O }
% N ?1 o$ l/ w) L1 C V- `+ n. {2 k# X$ a# n" o( F, x
function hidetext(){
0 u! }4 a: u3 I$ y& m- X7 d, Nif (document.all)7 q/ W6 \, L# r( k' _' n
supertext.style.visibility="hidden"- H6 O; j* y* i( a( F
else if (document.layers)
0 M6 t0 S8 u" H! S. _% c: E" Ndocument.supertext.visibility="hide") ]5 q% ?( R V% \7 U0 j/ d' ~
clearTimeout(animatetext)
0 l) M0 `5 p, g) x}; T% B- A. Y9 k# @+ Y
1 @) h% J; T% H8 Y! Kif (document.all||document.layers){0 F, [) [) T$ @& H
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ e! Z5 d" ?, [# gwindow.onload = initializeBall;
5 T' K. J4 L) `: N+ kwindow.onresize = new Function("window.location.reload()");
" U5 b) I0 y' g4 u}1 ^& ]: f2 S8 g# f4 @$ i3 ] x
# i" Y1 [8 o4 B/ a9 U/ S
</script> |
|