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

|
网页之不断弹射的文字-特效
<style type="text/css">
7 ?! G, \0 ], ]7 u#supertext {# d$ S" v l) W% R
position:absolute;
. t0 L1 t5 d% Y9 I- g# ileft:0;
2 I$ p+ ~6 P7 w! Y, V0 Mtop:0;' O; h! F" ]$ T6 Z2 D7 m3 F7 V; [( }
visibility:hide;
4 ^7 r. W+ _9 o- a+ Tvisibility:hidden;/ {5 g" s* b0 f( ~
}
5 K; F6 A7 K0 v3 l2 C</style>
! ?: o. v9 p4 y: a4 o4 c- p<script language="JavaScript1.2">. {. _4 c# s# V9 @* b e3 M' J
<!-- 改变下的字体的大小。颜色-->* b1 o% w/ x L7 S6 u% K
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ P r- Q$ A: j5 D. [; N
var hidetimer='';% J" x; F: ^) _$ y
<!-- 改变下的弹跳速度-->
3 J: ^* I* F. `* {/ H4 v% b- avar BallSpeed = 20;
" O7 e3 U, d! Pvar contentWidth;& a2 U6 Y4 x( j/ Y6 j7 g
var contentHeight;
' j- E) @, A' z. Yvar maxBallSpeed = 50;$ _' L) e; N/ j: t! ~3 M4 x9 v
5 y( N H* _3 \ K
9 p9 E4 W: G2 j$ |3 R F
var xMax;' ]1 ?1 i5 W* F9 W
var yMax;
& ? O2 N; e5 D+ J5 y% V+ f4 \$ P& ivar xPos = 0;" ] F& n$ \& | @
var yPos = 0;: _; L$ J) Z8 h! P% [/ H
var xDir = 'right';
: _0 T( S% w% nvar yDir = 'down';
8 j4 @( m5 j5 w6 ^var superballRunning = true;1 W" B W" y% B0 [3 o
var tempBallSpeed;
% J) ~0 p. `: C# Tvar currentBallSrc;
6 U6 z+ Q9 W7 q7 ]" a2 ?3 uvar newXDir;
2 b, S, S: x& Tvar newYDir;; g1 B8 z( ~: L2 O/ i5 z
* M7 d e9 A' m, K/ G. {function initializeBall() {3 b; S* x4 _8 F, E0 ~" I' {
if (document.all) {3 |* V, ~# y4 R) Z
xMax = document.body.clientWidth: J1 M) E1 Z7 m& ?1 B" G
yMax = document.body.clientHeight
& ?% ^+ ~" @/ X. \ m' d2 W$ ?( k document.all("supertext").style.visibility = "visible";! Q- p9 A, n, `' h
contentWidth=supertext.offsetWidth* j; z8 T& h5 j- w q
contentHeight=supertext.offsetHeight
& e: W0 P* F0 \ }4 t4 L' A( B# b. u/ Q( t& u
else if (document.layers) {
) D L: [) _/ d: j! e5 w xMax = window.innerWidth;
0 D4 Y" R; z/ z4 e* z& | yMax = window.innerHeight;
. y/ f8 q1 z8 [! T, u3 Z1 x contentWidth=document.supertext.document.width
) b* \ j8 k* t6 S/ q6 W contentHeight=document.supertext.document.height) s; x, I' T4 `" Y. U
document.layers["supertext"].visibility = "show";7 a% F5 _0 R- o M4 \
}
* w5 b& P" T% I4 A; h0 y# E setTimeout('moveBall()',400);
& l: v. w, {3 R; _' f# k2 C if (hidetimer!='')
2 K. m, M; V @* i- P, R setTimeout("hidetext()",hidetimer)) s; ^; V$ q+ {$ L2 i
}
+ g! }0 y4 N( y7 o5 @% t* o+ Y, G6 d/ F) p& r
function moveBall() {) q$ g1 ]$ C S# D1 }
if (superballRunning == true) {: g5 H. y0 c8 \/ h D4 n1 c5 C
calculatePosition();* g! \# v* x: H3 Y
if (document.all) {1 F) T# b8 N3 Z6 p+ o. S; C
document.all("supertext").style.left = xPos + document.body.scrollLeft;
& y% K" P% M6 [, E document.all("supertext").style.top = yPos + document.body.scrollTop;" S4 `7 B3 ~* d' _
}
1 L7 t+ W( }! t& ?7 t& B8 e else if (document.layers) {+ m1 L% H& o3 S9 i! P' L% b
document.layers["supertext"].left = xPos + pageXOffset;
, p8 m4 s5 Z- K% A' m8 F2 q& T* | document.layers["supertext"].top = yPos + pageYOffset;
. e- E6 R, ^! @* w7 s0 e }, q+ p- R3 `7 I; P5 f% U% @
animatetext=setTimeout('moveBall()',20);1 P1 b9 H# E- _2 f3 H$ V1 E# U6 y
}
+ Q O6 m5 ]; a }
% s" X# I0 T+ E
6 t8 k9 f; w1 H* o1 |function calculatePosition() {
0 n* `3 Q" n% W! R0 t if (xDir == "right") {
) e/ F2 ^ l! F2 |) @1 w6 A if (xPos > (xMax - contentWidth - BallSpeed)) {
7 ^4 B: h8 V$ ?3 l; q xDir = "left";
2 c g9 r- J- u) O } v/ C. Q$ L) {1 w. B9 r
}
8 y2 K S: C7 o- B/ |9 W/ l9 F else if (xDir == "left") {
- y( `) J* j& M1 Q if (xPos < (0 + BallSpeed)) {1 b0 n" W& T3 i; N
xDir = "right";
/ z; a- Q$ ~9 X2 M) { }$ J, j& M2 J' ?7 Z- I
}
; p- e3 h8 `: F- \ R' d8 m/ T- g if (yDir == "down") {
; D1 m7 H! k: y9 Z3 n S3 @ if (yPos > (yMax - contentHeight - BallSpeed)) {# s& t' u$ y \6 D+ s+ d$ O& t( U
yDir = "up";0 U) E' H- _3 [ a
}$ e* i; Z7 k. C3 A4 q
}" R: H( H g3 P9 B" g
else if (yDir == "up") {
) b0 c+ q! a! Q& e i if (yPos < (0 + BallSpeed)) {9 i* ^* Q/ U& W, l, H( K
yDir = "down";& c# [1 n4 u6 J2 i9 g
} m# Y0 l8 |$ T3 Z6 J
}
; a9 Y2 Y/ ^! \! F! ~9 B; j: I if (xDir == "right") {8 T. A3 M6 z" i I4 l
xPos = xPos + BallSpeed;) ^& i- ]+ b: E
}0 J9 n* V* |" s( i- R4 d) o1 r
else if (xDir == "left") {
) c, L1 D8 {3 d4 t1 i) ?! f' C9 u xPos = xPos - BallSpeed;- h! U; \. t1 A# ~& z( Y: ~8 B
}
( J( h! d3 ]0 g else {
. ]5 \; o0 {- ~% L xPos = xPos;# I, Z; S# a& \
} v' [# w' g/ Y) W* W
if (yDir == "down") {
0 A- P4 }: X/ @- t- j yPos = yPos + BallSpeed;: q. ~5 d6 u/ q9 v6 L3 |! a0 x& [ X
}. a& l, ?9 ~3 w
else if (yDir == "up") {5 l9 V- c5 z5 ^/ J
yPos = yPos - BallSpeed;
7 s0 M, M9 L3 G1 F }
6 R8 x T3 T* g' N% f+ h; { else {
% R9 C8 I- s2 S D2 { yPos = yPos;7 x* |0 n e1 M: a2 R9 N E
}
# q$ m1 {6 i6 s6 p. \ }
! _/ j. C' K: |
$ c7 E& N% o( s. I6 m$ E2 Wfunction hidetext(){
& S" R" F0 | e1 X5 P9 kif (document.all)
' q9 E7 x% |6 U4 f' Dsupertext.style.visibility="hidden"" b$ A, V5 d9 A& ]9 ~
else if (document.layers)
! F$ _8 _% T6 _1 L/ fdocument.supertext.visibility="hide"
& N: Q# u0 R$ pclearTimeout(animatetext)
+ G0 O* v, K4 Z# X5 m}
' |4 D4 O; z8 K8 \* n0 I: ?/ g& f# h2 D- ^
if (document.all||document.layers){) v! k& Y/ ~4 B6 |" k
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), D+ ]5 O4 f+ y8 R( T6 f) r
window.onload = initializeBall;
/ f; R' b, H+ l6 jwindow.onresize = new Function("window.location.reload()");: b' i$ ?, x& ^2 N1 L5 N2 m. V* J
}6 Q3 i* _% j Z! T2 z- b2 @% Y9 J: @
# @; H; D5 r1 h</script> |
|