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

|
网页之不断弹射的文字-特效
<style type="text/css">1 H$ J8 ^/ |0 ?3 l1 ?
#supertext {# D5 r" i% X) Z9 ^* X2 l8 ], T
position:absolute; H0 b ~& \1 f. i
left:0;+ ~1 N" w1 X9 J4 A& y2 B
top:0;& R' W$ }! [# v
visibility:hide;
- |/ J: ? @5 @2 G5 n: zvisibility:hidden;" z! L0 m0 F7 u! b: ^
}
- I8 k0 t) Z3 N</style>4 b3 s' r. r8 o" N
<script language="JavaScript1.2">7 o& o% t0 c) {
<!-- 改变下的字体的大小。颜色-->0 v# l. I; H4 D3 H
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'6 N8 Z7 t! q$ W* I
var hidetimer='';+ G; x2 q9 N2 R$ B& V* c
<!-- 改变下的弹跳速度-->
- r6 d$ ~ B# X& s" _* pvar BallSpeed = 20;' h# m7 D( ]: S8 K
var contentWidth;
8 O( w' g9 {# P% g2 k0 wvar contentHeight;
2 v, E. |9 f% q. k6 ~var maxBallSpeed = 50;$ P* r K. Q4 Z3 s4 p9 y
( i& w* k; D: F; R
8 D* z* v. d: ]4 b6 L+ B Fvar xMax;
9 X& x* t% @: ^* M- l/ r$ [- i. Zvar yMax;4 S* X8 ]" S. o1 F# O, V
var xPos = 0;0 ]* @( V+ i8 i$ |2 J
var yPos = 0;8 o" ^7 t7 p4 o1 h7 v
var xDir = 'right';5 x6 `( i* w* J% u# L: j
var yDir = 'down';
! t' W- u: t) ]9 q0 @var superballRunning = true;
6 G1 x7 I J! Hvar tempBallSpeed;% ~- ]/ N( c6 [$ f6 F
var currentBallSrc;0 g, N- e6 d5 F2 @$ S" h
var newXDir;
: q: w. I/ F* xvar newYDir;0 ^' H9 }! _0 h5 S+ w
3 Y1 A* N2 B$ j, }/ c
function initializeBall() {
* a2 I6 q6 E8 H: P if (document.all) {' k) O8 H4 q) w$ m* z* }) e5 K
xMax = document.body.clientWidth9 {2 M8 C2 w6 }3 F; {& E( I
yMax = document.body.clientHeight% C! N* c* Y r
document.all("supertext").style.visibility = "visible";
: X( ]: z" g0 F& z/ ]8 e contentWidth=supertext.offsetWidth/ p6 K, D! D5 s: `3 w1 S
contentHeight=supertext.offsetHeight
6 Q1 ]; S1 Y7 ]6 G }
- ~% z5 i! Z. a0 Z, J else if (document.layers) {
2 Y4 e$ H# }; t1 i q# n- W xMax = window.innerWidth;
: D" k* |9 i9 P2 M5 }( ^ yMax = window.innerHeight;! A# a, F/ Y1 a
contentWidth=document.supertext.document.width
$ G! @* c0 C2 k5 w a8 r contentHeight=document.supertext.document.height6 G9 N; W. ^4 a# i, p4 J
document.layers["supertext"].visibility = "show";
/ J4 e8 P$ e8 x7 J! o% U }
a( u1 w! z0 e4 ?+ M; E setTimeout('moveBall()',400);
9 f6 @1 H+ h! u if (hidetimer!=''), i/ p3 l% \6 x
setTimeout("hidetext()",hidetimer)
6 L% h$ a b1 M/ L3 o( S, R/ B9 v2 o }
3 H. W; c6 c* l' ^* n( O- u2 g" F: f* ?+ v" x
function moveBall() {
$ N3 n! {$ y7 q if (superballRunning == true) {" w$ t; R+ @2 p& \- f. v0 |2 f
calculatePosition();. N& y+ Q* n5 W' k2 q
if (document.all) {2 A# A8 w9 i" p5 m9 ?" x
document.all("supertext").style.left = xPos + document.body.scrollLeft;4 [# b# h, w( a
document.all("supertext").style.top = yPos + document.body.scrollTop;# o; a' D2 |' s! y9 C" h
}
4 {8 Z2 N: l. x- q else if (document.layers) {1 ~2 s l! g* ~, t( \$ E+ u
document.layers["supertext"].left = xPos + pageXOffset;* v0 }+ J) ^7 F6 W& _0 O" p2 N3 U% U
document.layers["supertext"].top = yPos + pageYOffset;
$ z+ r8 e. Y N }
7 n0 _" A3 h9 G2 u* `; s. Z& G& o animatetext=setTimeout('moveBall()',20);1 h, ]3 E8 ^0 X: ]
}
/ M. ^: o& a0 Q) g9 P3 r }
- H2 S! v% P, s1 M
7 G- {8 Y# g8 Zfunction calculatePosition() { W- K. e" J! q: D% X
if (xDir == "right") {
) Z4 X1 k4 k# X5 p) M# k if (xPos > (xMax - contentWidth - BallSpeed)) {
$ q; {" h# X1 k xDir = "left";( Y, s8 c. ?; X; H
}7 y, V$ e, Y( y4 ?2 `5 v" l- k
}
& u) S: [3 g( p) D1 C else if (xDir == "left") {
" o- B" \! P8 b& n9 |8 f if (xPos < (0 + BallSpeed)) {' V8 h7 O4 l% ~1 K% |* q
xDir = "right";
' m( {+ Q+ p0 j; b( ~- z: ] }" ?" ^# r+ Y* M! w# h3 r
}" p5 O0 v J5 W. t" s. a# C
if (yDir == "down") {3 ^9 W1 y8 n6 S4 A; g
if (yPos > (yMax - contentHeight - BallSpeed)) {' @: O$ y' \, I- l
yDir = "up";4 Q& O0 O R) u" A& K9 w
}7 f k0 |; A, E2 _4 s
}
# m/ i( M! w# v$ v& Z! E9 F: |7 w3 f7 S else if (yDir == "up") {2 \ b: g: o; y) ^( ]7 ^, T
if (yPos < (0 + BallSpeed)) {
. B2 ?4 ]/ L: Q5 ^ yDir = "down";
: ]( s8 O% w; C+ h T. |. H }5 Q4 x% \- @, i2 X* s; w
}4 \# T8 u9 k9 u) ?( i3 ~, @- ^9 }* G
if (xDir == "right") {
* R7 M) J; c: ~% d/ w' k& Q xPos = xPos + BallSpeed;
. g4 [8 d4 B) T9 z }0 W& G9 }+ u1 z2 h0 ]. @
else if (xDir == "left") {
. {7 p( N4 c! V; G' d8 d! g/ z+ t xPos = xPos - BallSpeed;
7 ~9 k' p+ l8 [% _6 z4 N }9 L o4 b5 N7 w* V/ H
else {$ l* j6 ]& R6 m1 w3 |
xPos = xPos;
+ q2 C" n4 T+ P" \5 h5 Q }. q% {- E/ W4 b3 b
if (yDir == "down") {1 u# X" u& a3 K1 s& g
yPos = yPos + BallSpeed;5 |8 `& A- n. s1 J8 m; K6 E" o7 G: x( e
}
3 y5 r6 K( g5 D+ w else if (yDir == "up") {
5 U; O5 f z1 ?& _7 ?7 a- i. d yPos = yPos - BallSpeed;
# M( `/ _# s/ B& Q4 n/ d2 A+ U4 G }
) J* S" f: g/ K0 Z% U else {! w: C3 b' n# ?# A6 h3 x: T
yPos = yPos;8 N+ y L; j7 Y. Z
}0 j( p! K$ Q& M+ T ^
}
* u8 P; j2 d! _8 ^5 h/ _+ {! ~9 c( B6 c- Y0 u
function hidetext(){
2 o) X9 c( _( y# F8 R( T! Jif (document.all)
3 |9 D& `+ h& o) Q% ysupertext.style.visibility="hidden"$ i* e$ [( n1 x5 G8 v7 c
else if (document.layers)
}7 ^ {' }) s) qdocument.supertext.visibility="hide" }+ |$ B+ D% s4 I
clearTimeout(animatetext)
- n1 q. ]( \3 T! S: x! v}7 \0 e/ r/ `7 O* b+ a- x
, A" ]- N% R# E3 A+ l- ^* L
if (document.all||document.layers){
8 L% f. b& F# n0 O# @document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 U! o/ S2 p% d6 L) F( z0 e m4 t5 qwindow.onload = initializeBall;2 J/ U. S; \, r. ]
window.onresize = new Function("window.location.reload()");
, ?0 E# @2 e$ X' c0 m- A W}
8 C2 }8 z9 z) o z2 g q+ J6 r- g& O7 D2 X% o( a" L$ ]
</script> |
|