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

|
网页之不断弹射的文字-特效
<style type="text/css">
" v* x$ c/ F5 T# W8 n$ L j( ], @+ }#supertext {" V9 R& i: E% r
position:absolute;
$ Y+ g1 h2 N! o4 Gleft:0;! M e9 {+ K& I- Y2 ]$ S6 m+ ?
top:0;9 g# S0 A+ Y! I3 X0 B5 Z5 q' |
visibility:hide;
1 L% n- w. m3 j: f. Q" T$ Y7 kvisibility:hidden;4 r. d f0 E$ `5 z6 O" _( U
}, U( i$ A) ]3 Y6 H: j8 v: E. b# h
</style> h1 S: u! Q* ^- n/ ?! [
<script language="JavaScript1.2">
9 g. F! \4 g( U0 t8 T& W<!-- 改变下的字体的大小。颜色-->6 m0 R& M0 W7 Q
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'9 _- ]+ I: [, [8 I$ X# z6 u% ]' M
var hidetimer='';. T/ i2 f( v. o
<!-- 改变下的弹跳速度-->) k' ]7 T4 T/ l( f. o% o9 Y+ \
var BallSpeed = 20;
( J: J4 V! p+ |+ ?9 rvar contentWidth;
9 }( o; C/ s- pvar contentHeight;
8 M- K+ A/ x$ i7 G0 f* X4 Gvar maxBallSpeed = 50;
7 Z9 V( }) Z3 D& R1 ^) [$ k5 T$ X
3 f2 O- R* p, x5 k6 G7 V; x
var xMax;: ` g' I5 u k: i6 G% \4 }! J- J: l
var yMax;
( r! x2 H a/ u/ P4 o s( ]var xPos = 0;
0 c! t% {0 V0 D0 Dvar yPos = 0;, a( }: I$ ?9 K. U# d
var xDir = 'right';
& a4 ~0 h* j3 E: C# w5 |- E+ O7 V7 Ovar yDir = 'down';
6 N0 k3 F/ o" r* p1 n5 jvar superballRunning = true;6 i& A( V. {+ V
var tempBallSpeed;% e9 q" B- _& B5 y6 K
var currentBallSrc;
- h" x4 Q' H) G3 Z! J0 @3 a. Ovar newXDir;
" p* p! j. m0 L9 n2 g: m; evar newYDir;1 [( z" A2 f7 k! L3 U$ i- Z
9 a* n7 T' T5 q& Y& S2 i. _) Ofunction initializeBall() {5 U, b4 }! E) W
if (document.all) {! b$ ~; J3 Y' R8 E' p
xMax = document.body.clientWidth
8 h; Z; V% C) H$ P, K. b( y yMax = document.body.clientHeight/ C( T6 w+ N$ c0 p
document.all("supertext").style.visibility = "visible";* s1 ]; G2 ^: @- G- Q7 R- w
contentWidth=supertext.offsetWidth% Q4 p/ S4 G: }/ n( n1 J
contentHeight=supertext.offsetHeight+ l4 |. Z0 d) T0 _5 K
}
$ q/ g9 f/ I* e# d G0 E7 } else if (document.layers) {
" r& E9 [8 N& I6 D( N xMax = window.innerWidth;
* e W' h4 d7 s7 w' C yMax = window.innerHeight;
3 v8 ^- B- j: O. Q8 { contentWidth=document.supertext.document.width
. B1 x v- H/ p contentHeight=document.supertext.document.height
7 {, j$ P( R! q7 q8 N6 D document.layers["supertext"].visibility = "show";
1 r* J, b( i2 `& ?( a% s }* z$ Q1 V/ M+ d3 d
setTimeout('moveBall()',400);3 G/ Q. \4 S/ I; K( v6 |
if (hidetimer!='')" b; Q* s4 @! `( \1 B' t' e
setTimeout("hidetext()",hidetimer)
& M* X/ S' J1 k7 J! q3 W* T }
% v# L2 @0 ~* J- J1 v, b1 y! ?& \3 h7 E" N/ `4 U
function moveBall() {$ @) k: S* u7 _' f+ p$ ^
if (superballRunning == true) {& I+ |; E, L* h6 @3 p. h! Z# T
calculatePosition();
# _ }' D5 a0 |. ~9 e if (document.all) {) N' _8 ?, j6 m& \5 a/ f# I
document.all("supertext").style.left = xPos + document.body.scrollLeft;
' v4 ?. g+ E# s6 l1 l8 h ^9 k! x document.all("supertext").style.top = yPos + document.body.scrollTop;
- V8 ?% ]8 J1 L: N }
1 u1 O& T7 J. F5 m8 U5 c else if (document.layers) {
5 \" m4 _. \6 f4 n" N1 ` document.layers["supertext"].left = xPos + pageXOffset;
& F3 i* K9 I( H% e/ ^3 B5 Y document.layers["supertext"].top = yPos + pageYOffset;' e5 N$ @8 R5 j( ~6 ?: b
}
( j1 |1 U+ c" O6 z animatetext=setTimeout('moveBall()',20);" ~3 R; ~9 V3 j- Q7 \9 N% L3 |
}
! e: `7 Q7 O: H6 Y }
$ {( t+ Q9 F* `+ j: c6 h8 D6 b1 ^& y5 A8 q. j1 u" e, N' P
function calculatePosition() {
3 {. {1 `- n! T! n if (xDir == "right") {' G# B; G6 j0 T+ W' G
if (xPos > (xMax - contentWidth - BallSpeed)) {
6 L1 i/ h, ~& X: U; o/ z* g xDir = "left";
0 Z0 X- `2 F- b8 g }, F/ W$ i# q# p* G2 N e/ T
}5 V% G1 {) K1 z* } v
else if (xDir == "left") {
# M, z6 m" D: c0 g if (xPos < (0 + BallSpeed)) {4 F3 @. Q) M& B$ w3 Q( K `
xDir = "right";& n9 @ h" k& e$ O1 ` N
}& w2 i: Q% H9 q' N: f Y8 M
}
" ~) b# l& Y4 L4 I9 z& U+ D if (yDir == "down") {
* @6 V: e. o- J( t& Q: n$ e" g" l: D if (yPos > (yMax - contentHeight - BallSpeed)) {6 N1 [, T% t# C& r5 A* v
yDir = "up";0 [, O/ P% ]& \5 i
}
7 e9 m0 B$ _/ d }
0 I! g0 U+ c- l# R else if (yDir == "up") {
6 G7 L2 v4 v7 H) s! [" X- ~ if (yPos < (0 + BallSpeed)) {
- {: X" {, ]9 D8 w& H yDir = "down";3 f5 j/ I8 e+ i2 R
}
$ m3 v6 T' X2 j4 G }# Y3 i! h* p2 p; M- g$ R! v; A
if (xDir == "right") {) m; d! a8 H' @% J
xPos = xPos + BallSpeed;. G+ j. S; Q; E7 Z* i3 m- S3 V" M& c
}
) L3 U5 S# J6 \$ f5 B" d1 @& D else if (xDir == "left") {
% _, B3 [2 w% R$ r/ ^3 m( ] xPos = xPos - BallSpeed;
' {8 a; o( y2 X, ]) x0 g. j }
" D% y, P9 d# H0 E else {
5 s- I1 w2 X; B$ z% n9 _ xPos = xPos;
) X; m3 o/ E7 e l/ a/ h }
- o# I+ l- j% O9 Z G) H' d0 T if (yDir == "down") {
4 W" s" M2 u3 M, U% }0 k* Y$ ] l' E9 r yPos = yPos + BallSpeed;( @# n( T! V& {' N1 d
}
# x5 _$ r! ]; u- n6 B. D; m else if (yDir == "up") {, M6 a. c2 t6 r
yPos = yPos - BallSpeed;/ U+ _$ R( H" ^) i
}
8 I! J. p$ i: i! G2 A. D* P D9 g else {( f @9 ]; a+ X, w
yPos = yPos;/ N C: P* T( x: Z! S# q& B
}
% z2 t9 S* i6 r# | }
6 Z+ h3 Y" Q) M; G/ g8 X( n; o1 ^0 u, z8 x8 \- f4 ~
function hidetext(){$ `8 u: @! j2 B0 d* W1 R
if (document.all)6 v, `- U7 g1 E; {2 K) C5 g4 Y
supertext.style.visibility="hidden"4 j6 v$ J& F2 e$ H2 ]8 t
else if (document.layers)
. [% `9 \3 @6 Kdocument.supertext.visibility="hide"
$ g8 a) e* B3 \+ t% g2 q iclearTimeout(animatetext)
6 z/ b8 [6 ]0 X$ h& [! x}1 V$ \1 t; J4 i, I$ j9 X+ E
# i/ h' ~$ ?& S7 A: y6 Xif (document.all||document.layers){$ w* @6 [% ^! K7 k
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
( N2 ?" \7 q4 ywindow.onload = initializeBall;
o: Z& l8 r; {8 e: zwindow.onresize = new Function("window.location.reload()");
# P- _% v) A) a2 Y/ R. S. `}
# H, N4 _% U9 A+ o+ y5 n" p: e
' g1 ~4 v8 j, X& u# g1 b</script> |
|