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

|
网页之不断弹射的文字-特效
<style type="text/css">& `9 C" k6 p4 w0 P& Z
#supertext {3 i: s( e& T' _9 V9 r5 S" @/ c1 A
position:absolute;% H- A0 K+ O- X3 j6 }) l
left:0;: I7 o4 L' B! h' b- g" ]$ p
top:0;
8 ~1 d' k1 Z1 d h2 X. cvisibility:hide;7 U+ I: Z+ J; A; B% _
visibility:hidden;: d: ~3 N4 U3 G8 r1 b
}
7 ^% v6 @, a& ]# T( W$ W</style>
4 o/ P7 n2 P0 g6 O% }& g( ]<script language="JavaScript1.2">$ C7 c C; n$ v' @+ r, a# E7 s
<!-- 改变下的字体的大小。颜色-->! }! ~, `2 h" ~3 X
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
, I2 g! A; Z* `$ U O+ x0 z7 uvar hidetimer='';0 S: S, k9 s4 P# ] d7 G
<!-- 改变下的弹跳速度-->
! x3 w6 P; m. q E# F1 ~, tvar BallSpeed = 20;9 V( m% U! [/ Y1 L& M
var contentWidth;1 }7 m- P! Q5 N' |: q+ y3 `
var contentHeight;
/ T/ @+ J; V& g: E1 }( l: N$ ovar maxBallSpeed = 50;
3 ]3 \8 ^" V9 f( q6 G* n: X1 I8 }! q$ x+ c5 m! L) ?& T
7 E7 J6 M+ ]2 Z9 Fvar xMax;
0 \8 k) O; M4 D: \" a# ?# \var yMax;
$ m5 N1 h. m2 K- Y9 D! ~ Dvar xPos = 0;
1 J9 X, g- U+ r$ c2 w% a/ Nvar yPos = 0;
& l' w, L0 m/ ~8 d4 `! z2 qvar xDir = 'right';* b/ Z$ x- H0 h& K( q: m
var yDir = 'down';
* G8 z0 y/ `6 Y7 w/ m6 X$ ]var superballRunning = true;
5 a6 r4 c3 h8 f( ~1 C5 | H6 kvar tempBallSpeed;+ z! D: W$ b1 z' w6 ]+ q
var currentBallSrc;% x* P8 s& ?0 J
var newXDir;0 t' a8 x' E% o: a# X+ a
var newYDir;
! Q" `1 S! ~& P, ~5 c
! g# \5 t8 F9 \! T" W1 F) sfunction initializeBall() {9 @7 Q, b! @$ B; k+ L
if (document.all) {
3 P, s) z/ `$ \/ ] xMax = document.body.clientWidth
! t: j0 U0 V! U4 o/ w4 k9 A. R' e yMax = document.body.clientHeight
7 w; H" z/ i2 N! Y document.all("supertext").style.visibility = "visible";* @- J! Y1 E4 O# o8 ^' I1 k$ S
contentWidth=supertext.offsetWidth
8 W }/ p, E" n* K4 \ contentHeight=supertext.offsetHeight: o- b/ t6 i* t: M$ o
}5 E+ w' D7 `. B, w: L0 w
else if (document.layers) {
( B# Q0 i" U; M( X, ^" c, f9 l xMax = window.innerWidth;
" y! P. z) z, M2 @% s7 V( R! J) @6 V yMax = window.innerHeight;' V2 q, g0 Y7 I' z; a6 C
contentWidth=document.supertext.document.width
. G# q. d" S% h+ a9 x contentHeight=document.supertext.document.height- a. p' D' _0 l7 s: B z
document.layers["supertext"].visibility = "show";
) ]+ I, k. {1 a. a g1 I }
3 C+ \# ^* Y8 s5 R setTimeout('moveBall()',400);
' v5 x4 S7 C9 }) w& V# e if (hidetimer!='')6 K' O% N! B: z8 }
setTimeout("hidetext()",hidetimer)
0 H# ]# Y {3 Z: P ]. k8 L }+ p% ?3 @$ Q9 l) ~. h& a
4 L" ^4 {. ?0 d7 |- V% D. j) X3 jfunction moveBall() {
) f: T) q9 c& A$ {! M1 W9 C$ A if (superballRunning == true) {
/ f4 v9 c* p) `7 J9 x calculatePosition();1 K) D' F" v3 @; n) p4 |
if (document.all) {* W( C+ s1 p! c4 E0 z
document.all("supertext").style.left = xPos + document.body.scrollLeft;6 V& q& l5 S' ~# x. |5 P; l
document.all("supertext").style.top = yPos + document.body.scrollTop;; S' R {. V* {7 w4 Z
}
Z4 h4 \ F P* F$ p: B else if (document.layers) {
9 c& |+ c% K' F, V# t document.layers["supertext"].left = xPos + pageXOffset;
. ^" l0 K6 m; P1 J4 h document.layers["supertext"].top = yPos + pageYOffset;- [3 W# p! b9 w8 a9 d
} ]* X1 Z9 L( ]9 o$ {7 ~
animatetext=setTimeout('moveBall()',20);
2 R/ J1 B; i* C, d9 Z) A }
5 n! k5 B7 q+ P. H }
) }- z- N7 i; x) v* Z3 T
* L- m. Y, E! @* o$ \9 ^" }function calculatePosition() {8 Y3 m/ h& i- R
if (xDir == "right") {
g. K u5 _" e if (xPos > (xMax - contentWidth - BallSpeed)) {
1 v! w/ q7 Z F/ Z f8 \) }& F xDir = "left";
% n B5 ]3 }1 R% o1 D }
& O J) f& e, B$ Y1 i% [1 d }
3 S$ y: h; g3 u0 C$ Q else if (xDir == "left") {5 T+ E9 E5 z$ V, v6 q
if (xPos < (0 + BallSpeed)) {8 q& T( Q% b( V/ a I: W- M
xDir = "right";
2 n, S3 n% k( Z }' `. \0 r% Q( N1 X2 }
}8 Q* j+ B) _2 D1 p
if (yDir == "down") {
9 Z$ Z2 |* g7 u4 x# n( ] if (yPos > (yMax - contentHeight - BallSpeed)) {! ]( ?! {$ g; s# m% } T; {
yDir = "up";
N* ~* S7 o" Y/ g& Q( U }
5 Y4 r6 E. B; Y C) [. d# \ }
& _ l- B- _1 [* I" v/ F5 c& Y r else if (yDir == "up") {
9 I3 ^. R, e5 L3 d# R if (yPos < (0 + BallSpeed)) {
' M/ E; ~4 N+ N0 k yDir = "down";
/ g7 P; B2 g. X }
. ~+ O7 P2 q+ s }
$ H r j3 o' p if (xDir == "right") {2 p8 m4 r$ r8 M1 D$ \' m
xPos = xPos + BallSpeed;
) y# W1 @- e, u }, y/ O. u5 E6 a8 X/ s
else if (xDir == "left") {
" k- N+ x% v( z0 A# y xPos = xPos - BallSpeed;
: B3 `: Q$ f5 @& M$ d }/ O3 C) ^) t% i' O- ^& h9 N% Y3 s
else {: L* Y! N" L7 Y8 C+ P
xPos = xPos;9 M0 v; Q2 {+ Y5 H* Y# @
}
9 k1 o+ M! ~4 R' I if (yDir == "down") {7 M: C/ I9 n. y/ x# f1 _
yPos = yPos + BallSpeed;
+ a- H" ?1 J" m+ V4 h( F' T" O, T }% T* x9 d1 u7 y0 o
else if (yDir == "up") {8 ?( N6 d+ U Y5 G% q7 \+ ?
yPos = yPos - BallSpeed;9 a. j$ I/ W D* B: K
}
0 M& W+ u. ]0 t3 C% i' D else {7 L0 H% d. n$ x1 `- ^" @
yPos = yPos;
8 ]( Z- S; q6 u+ i1 ~1 K$ `; R5 G }
$ p H5 F' f; i$ ?; B1 C }
+ P; h) O# `- N, b. q
* i* Z% H( t) H4 K8 Efunction hidetext(){2 U! |* D% d& f3 r& z
if (document.all)
) d7 `# r) o, ?supertext.style.visibility="hidden"9 O3 i) ?) c- V3 O, k' t/ r& b4 i( e
else if (document.layers)( Y3 G' c1 M6 j9 l0 q8 D# d9 X
document.supertext.visibility="hide"
; r! y* x" ]- E6 I' Y3 D5 S; ^clearTimeout(animatetext)' L# ^: B! R- A8 Q& n+ Z- h0 E
}3 d; ]/ a9 j( U/ B
- ^! c: T6 l+ x3 T, L
if (document.all||document.layers){
: _7 i; s) `4 a# ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'); y% H! d! Y! O! ^9 A' A$ g
window.onload = initializeBall;, }5 n5 E7 G* l) J
window.onresize = new Function("window.location.reload()");1 {4 Y; C/ O& R) @; K( f) P: H
}& N& z) Z# B9 c" g* \2 [
6 X, K( s L1 h) J</script> |
|