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

|
网页之不断弹射的文字-特效
<style type="text/css">) t8 y7 [! G3 P8 f" L4 o# W
#supertext {
4 E: M- w$ x7 `8 `; Yposition:absolute;
" H9 ]/ l. i" I+ oleft:0;0 {8 A+ ]4 X# g4 H
top:0;. R" a7 s0 U% {4 L
visibility:hide;; r" q" O7 `6 \
visibility:hidden;
) |6 G* F6 k9 T. {; K}
R' P2 A% B& p) y% I! g</style>
( j0 e' X1 b' B. |% W<script language="JavaScript1.2">
" x k7 n2 A: m$ R<!-- 改变下的字体的大小。颜色-->! N. x: P' y L( \7 j5 b
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 f: h7 ]' d. f3 ?. S' Qvar hidetimer='';; M5 L' R" `% h! h
<!-- 改变下的弹跳速度-->
- a& q* e) y/ }, N' Jvar BallSpeed = 20;
( K. b; h9 c5 s) V3 D; Lvar contentWidth;7 M- G" W6 _+ h) g* R
var contentHeight;
& |1 A) O3 O+ Xvar maxBallSpeed = 50;
+ n8 W; B; L: L( H4 G. J, M
' s5 W/ B# e* C Y+ W3 A; S6 }1 D9 U) K0 N
var xMax;
( j ]3 Q- f0 m: Zvar yMax;
8 o0 P8 L1 M3 k- Svar xPos = 0;
6 Y+ P1 k1 A8 @) u( Xvar yPos = 0;
8 Z: p# h* a6 {( c- L* yvar xDir = 'right';* A' k+ O$ A4 Y- t. N# ^
var yDir = 'down';
+ h0 n; k/ Q% ], B5 G8 rvar superballRunning = true;
% g1 G2 x$ Y+ g( k! Lvar tempBallSpeed;& L; w3 p& Q- c; S- |9 y
var currentBallSrc;
0 C7 L+ S. [1 p! Z0 m3 C8 u: \, u/ Tvar newXDir;' V; M% f3 W/ A0 W7 }& D
var newYDir;; R+ |1 _" V5 ^- D) ~$ e
) }; a. ~$ Y, r2 S
function initializeBall() {
4 d5 w1 I7 x" D G L' `: f0 s% b if (document.all) {' W" B: F# D: `( V" |
xMax = document.body.clientWidth
3 i" Q) u% e. A1 @# F. M7 J yMax = document.body.clientHeight; E, _! Y" o9 L8 \4 h% _/ j% g
document.all("supertext").style.visibility = "visible";
5 p/ V7 C( r1 ]# a$ _ contentWidth=supertext.offsetWidth% _3 E3 S. k5 }: L7 g' S
contentHeight=supertext.offsetHeight2 A: a6 F/ u5 g+ \ o" l
}
/ y+ I) V+ D8 r3 a4 h! c1 S else if (document.layers) {* ]) E! Y4 A# J
xMax = window.innerWidth;
! d$ ]/ M2 T5 H; ]: d7 w yMax = window.innerHeight;) ~7 `7 Z* h9 N6 U
contentWidth=document.supertext.document.width
! [: F! G" Y* g$ T7 M. f contentHeight=document.supertext.document.height
! m8 X. n2 ~- w& y( H: L document.layers["supertext"].visibility = "show";! Q% Z! O5 O( W$ ^
}
: r I X, Q0 A! Y! M- X' k setTimeout('moveBall()',400);
. H2 b* m2 B( l if (hidetimer!='')9 ^" j5 I2 z$ p0 Y; h0 g3 ^7 @
setTimeout("hidetext()",hidetimer)
4 P# F h& w+ i }9 ~6 @9 Y, \9 [; p% y& c0 q7 Y
" q8 a; d2 A4 F9 j& }" Ffunction moveBall() {' y6 z l% n7 f/ H% ?5 P
if (superballRunning == true) {
$ l9 `* I. |& b0 @ calculatePosition(); Z2 u: D- `& [% ?( X! A3 C* v; L
if (document.all) {
( _' D4 ~ W: [ f {* w document.all("supertext").style.left = xPos + document.body.scrollLeft;7 J* l$ H8 b% w/ z g5 }
document.all("supertext").style.top = yPos + document.body.scrollTop;! P, T+ C3 i' O+ m. s) j2 K; l7 J
}6 {+ @" B5 {. |% j6 g, `
else if (document.layers) {1 L# ^+ g9 n5 D j( G, X
document.layers["supertext"].left = xPos + pageXOffset;9 t( J: \" h3 Q; U5 P' O
document.layers["supertext"].top = yPos + pageYOffset;
7 W: {% p5 ~& [4 ?; K2 C [ }
" s+ N% y: H! h5 k R animatetext=setTimeout('moveBall()',20);
7 w8 R% o# u* ^ }. _2 R# T: F' N2 _
}
* c. @4 S6 A8 H! e: @3 V. y! B) `! S& B
function calculatePosition() {! J* k) Q+ ^/ c) h
if (xDir == "right") {
) m; g1 V5 b! i! L if (xPos > (xMax - contentWidth - BallSpeed)) {
: J" L4 s+ u0 \9 _/ Z& E xDir = "left";. C# t* ?! o5 Q2 u; ~ D! @
}
s( t6 D2 ~" g, V. W: | }
+ j. q+ P8 e/ X! q X else if (xDir == "left") {
2 j) r: Y& j9 k2 h2 c if (xPos < (0 + BallSpeed)) {
" X# _4 F4 b/ _: [* N. M xDir = "right";
" |& s" y* r4 d5 N }
: s& N0 o. b6 {- n }
, _1 C; q w7 t, e9 ] r if (yDir == "down") {
& `+ v6 N/ n9 A9 N& I if (yPos > (yMax - contentHeight - BallSpeed)) {; N: x% M/ g! A! F% A! O- X, a4 d
yDir = "up";
1 ]: }; v: Z- a0 r# o" r9 v }: ~. k; Z( M: t1 T" O$ a
}* B4 X& L. i# B1 ?+ y$ U8 @9 }* E& W
else if (yDir == "up") {# z9 Y: z, S5 Y! ~" H) j
if (yPos < (0 + BallSpeed)) {2 d5 [+ l8 t7 a* z
yDir = "down";2 J1 A( W! F2 t; h7 ]
}
: s- I. v1 X# z+ g/ |5 o& p3 q* u }
\" n8 d0 M/ A" G. G* ^+ k if (xDir == "right") {
' ]4 y6 o, ~" m; V6 [% w xPos = xPos + BallSpeed;2 E |/ L6 }1 k
}
! C4 B% e8 J* B/ H4 T6 v else if (xDir == "left") {
- c1 i$ a: L6 V. [5 f- b! F xPos = xPos - BallSpeed;; L' Q7 o5 x% }8 a* ^- R' K' D$ f
}
1 F* A6 K2 [( h6 H' H6 @4 D1 { else {3 K, J1 t; }& B/ V
xPos = xPos;
; i6 N$ [/ F# P+ M8 s3 T2 k0 Q7 P a }; R+ f6 ~. z+ @
if (yDir == "down") { M& [' [* X5 o1 i: j, j, D' I
yPos = yPos + BallSpeed;
' s0 P7 v a) ^# A' y& S; b }
( e' Y% X/ X7 z: U; `3 G1 t& r else if (yDir == "up") {
- d, g6 S J+ U+ g yPos = yPos - BallSpeed;
$ F; T. J; i/ {+ S8 { }
1 X" s9 D- j I0 P" Q else {5 R6 F/ i: H5 Z6 L- h
yPos = yPos;
; L2 V( Y4 ]# ^1 k }4 L9 O+ k4 o5 I0 n8 l1 R0 I
}& M8 \2 g! A$ N [
) S# G: |6 a# l( O7 rfunction hidetext(){
4 \- G- O1 o! V7 o( R% O6 Cif (document.all)
% g: I/ R+ {' C9 Z/ Z8 Isupertext.style.visibility="hidden"
9 i f# a& \. Y3 r" {7 [else if (document.layers)
" P. R7 w& V& g0 Zdocument.supertext.visibility="hide"
9 `5 `+ @, h7 ]/ w$ v4 ]clearTimeout(animatetext)7 U5 v# }0 b" t# O& w
}
1 a2 n9 s) o, m: M# J, { O W% [, y2 k h+ e
if (document.all||document.layers){
& f/ E0 y) L* r# i% mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')* w9 r8 w5 p/ c
window.onload = initializeBall;
, b5 e- ]! c' N: K- Gwindow.onresize = new Function("window.location.reload()");' Z! Y8 g! w- Y1 ]3 z8 S& e x
}
7 J/ Y5 `; U/ @8 G: w. [6 z$ M) d7 y* B3 [- Q8 C
</script> |
|