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

|
网页之不断弹射的文字-特效
<style type="text/css">
: j$ k6 t% z$ y9 C5 |4 p#supertext {) _# g( @) w; w: F. d
position:absolute;
y- e% S$ t" {) H) p% C! D) |( xleft:0;1 o9 S1 f! l5 j E# o \
top:0;
4 k2 Z9 ]: n( K; Q1 X& G; j3 |visibility:hide;0 r8 l r7 @4 L _0 M% d& M
visibility:hidden;
: w1 Q# N. F/ W' Z' |5 X}
3 p, s& E7 U0 b3 Q% `5 C& ^' C</style>
* f/ K0 z* b( {7 A3 z# G1 l: p<script language="JavaScript1.2">2 h9 f4 U) f3 N& h% [
<!-- 改变下的字体的大小。颜色-->' d7 Y* O+ H: y6 V& r) O' t+ u
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'5 F, f+ z+ F8 H; P+ Z \/ }% E' n
var hidetimer='';" g( ~8 P b* a9 ~# Y' ~
<!-- 改变下的弹跳速度-->
; w0 p1 a, v) avar BallSpeed = 20;
6 G D4 O2 ^8 t6 x: I$ T$ \- y. V( @) `var contentWidth;6 `9 n+ |0 x5 ~9 {2 `1 P9 E
var contentHeight;, ?. g- O; W( t; |+ [0 e6 ~
var maxBallSpeed = 50;/ q% R6 U& [' L* `) I" s7 i
( |; F$ I$ p7 N. Q; O- B7 ]' E9 ?
& f, P: j, z4 S4 p1 T! C0 wvar xMax;
9 h+ O) N1 z8 h* _var yMax;
2 ]5 V( u0 I( c* H/ b8 ^var xPos = 0;% d# i7 v4 i; ?3 h) J
var yPos = 0;% ]4 G& L/ C! t& i
var xDir = 'right';
' g `% _+ n7 d; L, Fvar yDir = 'down';
. \" }1 o' w1 p" Kvar superballRunning = true;6 U! d$ |) B! x+ x2 O1 J
var tempBallSpeed;
' X( E5 D% d# {7 R1 i; d, ?0 kvar currentBallSrc;
Z7 v. p3 A& f; u/ {( U0 uvar newXDir;
1 B# t& I# h% F% n( T4 U0 Ivar newYDir;
5 i7 F% X) X2 t: ^- E( i9 }7 P, b9 ` c4 z: |) k, ?: Q$ Q
function initializeBall() {
2 L3 J. |' I8 d if (document.all) {
) D3 @6 G/ t+ V8 j5 `+ d8 f( O xMax = document.body.clientWidth
% F) P2 a' x' C5 b! C yMax = document.body.clientHeight
& g1 v+ F P5 t; j' Y2 f, f document.all("supertext").style.visibility = "visible";
* x/ s6 U3 Y$ w contentWidth=supertext.offsetWidth1 Q: ~( A1 H. C* i# m* z! p
contentHeight=supertext.offsetHeight8 |8 ^0 w) s& c9 T
}6 Q; e$ n- @% J& H8 q3 M7 B" W
else if (document.layers) {. L; X$ N' Z+ K2 p2 c8 V
xMax = window.innerWidth;
: {1 ^, h# f8 O. I5 w1 o" Z yMax = window.innerHeight;3 G. j6 c! K0 m' _4 u1 P K
contentWidth=document.supertext.document.width4 x( p8 j( m8 @% Y0 ]) e/ ~. i( n
contentHeight=document.supertext.document.height" x/ \( M( S2 L0 h/ g
document.layers["supertext"].visibility = "show";7 \6 E1 ^1 W1 X+ b& z+ x
}
& z8 `" l: P- J& d, @+ a! k setTimeout('moveBall()',400);
4 `1 ~( q5 _$ v+ \ if (hidetimer!='')
6 \! F# y) b5 @2 R, L setTimeout("hidetext()",hidetimer)4 y* n4 A* |5 B% A _
}5 g. O/ F# L) h7 o
, ~# y. M* k) F xfunction moveBall() {0 B# z3 B+ D- H6 E/ U
if (superballRunning == true) {! ~' o( z( T; m R7 E3 _: Z ~# O
calculatePosition();1 h/ c% n( z6 j0 Z5 [# l
if (document.all) {
1 Y7 C2 z5 F* {7 e' o document.all("supertext").style.left = xPos + document.body.scrollLeft;1 F {9 L$ Q6 v! w5 M4 z- p/ m' c
document.all("supertext").style.top = yPos + document.body.scrollTop;/ z/ A4 V' N( m, F
}# j0 j1 P8 u* o6 L' e$ E
else if (document.layers) {
# K* t9 ?5 W6 k1 L, i document.layers["supertext"].left = xPos + pageXOffset;
* G$ i3 l7 J7 r' w6 }0 Z document.layers["supertext"].top = yPos + pageYOffset;
! w& r6 u, S# y }4 g) _ R; K5 S" c3 g) o: \; V
animatetext=setTimeout('moveBall()',20);
1 \3 L2 d) E* n; U/ n$ b }4 M# T$ @! j0 E3 W6 p# @2 |
}
. C& [" t3 i8 x4 w
?6 { d+ e* h, a7 Gfunction calculatePosition() {- k1 ^1 E; p8 |1 I9 X" R) V/ U
if (xDir == "right") {
$ _: z, U k4 F if (xPos > (xMax - contentWidth - BallSpeed)) {$ z. G- \! V2 X8 @5 |1 \6 ?
xDir = "left";: j; I5 F* N/ ^. q
}0 I- ]4 _+ i( l, k
}" _+ N2 G# c# O. W' M X
else if (xDir == "left") {
, D. i' L( e3 l- \5 `. X if (xPos < (0 + BallSpeed)) {# u# G( g% N6 w5 K! F' v/ d& I) d
xDir = "right";
5 ?* t* Z+ M8 y! z' Y }
% W3 ^7 v1 D4 f* C2 R ~! ^ }( |3 e. N# F$ Y X
if (yDir == "down") {$ H$ Z3 ]( P2 Y, h$ V$ Y( ~) h% v( a2 I
if (yPos > (yMax - contentHeight - BallSpeed)) {, ?7 S. X% Q, U$ t3 L5 c5 b
yDir = "up";, \/ ?2 q3 w) z8 X6 C( y8 {0 z
}7 k* m+ R, t+ b' l- U3 N; a- o9 x
}! m6 j) m( q3 ]$ s; w5 w# o
else if (yDir == "up") {
( R, M6 R$ H0 y+ H" c if (yPos < (0 + BallSpeed)) {. z; v4 {3 f+ K! C8 N3 T
yDir = "down";
# ^5 A* g. r9 g, K+ f }
% U) m( `3 G7 T' ~9 { }0 h ~% a* o# G( u
if (xDir == "right") {
. M6 h: ^7 L) s* B3 M/ }* G xPos = xPos + BallSpeed;
V$ W: p, Q$ m+ S3 Y5 c2 { }' X& R1 G, @" X% z# k6 H' R. i3 C6 Z
else if (xDir == "left") {
$ x1 R0 d. T5 ?1 L, O& O xPos = xPos - BallSpeed;5 ~! v7 z' i2 T4 S
}( a2 l e2 h( C: K/ V \ J
else {6 `* ?9 }7 S- G
xPos = xPos;% I' j7 ?& b# D8 D1 g
}1 M* c3 W" y2 ]9 E7 W; x( k
if (yDir == "down") {
' n' }# p: P/ i yPos = yPos + BallSpeed;; |/ j! I: W) |' |. T) u
}1 X# N8 L# C# X: g
else if (yDir == "up") {
; _0 ~: k' a' {2 ?! u$ o yPos = yPos - BallSpeed;
6 v1 ?/ a: ?2 I7 i" j }
0 B# }6 u* C, T8 M: j3 A, P else {
2 z* ?3 L5 p. A" s8 v4 _) F yPos = yPos;
0 S; l2 s7 Q+ Y: \ }
" K* [, O3 J& m, R0 u, o* k }( v$ N! U; E/ M" a3 v0 w
# l" K1 J9 z* u1 T2 I0 \ H* M) wfunction hidetext(){
) c, M; P% U% t! c5 f/ Jif (document.all)
: o/ ]' A# i6 B) |) u7 c1 t- }* v, wsupertext.style.visibility="hidden". A. J" Y- m' p5 m, V, W2 e
else if (document.layers)# t. o! B; X- i
document.supertext.visibility="hide"
& Q7 j \8 g+ h0 ? `! Q2 A- kclearTimeout(animatetext), ]+ \- I" R2 l" H X, [! W
}
9 G6 f1 Z; b2 i! ~9 b, e- D5 q% N. L3 |* V1 V( o
if (document.all||document.layers){( A) ~: P: G& q9 j' ^8 K, g
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; V5 P. b- Y% @8 D& kwindow.onload = initializeBall;; M# A3 Q* C( r% s% e
window.onresize = new Function("window.location.reload()");: ^6 S+ ?. j" f" q
}
7 w6 B, u! v3 ?) A+ q
. C' c2 O7 c6 R9 n</script> |
|