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

|
网页之不断弹射的文字-特效
<style type="text/css">: A: S% i/ i3 K( U3 x0 m
#supertext {4 b6 h& {/ q3 C( f8 G4 ]
position:absolute;
) L( N3 f% {5 ]. f6 U% S4 V1 c& gleft:0;0 m9 U7 j; v* ]! x7 d: ^
top:0;" C" Z+ O% A- e6 \! a
visibility:hide;1 [' R; K3 B! f9 Z# a8 K
visibility:hidden;$ \ e8 Q# q1 A# q
}
' F3 b) }. r0 m; S</style>
8 C7 p+ O- L( h<script language="JavaScript1.2">1 F; u, p' j& ^1 ^; p2 l
<!-- 改变下的字体的大小。颜色-->: L" M: ^; I% D4 v
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 J2 D5 \, @: } A
var hidetimer='';' C* X9 {. H- |
<!-- 改变下的弹跳速度-->
9 k, k" O) P5 O' S( X2 k. {9 lvar BallSpeed = 20;
: |$ N0 v8 c0 `6 n) Z$ Zvar contentWidth;' z8 J2 j, @3 k: y3 C$ N* L
var contentHeight;+ \5 |. N c' Y% h" }+ Y
var maxBallSpeed = 50;" e2 p9 V" O: n& ~6 d, a$ T
* _1 L6 S) r; z8 Z
4 P6 J6 Z. a7 A; Dvar xMax;5 b; V% k: A7 ?3 j+ |
var yMax;( i+ J) d6 M7 x2 l+ I. q- O
var xPos = 0;
3 D: t# H5 T! @var yPos = 0;% x1 w M7 ^: h! D/ c
var xDir = 'right';
# N/ F% B! v2 r7 Uvar yDir = 'down';5 r: p" c% x6 W* n
var superballRunning = true;
6 b+ D* z0 f0 h9 _9 j T; tvar tempBallSpeed;
8 f7 f1 ~, n' N+ L- @var currentBallSrc;
' u3 b M) ^! ~var newXDir;# ^/ n8 g7 O. V% C
var newYDir;3 O/ D! M9 p; p0 a! O2 u
5 g# {8 q# B _: J3 P: j: Xfunction initializeBall() {" [ d, m* Z5 h- y
if (document.all) {
: B: M- b! ^# V( C+ R xMax = document.body.clientWidth. }/ g8 J5 [/ h, E* F& G. P+ U
yMax = document.body.clientHeight
" i# v$ b8 m1 O9 N% ?( r document.all("supertext").style.visibility = "visible";
; Y2 j/ M) j/ n8 c! S4 h contentWidth=supertext.offsetWidth
0 P6 {2 p/ u+ q; V. F9 e contentHeight=supertext.offsetHeight( N E& I/ y+ o7 E
}0 m9 X$ z# F2 q3 b
else if (document.layers) {$ Q7 i) _9 p. x- n, Z/ q% i8 R4 g
xMax = window.innerWidth;0 J4 U4 K" D& J8 P& B# e
yMax = window.innerHeight;8 i1 d/ P" @/ ]! J* F/ i) Z
contentWidth=document.supertext.document.width' z) P4 ^ V+ _
contentHeight=document.supertext.document.height/ O! n% d3 ?& [; W1 l
document.layers["supertext"].visibility = "show";. s p' o# U6 l% [# o; F
}
# I2 z! t$ q6 Q5 N7 R setTimeout('moveBall()',400);8 M5 C# x3 N! g( f/ {
if (hidetimer!=''): Z( B& }$ W3 B+ s
setTimeout("hidetext()",hidetimer)% R2 {* @2 i4 P3 }- U
}7 }( m ^% c5 [0 B2 h2 I8 V6 A2 u) K
8 s! q5 A+ a4 h, K+ P- V
function moveBall() {! _+ d- r7 W0 r `& h
if (superballRunning == true) {
! X6 y. n2 s0 m8 f, h2 _5 C; t( b calculatePosition();+ L% {1 F7 U9 M9 [2 y ?
if (document.all) {- Y8 `$ H& m- m! v# J
document.all("supertext").style.left = xPos + document.body.scrollLeft;
0 X9 e7 i0 a: R6 e" v document.all("supertext").style.top = yPos + document.body.scrollTop; x: t* i+ }+ W
}" J/ k( J# R! [0 J* b6 o; |# p
else if (document.layers) {/ R5 ^* V+ f6 E
document.layers["supertext"].left = xPos + pageXOffset;- \* k, U+ k# K2 m
document.layers["supertext"].top = yPos + pageYOffset;) Z( v4 M3 s8 z, c8 P
}
4 d2 f8 y/ D$ Q+ y0 N$ K2 _ animatetext=setTimeout('moveBall()',20);: o z% P3 k! f& { ~8 s% e
}
% W' Y4 f! b% ~ a8 j% @$ f1 Q }7 S, R. k- G; p4 r) e" a
% Z" V* k8 j. p0 b3 Y5 K+ ?3 H X
function calculatePosition() {
. {- r# L: h% K. E if (xDir == "right") {
3 \$ d. j& U v9 e$ q- [9 Z4 p if (xPos > (xMax - contentWidth - BallSpeed)) {; G5 V$ K) ]! {5 D* m* I0 ^ G+ W5 n
xDir = "left";
8 M! i V) A+ C V5 { }0 V* H }
+ ~' e3 c% P8 I5 c' h }
- i) Z: _6 f q; @& M% `6 `8 e5 X else if (xDir == "left") {3 a" @+ U& x7 S, O
if (xPos < (0 + BallSpeed)) {
) [+ b7 K$ l: ^5 G xDir = "right";
% M5 j, W8 b& D( l7 k }4 \! V/ Q( D) V: D+ h5 r& f
}
- f* A: e% s% H* F0 K+ X/ w if (yDir == "down") {
) v" r. c. Y4 K4 p: f9 N* q if (yPos > (yMax - contentHeight - BallSpeed)) {
8 G V$ U/ M5 ?, m. J# X& J yDir = "up";
2 A! q* K5 A$ f3 u+ _& }4 } }/ A( e2 z' E, g
}
- q/ s! _. a* X3 ?/ ]% l- Q else if (yDir == "up") {, N8 ` p% v8 ~4 y
if (yPos < (0 + BallSpeed)) {) r7 y1 o5 L0 z2 K' q
yDir = "down";
$ E6 B( Y" \- U# Y }# v3 K" I. r2 i0 C( X6 ]; Y9 @
}
0 e6 i( h0 r. c* W9 [9 S1 m4 n if (xDir == "right") {
r9 {& ^( s- X6 c; B0 A, u1 T xPos = xPos + BallSpeed;
% x, ]1 f& J K: ], q Q }
0 X1 Y- g4 g' N, C; L3 e3 [6 T4 s) H else if (xDir == "left") {, L# f5 z2 @5 Q& e
xPos = xPos - BallSpeed;
! e, i. [- H1 E" C) o% a$ L }
7 u; `/ M) y0 v% G% C) s else {
/ S4 a( K( @* s/ E% P3 z xPos = xPos;
' m, V$ D3 n. V) }6 z }7 N* n0 `) I7 u- n/ [
if (yDir == "down") {4 `5 y3 S! G! j2 t; k4 E! [) J
yPos = yPos + BallSpeed;
`( f4 j) l- f5 g5 o/ X9 K }
$ f2 A7 K7 }" u else if (yDir == "up") {* \& B6 `5 ^6 I. n) x
yPos = yPos - BallSpeed;8 n! o' r+ t: }2 ~. V F* O
}
6 K4 o) O) I& W else {
1 ]/ C) h% ?8 N( M# `2 B$ s yPos = yPos;
3 G; o; q2 c6 x }4 h O {- y( Q& [4 ~7 H
}5 `( R5 O& `4 h% Z; _
9 Z& `5 k2 X. {1 `/ u
function hidetext(){
+ P% M& o" J' W* q% }( E K) dif (document.all)4 N1 {: y4 g. X0 V$ U
supertext.style.visibility="hidden"" }, d) t1 S/ J; s
else if (document.layers)
9 N6 X5 n9 g- z. ^6 Xdocument.supertext.visibility="hide"
3 k) I, U4 z @! _clearTimeout(animatetext)& K$ w, n7 }# |2 N6 ~7 Z
}$ Q* j1 D2 d% Z% [& `
0 [- ?' I% a( q( j; e
if (document.all||document.layers){$ ?7 w. y. H: J8 L0 }* I# O/ Z) B y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
' ~9 V& u. M, @- o/ Z: owindow.onload = initializeBall;
, M2 W3 o# ^- u& b! ` Ewindow.onresize = new Function("window.location.reload()");
% ]" O1 X2 t1 ^1 B}
5 x3 B* z# a' t( s4 W0 U6 G5 ?: b1 x& u. a) L
</script> |
|