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

|
网页之不断弹射的文字-特效
<style type="text/css">
, Y; I* i) L1 G! G2 l+ |+ ?#supertext {
7 |% G5 M9 H0 }6 O8 T+ sposition:absolute;
# _; A! s; w! M% d# v2 q% Yleft:0;/ a# |' d2 m. T$ v: K
top:0;2 I5 U7 @- ? c3 ~; r/ j/ i7 f
visibility:hide;
& w; g1 x. W$ _, cvisibility:hidden;
9 e; F5 ^$ i6 S}
% D& g3 g% R, v D9 S3 @0 G</style>
3 g8 S6 N# Y! Y) ]<script language="JavaScript1.2">
5 u/ H! ~/ e% I) l# N' H& f* Q<!-- 改变下的字体的大小。颜色-->- k! {( c2 f% x7 i0 a
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# A7 F3 }. A7 x1 Q% W1 _
var hidetimer='';
8 Z1 V1 c9 `7 K) h* A<!-- 改变下的弹跳速度-->+ G9 x6 |( \ _# m8 x
var BallSpeed = 20;
5 }/ y0 x/ a2 I& X! b' H# svar contentWidth;5 f' p% ~6 H E2 U
var contentHeight;! A6 T; C8 c8 M; ~- P) C
var maxBallSpeed = 50;
: {5 u' t) b1 J+ Q- L' ]2 P: v$ y: k& s# v
! u% S% r8 k; R) O2 {. i5 cvar xMax;) i" `, U- [3 P7 X
var yMax;
; ~3 X) @- M& T& l( a" Bvar xPos = 0; }, E9 |% H& y- @: t0 P
var yPos = 0;1 j& \/ i4 j1 P2 o) i- [! K o
var xDir = 'right';& y$ U; N/ f$ u- w( [
var yDir = 'down';
4 `: O+ v: R% S* |2 N+ xvar superballRunning = true;
3 I, G# N7 `. Vvar tempBallSpeed;* w0 t, _) |( o* ^6 r9 q
var currentBallSrc;2 N( ~% {) D6 E* ~4 d, _
var newXDir;
# L9 q1 r* r" |$ m" Xvar newYDir;/ ~1 n* n$ s/ o0 k$ K& G
+ h. V/ L. z6 o5 S1 p5 p+ K: `
function initializeBall() {0 i H4 N& n! d; K9 s' u
if (document.all) {$ I, o2 T H2 s. T3 Z7 A! s
xMax = document.body.clientWidth
9 _! |3 P4 G# Z yMax = document.body.clientHeight5 H8 G5 J& i8 t5 p* N
document.all("supertext").style.visibility = "visible";
. j+ s/ W. k9 p! k0 N! m contentWidth=supertext.offsetWidth1 N, C& C( E9 v) p: ]% o
contentHeight=supertext.offsetHeight; @# I) W; |% X( X( g$ M
}
; i7 A, v2 C9 M9 f- I else if (document.layers) {
4 { x8 n( C1 W3 i* G xMax = window.innerWidth;0 J- Y+ A4 W0 E" t5 {2 S! i6 b2 R
yMax = window.innerHeight;# E+ o; b k# I+ y$ V+ d
contentWidth=document.supertext.document.width" y9 J& A4 O% [$ a- z6 w/ k
contentHeight=document.supertext.document.height( L/ n2 n1 p# Y1 o) _! Q+ N
document.layers["supertext"].visibility = "show";
) y0 c! ^) Y- z0 o2 Z }
" L7 _6 V0 G3 V setTimeout('moveBall()',400);
0 @' |7 e- ~: Q8 S, u if (hidetimer!='') N N5 Z; J/ Y' X
setTimeout("hidetext()",hidetimer)
5 M0 E* _4 h- g* m* A }
& @0 p) l$ S* o b b( S
3 u5 [! m8 |+ P! V8 ]( \6 i! m4 Yfunction moveBall() {4 S5 k7 p+ f2 n3 S& b& |
if (superballRunning == true) {
. w! W9 p' w& k: M* Q calculatePosition();5 L# K1 Q% C* `& C& t8 v
if (document.all) {
5 C# g1 C( \4 v+ E( j document.all("supertext").style.left = xPos + document.body.scrollLeft;
& y: k2 i' J2 ?/ w document.all("supertext").style.top = yPos + document.body.scrollTop;
& R+ }9 A: s+ A/ e }
& U" P8 B* n6 ]' n1 O else if (document.layers) {7 [2 [+ `# }3 L( j* Z( U9 @
document.layers["supertext"].left = xPos + pageXOffset;
9 F, e# Z) ~) f3 O/ v5 h document.layers["supertext"].top = yPos + pageYOffset;
+ X6 r9 j" F& c, \! H) G }
4 n/ i3 r0 B6 Y0 C animatetext=setTimeout('moveBall()',20);
0 |) t4 `* b: o6 O9 v }4 f0 y) l+ q6 x: }) O, y: E
}3 d0 c8 C) H1 j) O, ^% B# w
# R+ u5 z+ ^( ^function calculatePosition() {
; B5 c5 ?# M5 Q- Q+ y% K* e if (xDir == "right") {8 q6 Y l# J7 g& d: M9 k: r
if (xPos > (xMax - contentWidth - BallSpeed)) {
- E" Y& W% Q& {% T+ y$ O1 x xDir = "left";# p; R1 ^& m; c- S: z( m- V$ P
}/ G) f9 j; F7 V
}4 ~5 q T/ i8 v! a4 l; H
else if (xDir == "left") {& l6 i- H5 W; o$ i2 D% }
if (xPos < (0 + BallSpeed)) {
+ G! r+ X4 Y p$ {$ R( w+ D4 m xDir = "right";
1 @: C) ]' y3 z2 O# }5 T7 i# t }
4 V! K6 ]& G2 g1 a' p3 H: G f! n }* k( @; _; j0 T" O) w8 g! F
if (yDir == "down") {; q2 W$ M9 }5 Y7 k, y
if (yPos > (yMax - contentHeight - BallSpeed)) {
9 w( Z; o7 G& [3 F T yDir = "up";) V" I- N( c* M( L, t* n% i" @
}
( S6 x( l& [: b# t }2 N s1 k- d4 L! p/ z7 l/ J) b
else if (yDir == "up") {
& @! x% z1 Q8 q% o) F if (yPos < (0 + BallSpeed)) {$ p1 Z' G' ?% V6 }
yDir = "down";
# w! f' I5 H. B, z7 E0 W9 n. x) J }, ?, d, a4 p4 M, t5 X$ `+ n7 n3 b
}
! v, R# z2 r/ H3 H if (xDir == "right") {
m) V$ E/ l2 n8 C5 \ g xPos = xPos + BallSpeed;9 X- \2 C; i/ j
}
/ [. U% {, q& |3 h. W3 Z1 T else if (xDir == "left") {
8 @" B" s9 d3 o0 w- K+ p xPos = xPos - BallSpeed;
" Q+ |* c- z, s6 V } b) j6 u7 Q) F8 V C4 b
else {
7 M6 y- s y+ {: V8 w0 e5 w xPos = xPos;/ J" f* _8 B& y& X" P
}8 _+ D- K t/ J# V8 G" a% o
if (yDir == "down") {3 ]# _$ Z6 V! y; @) W4 @
yPos = yPos + BallSpeed;/ x3 n2 J7 h3 Q& C2 ^
}) \8 W$ _" \- V7 x
else if (yDir == "up") {" b8 m; S# f4 a5 Q9 l# L. ]
yPos = yPos - BallSpeed;
5 l! D5 G6 s+ \9 E }
9 e" w, j8 m4 }2 R( p else {4 ^2 d8 p" m7 l' g
yPos = yPos;
$ Z2 h0 j; g' A2 X: g9 C: m }) W A( t8 W4 L9 y; U; b. h; t. W
}
& [- c0 ]5 e/ _6 R! J
0 `3 A- Z: r, u2 b. ]3 ?function hidetext(){ t+ I! A) L: S& w6 ~
if (document.all)! d/ e! i& }! O1 R# ^/ n7 U
supertext.style.visibility="hidden"
. O& e, }5 J( o: \" ~else if (document.layers)
2 q6 O1 [' t: o! r5 }% bdocument.supertext.visibility="hide"& v; `3 \6 |' Y( _7 C
clearTimeout(animatetext)
! r+ {2 L R2 v7 y6 y}
" Z! b0 p8 m& N
8 a: \* H/ W( q# x9 D( K; ?" Gif (document.all||document.layers){
; k h' {$ Z) A: Xdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 D* A7 K( o3 K0 Y7 |6 ewindow.onload = initializeBall;0 d0 O' x5 l% `* @
window.onresize = new Function("window.location.reload()");1 h& n- @. a z3 h- [
}
# r' b0 ^+ W- k$ H' T: o! y
# ~7 x& J; u" ^% a; W& }& c</script> |
|