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

|
网页之不断弹射的文字-特效
<style type="text/css">
" y) w( W, O7 Z! z }9 O#supertext {0 `- K: s! B" \/ l$ n$ H: |$ T
position:absolute;
, ]2 V9 F) Z7 Uleft:0;
* L1 b1 M/ w& N' M% Dtop:0;1 U8 l& I# Z* ` y
visibility:hide; T7 s: R4 E9 H
visibility:hidden;
6 s4 h0 d1 t1 S2 V$ y) f; ?% ~}) c( D% \, J9 e
</style>
/ o, F3 S1 Q9 L9 g8 A; m! j; v<script language="JavaScript1.2">
: _: s5 p" K. V7 a<!-- 改变下的字体的大小。颜色-->
$ x! s. }: F/ B/ u3 v3 Hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% X4 A- V+ L) V
var hidetimer='';# l& z" w. _; l# Y) S6 q: {
<!-- 改变下的弹跳速度-->5 e: }1 C2 z* ?+ u3 G
var BallSpeed = 20;
# Y( |, }+ {! P: L9 _: D& }2 [var contentWidth;2 `& ^6 s+ | p9 G. n9 |# X
var contentHeight;
2 s% Y H" [+ x4 M: W$ x2 M; d6 svar maxBallSpeed = 50;! }3 d, C7 h: v; N' }
. O5 C6 N/ e2 y2 b% W3 g
; I# P- |1 O- Z, \# U% e. w/ G& f8 Y
var xMax;
x& l" C! `3 E6 ^var yMax;
8 Z2 m# G O* G5 F" A. Uvar xPos = 0;
- r: c: l t. D' s; X U5 g$ rvar yPos = 0;9 a7 W6 M1 @2 c1 W( I: t/ {
var xDir = 'right';5 H) b1 r7 o! k# t
var yDir = 'down';9 \) }! B! N: d- J
var superballRunning = true;
4 e3 Z) ?. N1 }var tempBallSpeed;
. }% N% L; ]' R6 F5 ovar currentBallSrc;0 Q0 y9 m U; }7 B7 ~' ~6 J
var newXDir;5 E4 u- B5 v5 `+ q9 T2 e
var newYDir;- _7 u% ?5 G4 Q' x! A9 S, u
f7 C' `) A! J4 S4 {7 W8 Jfunction initializeBall() {
, k6 a6 g& h! A& _ if (document.all) {6 U3 i1 h3 E8 A' k4 r
xMax = document.body.clientWidth" x f( K4 d4 C1 a! O3 e" I
yMax = document.body.clientHeight
$ P1 q: @; C/ d document.all("supertext").style.visibility = "visible";
$ {. s V* v" q2 Z4 p$ t/ v. d contentWidth=supertext.offsetWidth9 K& L/ Y& w4 @" X$ b' L
contentHeight=supertext.offsetHeight
; m0 P2 Y' @5 S4 [! D }- c! c% o9 A: w0 b5 K. ?7 \2 o! P6 O
else if (document.layers) {/ y; M, W. r1 y4 L. ~
xMax = window.innerWidth;* c8 H% O# V. v( \7 V
yMax = window.innerHeight;
+ S. J4 l- Q+ B3 q contentWidth=document.supertext.document.width
/ _2 q4 G( N: ?2 B contentHeight=document.supertext.document.height. z" f2 H% d! C/ Z
document.layers["supertext"].visibility = "show";
3 q6 l4 V: E) O7 L+ B6 O7 _ }
/ A$ r* _8 Q5 A4 R setTimeout('moveBall()',400);: s! R) |* j, J, j
if (hidetimer!='')
: _ g) j/ u4 r$ m9 J setTimeout("hidetext()",hidetimer)
5 H/ K+ }2 I" _3 A3 \4 k! v2 _% z }/ T# G; H+ A" g8 `% d3 i( C
+ A3 }) M3 J" m. p* [' n4 W% kfunction moveBall() {
1 H( u g8 {7 l2 b if (superballRunning == true) {
' V r3 l) ], `7 P9 \& R calculatePosition();$ [3 d* p& L+ U0 D
if (document.all) {: [, \3 x1 p( T8 [0 l
document.all("supertext").style.left = xPos + document.body.scrollLeft;# Y( H/ [( g. N6 m: P( v( _
document.all("supertext").style.top = yPos + document.body.scrollTop;
$ L6 y0 o6 E# F X) f }
" M3 ^- o' s: v( G3 Z" P$ [, U) y6 \ else if (document.layers) {/ R: C, f, g/ ~, W% S+ U) A
document.layers["supertext"].left = xPos + pageXOffset;
* e$ f% J9 D# Y$ z4 ?; S) H document.layers["supertext"].top = yPos + pageYOffset;
# I9 I3 u6 d N. \% t+ { }- d1 [( C0 L) |2 T- C' q
animatetext=setTimeout('moveBall()',20);
& \$ d# i ^3 [) l+ N, u0 C$ l }+ s) m' t6 R, e* ^: g$ E P
}
4 I1 l+ ]8 [$ \- |/ {
" S% d8 q( q6 D% Z" s8 ?6 Hfunction calculatePosition() {
3 E3 F7 Z; Y3 v if (xDir == "right") {
* O6 v- w% G* P( Q! A; `5 T if (xPos > (xMax - contentWidth - BallSpeed)) {" K. {6 z0 l% T) H7 B8 }- k2 O- p% N
xDir = "left";
- |- |3 i; C3 m' a1 S* g9 x }( G+ c: L' b. Y, G
}* ~ s0 S4 e6 Z3 u6 n
else if (xDir == "left") {: s/ x0 l( V- r2 u) a- |5 Q' S
if (xPos < (0 + BallSpeed)) {0 }$ G; S- C, {5 u2 A+ O
xDir = "right";
! U: d% R3 x( V: U }, j _% G' ?* g# w8 T
}
# x9 p1 G! t: Z; Z& J! K& Y' } if (yDir == "down") {0 L0 _ v# h$ v7 C
if (yPos > (yMax - contentHeight - BallSpeed)) {* h4 t9 L1 _4 K; _9 l0 p
yDir = "up";
7 N' G& C* x* p: \1 X% v0 s% O6 u }5 J6 C7 p6 ~: t% F5 c) Y
}
% p; V% w# e3 G% J" `; k. ^: g else if (yDir == "up") {
9 u1 e. J* b" A+ v if (yPos < (0 + BallSpeed)) {
) @" Q4 N) [- N# z1 j% x yDir = "down";; D- ^% f" {9 R' Z
}8 ~5 O" G- B1 ]1 t5 X
}
; H6 W7 w) d4 ~1 r, X if (xDir == "right") {
8 }5 l& o# p9 a6 E xPos = xPos + BallSpeed;2 o* d( l- W' a
}) K* G% [) E9 p, K; P3 b
else if (xDir == "left") {
) p7 q- J8 c- {. l& b xPos = xPos - BallSpeed;: O/ Q; E1 |5 L
}8 ^- l. V1 N ^+ l
else {
" X$ `' r p) Y xPos = xPos;
+ ~9 `) k/ I7 g/ T! a6 p" M }
1 T* i4 l2 O5 F6 h0 F8 ?/ U; Z if (yDir == "down") {; {" t8 V$ \# H: y# a- x
yPos = yPos + BallSpeed;) P4 x( G% L1 H
}
6 ~- D9 b& n# r1 B% b7 d. X else if (yDir == "up") {
* ^! t" s1 o5 O1 O7 g. h- N& V yPos = yPos - BallSpeed;1 y* _. N9 x! J$ e/ ~3 k1 [
}
' l: A$ }, Y. I5 E+ z/ z else {, O" G& M0 T; L4 r% R- i
yPos = yPos;
2 ~. _ E" v& V; f {. F) Z }0 w* a3 u) O1 F+ T6 G) V4 T2 b
}8 `5 O0 C. m2 W
' K: o# a8 P3 c: y3 \/ t! @( {/ l( x
function hidetext(){
0 d2 k: a) G7 k" |. {- p& E, j a. xif (document.all)& G: f; a0 _0 {3 F# N
supertext.style.visibility="hidden"" I- H3 A$ @9 R u" s- _, V2 p
else if (document.layers)
4 q! S8 R! m( M' rdocument.supertext.visibility="hide"
; g0 ?/ J1 F( n$ l: N) mclearTimeout(animatetext) L! h) d( d* m4 ^( Y( n8 Y
}
0 a4 s* V8 w. B- r2 q& L( q$ s1 T
, v, A/ v! c/ E$ mif (document.all||document.layers){2 I, C$ x% W1 F6 m) ? _- R7 W
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')( o6 k: |2 R8 F4 D7 @
window.onload = initializeBall;
E4 ~6 r3 C' Kwindow.onresize = new Function("window.location.reload()");
* }4 @; U$ B: W' Y}
q! y! `) J/ [+ i0 L/ E9 `
- q6 Q) \) g3 O2 |" j$ y</script> |
|