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

|
网页之不断弹射的文字-特效
<style type="text/css">2 k- P4 q2 i4 Z, Z
#supertext {
; v+ ?4 ~/ s2 p+ H$ @position:absolute;
1 j7 M+ S* J4 X2 o: a* F8 v0 eleft:0;. |+ ]9 V4 p) K8 i- o
top:0;8 G7 j/ d: E+ e- _ d
visibility:hide;
4 G' F/ T; J! zvisibility:hidden;( Q# Z; P f9 B7 ?9 M9 m: g
}% y- L( N9 h5 z/ m, d
</style>
# _/ @, E3 R4 Y<script language="JavaScript1.2">4 v* n; a0 U6 \6 k& U6 u; z+ j
<!-- 改变下的字体的大小。颜色-->/ ^/ G1 e( K+ D
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' u0 {, F; z1 z% _4 r; Y, @- _var hidetimer='';
5 Z. }0 n8 x% }# f2 m<!-- 改变下的弹跳速度-->( @8 N/ J) n) n: h" [
var BallSpeed = 20;
" i4 e( [4 B9 F- W( j$ r+ cvar contentWidth;
) t8 g' R( w+ w5 N' L5 uvar contentHeight;
2 I0 T" m1 w( _6 ]- D; t/ D& Xvar maxBallSpeed = 50;$ ^+ H2 ]$ c- o+ ]; o% M+ }5 d" \
2 I3 p0 O/ _9 h0 X |" H
) f& Y/ j ]5 E9 a
var xMax;- h* ?4 y; U, h8 S) v
var yMax;0 G3 @* x# X- u4 L: C- s: A
var xPos = 0;
i1 a# ^6 m* U9 _& Nvar yPos = 0;
: H' j1 _0 I4 A$ V% }8 {: b7 mvar xDir = 'right';
9 E" | T9 ?8 i% }1 W8 ^var yDir = 'down'; N/ }3 {5 e+ y! `" U* x
var superballRunning = true; k, U7 f3 U$ H+ S1 o. K
var tempBallSpeed;1 ~+ E. F7 u/ l
var currentBallSrc;2 _2 _7 x j7 |0 D$ W
var newXDir;
% Q' O- e1 Z: ?8 O, nvar newYDir;3 n% J% |1 q. p1 A
! ~, W9 b. z: n7 [' H" q8 N) Yfunction initializeBall() {6 k2 e) R9 s. g
if (document.all) {- T7 j% H8 m; x
xMax = document.body.clientWidth7 C1 ] u5 R* w9 }0 z6 \) A( p
yMax = document.body.clientHeight" v, }' B4 F- N2 ^& l# D
document.all("supertext").style.visibility = "visible";
& Y3 _0 L1 a! ?0 f/ @' S( M6 q$ F contentWidth=supertext.offsetWidth$ f' `# Z2 O: d5 V I; q( f" ?
contentHeight=supertext.offsetHeight
. B) G0 c# N. G3 O4 j1 T; U }6 V! b; ~2 Y3 H" F6 s; i* X( h
else if (document.layers) {
e; v, a- o( ?6 A# P+ m1 W xMax = window.innerWidth;* f* y" L) O1 @4 {5 v
yMax = window.innerHeight;. s) H% [% I+ o8 L: t
contentWidth=document.supertext.document.width
% G- _8 L( p* G contentHeight=document.supertext.document.height; _( E5 V* z1 Z5 ~
document.layers["supertext"].visibility = "show";
! {$ A, n3 g& P6 p6 G( }& K9 w }
% |$ [9 s" L, B( V, F; s setTimeout('moveBall()',400);
' \: R3 |$ U# ~9 [% |! @+ x if (hidetimer!='')
5 y- n; f9 b' i5 d" `+ {- r% _3 S setTimeout("hidetext()",hidetimer)6 f. R$ t+ w# z
}- h% Z2 x: C W% A% k
( A0 G j6 h2 k( P( X% M
function moveBall() {7 c' y3 e7 f' f+ V
if (superballRunning == true) {2 G7 r- m/ }0 S% ^& _
calculatePosition();
# P) ^, }& z! }5 P# W: `" U% e if (document.all) {" ?. M! l& P5 d6 d! n
document.all("supertext").style.left = xPos + document.body.scrollLeft;
0 q0 N0 }+ x5 p6 R document.all("supertext").style.top = yPos + document.body.scrollTop;0 p+ R/ M( ?+ h4 |5 r$ a( Y
}' ]$ g) @5 P0 F" g
else if (document.layers) {! M/ X3 s# M" c7 g: q' T, v! X
document.layers["supertext"].left = xPos + pageXOffset;# c3 R9 X/ } q D6 g: V
document.layers["supertext"].top = yPos + pageYOffset;
4 M) J" A7 V% Z" }4 i }
4 i- a5 n; `+ _1 f animatetext=setTimeout('moveBall()',20);
1 N8 R- ~2 T( [% K! p1 O }8 h7 A6 ^0 S X) k! L0 @" Z
}; o; T' C4 }' E# K5 a1 L& T1 r) F
3 l3 O3 _) Z+ f. k
function calculatePosition() {
7 R+ C: s4 x; v' N l' J% ^ if (xDir == "right") { x- ^5 V8 z* } |6 ]5 m
if (xPos > (xMax - contentWidth - BallSpeed)) {
6 ^: N0 S$ ?. O! z xDir = "left";1 A# @' }2 c& f5 | J2 `8 U
}; _( q# s/ Q, _ E% K0 M: E
}
! T( A4 @! T- [# _% v' i1 ] else if (xDir == "left") {7 Z M( q q* t
if (xPos < (0 + BallSpeed)) {( Q/ h8 w* E7 p' l+ q3 A
xDir = "right";
# K- L5 e( {, Z/ o9 _ }
; C2 K, d. `7 g- B }, B. S/ M6 a9 y/ K& E. ^
if (yDir == "down") {( j- C2 ^5 U: G! L; d6 ^2 g
if (yPos > (yMax - contentHeight - BallSpeed)) {; y: t7 {$ A- D; r9 Q
yDir = "up";
9 h: o4 w) q. w. E }4 K& o$ k1 Y0 l! x. Z6 u% ~
}
& b0 W7 d& Y8 i% o else if (yDir == "up") {
' u4 r# a7 p* O3 `' T( p if (yPos < (0 + BallSpeed)) {( L" A! @% Q8 v. k r
yDir = "down";4 d4 }; W' W5 w/ w0 m
}
$ `5 E6 `7 g( l% M7 W% _% G2 F }
% }. s- K( E" w- k) n. l if (xDir == "right") {* m, @& h: h( ^. l- Q; L* w
xPos = xPos + BallSpeed;5 g$ w) h3 q4 ~' x/ s
}- K, Q% v0 N: j
else if (xDir == "left") {
2 M7 Z- {$ F4 `. S! x# k xPos = xPos - BallSpeed;
. g: V$ f, q/ h' @$ L" w }+ `* U- l$ i2 j1 @3 t* j- H0 d
else {' x/ `( }' O$ H9 j
xPos = xPos;
1 V/ o; M, l2 B+ A* S: u# f9 R6 H3 p( u }
5 P' f5 Z: q& H; q* Y if (yDir == "down") {
! ] D, v9 g& Q, y" r6 {. b% w yPos = yPos + BallSpeed;
8 Q3 C8 Y0 |; F+ X }4 V' s7 x% }8 V9 r6 S
else if (yDir == "up") {
: \7 @& ]3 R6 p( F yPos = yPos - BallSpeed;
7 H$ Q8 D- y* R7 J( h1 z8 Q' ` }
J& G2 F# M2 `" | else {( ?% B3 I- q# F
yPos = yPos;
& z, q" V/ j, N4 |& `- G }+ e p/ v3 E. }: g' h5 b& Q3 A
}0 F9 n9 G+ g. h9 w" \
3 m0 C6 E( p! `2 E" w
function hidetext(){
1 `/ n% ~) M3 K. d/ w# b5 Sif (document.all)
) ~9 i+ l, t; Z6 osupertext.style.visibility="hidden": p, g; r2 t, Y8 L- a/ g% a% m# J
else if (document.layers)
, u' O) ~$ R0 L, L9 K7 mdocument.supertext.visibility="hide"
' L) e! w& K9 hclearTimeout(animatetext)
+ ^# K N; J. ~, a}9 j4 h6 O4 L2 ?' G: n* G R
' n$ A" \7 q; Hif (document.all||document.layers){
/ {/ u* G# A# M9 U5 zdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'). {$ v! }3 T( E! F" t# Y9 u
window.onload = initializeBall;3 Y( F$ J1 g& U7 O3 K8 Z/ E; h9 B
window.onresize = new Function("window.location.reload()");6 C0 l+ X3 f0 `0 {
}; K+ F3 c* g3 O8 C' O
, g6 i/ f; }& b; z! k. c9 \# O( n</script> |
|