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

|
网页之不断弹射的文字-特效
<style type="text/css">8 [* U: d4 I4 C- j8 Y5 f7 ?$ J
#supertext {
8 ]' u9 ^" N: Y/ u6 ?" }position:absolute;0 @/ q1 z! E' |. V
left:0;4 N, q& B* e9 y: s
top:0;
0 V6 r s- w8 I# Z( X3 x8 Mvisibility:hide;
! h( `7 n* }9 v; Vvisibility:hidden;2 `3 K6 C1 @9 P! a3 a
}* w# _2 y7 F* G* l
</style>2 Z# b/ ^! l; X4 P r( u
<script language="JavaScript1.2">+ K4 l+ F9 \+ x! i# t0 ^- K+ r% ~( H
<!-- 改变下的字体的大小。颜色-->: R3 u# f0 k( F
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'5 D ` z1 z% [" {+ T1 Y
var hidetimer='';; a7 w: N, [- ?6 M; L& M6 S
<!-- 改变下的弹跳速度-->' o3 R6 b1 S% y0 u+ E0 Y" O
var BallSpeed = 20;
3 _% D. ^! {3 Vvar contentWidth;
9 _" o( J% Q' Kvar contentHeight;# Y$ {* b5 \0 `
var maxBallSpeed = 50;0 V2 u4 P6 z: E$ L
* {9 o1 n. R4 E- u
}5 u* g" G4 B( ~3 a6 e d
var xMax;
# q- j; _0 Z6 T! B. L0 R* o4 Tvar yMax;
& [; R, U( Y' Tvar xPos = 0;
7 W' v0 { d- B' [var yPos = 0;% e1 y9 I1 x! S) D* N/ S; F* \* c
var xDir = 'right';
% G2 I: n) c7 tvar yDir = 'down';- G/ a' o, Q+ `( A8 F, q
var superballRunning = true;+ a! d1 c M- ?1 L+ y
var tempBallSpeed;
; u$ R: `. J7 R- O. |; Gvar currentBallSrc;
$ r+ L/ \; r( x# L) f( X- Pvar newXDir;% x' V E0 Z0 j) v+ [% h8 Y
var newYDir;# W; r/ J+ ?4 s0 u" S/ h( o% E6 d
# ~" V* ?9 {/ n& n5 n' I; p- Dfunction initializeBall() {/ l) W8 c5 O, U- h0 S' o( z
if (document.all) {
# D4 S" F$ |0 l+ |8 u" p0 P xMax = document.body.clientWidth; E2 Q y; e8 }
yMax = document.body.clientHeight
# y7 p# j# O h document.all("supertext").style.visibility = "visible";! X+ P2 m: x, b A2 C, X4 W
contentWidth=supertext.offsetWidth
7 q# ?3 t$ t" w( V9 X# r contentHeight=supertext.offsetHeight
) ]( T7 Y. o2 W }
2 d# d4 R9 G y! C. s2 g4 A( } else if (document.layers) {( O3 B) `- O J7 v, y( M
xMax = window.innerWidth;' e8 n+ n. f" b# A, M
yMax = window.innerHeight;
) f( \2 e' J& V/ k! k% r contentWidth=document.supertext.document.width
$ C% ?$ D9 G* j- F) ` contentHeight=document.supertext.document.height
y z: `( U( s$ K. ?* o" Q document.layers["supertext"].visibility = "show";
* F# T& d( M e6 N& C }
. t6 z/ |7 @0 S setTimeout('moveBall()',400); @$ ]0 Z/ i7 S" N" g
if (hidetimer!='')3 Q# Y& m4 u" Z5 W' l- h" Q
setTimeout("hidetext()",hidetimer)9 ]3 p, l# c V! {9 P0 n& y
}. p5 r) A* C/ W4 w
+ t2 @! v. Q7 @! x$ _6 e/ R; {0 |. Z; afunction moveBall() {
/ K. Y! o# l' {' R* X7 R if (superballRunning == true) {
7 l% I. p$ E' b1 V$ S9 Z, l8 t( [ calculatePosition();
, Y! I. m7 f) z& {; ? if (document.all) {
7 M) M6 [% ]+ O4 @9 }: t3 k document.all("supertext").style.left = xPos + document.body.scrollLeft;5 b# T5 W+ |, a. \$ T
document.all("supertext").style.top = yPos + document.body.scrollTop;. [2 I3 J: E3 R7 R: R* k
}' h! l( X' G1 b. n# @/ { X* R0 s/ c
else if (document.layers) {' P! ^2 _6 w) j- v# K5 k/ ~
document.layers["supertext"].left = xPos + pageXOffset;" U' t, h# {) v0 N: Y" E5 u1 ^
document.layers["supertext"].top = yPos + pageYOffset;+ z& i( Z4 k9 v9 l
}
5 d/ ]2 Y; G& E" v r1 {/ g7 s animatetext=setTimeout('moveBall()',20);
6 O& }) C Q3 G0 i1 P$ C5 H: R }! _) R4 a3 }5 P0 a. e
} Q: ?& q6 G( I8 K0 _* L
6 v6 H. Z9 A' k
function calculatePosition() {4 i D! S. Q5 L c4 k
if (xDir == "right") {2 Y& X q4 b7 F& _. m
if (xPos > (xMax - contentWidth - BallSpeed)) {
0 `* Z N, H2 [+ ]6 h7 D xDir = "left";
* U6 j9 {* h2 P# D& g) Z; b5 G# \ }. l4 D& r8 A6 J& _- q8 v: E
}' r% b9 V' }0 N: r+ g3 G
else if (xDir == "left") {
; v# d ]5 }, b# m, ~6 f- } if (xPos < (0 + BallSpeed)) {, P9 [4 G6 N% U5 ]
xDir = "right"; ]$ p [& ?) k* `
}
, `, h7 f& e: r }
) ]2 \& ]* e0 J( s" C: ~ if (yDir == "down") {
* {! Z6 V0 s" c; U- f) f* N0 a* [ if (yPos > (yMax - contentHeight - BallSpeed)) {
8 d: U8 P C3 ]- Q1 ]8 O6 i# H yDir = "up";$ Y8 J; a( b* ?
}9 P9 Y; s& ^4 L6 _
}
# f' A$ T; p1 q: B- c else if (yDir == "up") {
3 r# D! S8 j% z if (yPos < (0 + BallSpeed)) {2 `) o6 v5 Q/ u0 r% E( A
yDir = "down";' p' N* @$ I: X# e- p @
}
3 Y; j' F" n, T" a1 P }
% C% i: y" V3 K/ r; h( \* [" Z if (xDir == "right") {2 y; f2 u& _/ \, ?; y2 e5 q
xPos = xPos + BallSpeed;0 i' C$ N2 S. A0 d" n. h9 A+ {9 r" ~
}
( T! b: [! H( {. }/ v& h else if (xDir == "left") {' I3 c" ^* M$ H% q! z
xPos = xPos - BallSpeed;
% v% d2 `2 E( d5 _ } ?& w8 G2 N' S$ d' L h. I
else {
+ x0 a1 Z" D7 a& D xPos = xPos;
3 o0 s( Q+ j1 _5 ^8 ^ }
4 i$ D Y( t6 g( Z* N: |& P if (yDir == "down") {
0 R! E7 E) A- C& M2 F' \ yPos = yPos + BallSpeed;
, e: j$ W6 ?9 o2 Y& X, A5 W }5 W5 z8 g' j& ~5 D8 u/ }. D
else if (yDir == "up") {
1 E! e% p8 {3 [3 J$ I yPos = yPos - BallSpeed;5 F' p# W- M9 x$ H1 |) q
}7 l" q, B: _+ i+ \
else {9 v% @+ |. F1 ^
yPos = yPos;+ p/ ~9 q* p/ Y
}
$ R0 N) |1 {, C8 O) L+ C }/ o" `- O7 U$ I# q9 E3 q
. w6 L6 t: S8 w4 Afunction hidetext(){5 |' t3 C+ ~- f9 D+ m; W0 w E
if (document.all)
- h- b* {2 k+ G9 X, b6 c* Gsupertext.style.visibility="hidden"
" U- G+ W4 ^/ v5 ^* zelse if (document.layers)
E6 Y! N1 n; l# Jdocument.supertext.visibility="hide"
- D. A( q1 j) N- s& Y, uclearTimeout(animatetext)
1 g/ ~- G, [' V}
, |3 S* q! x1 ~4 w
+ n8 ^6 P) G A% yif (document.all||document.layers){
+ n' D8 |5 \- i. ^: Mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) r& X' y/ ~8 G( \) i: m4 j0 Uwindow.onload = initializeBall;4 y1 \4 U2 `% J/ B: m& q# j
window.onresize = new Function("window.location.reload()");+ ?( g; J$ r; _! g+ {8 Y
}
4 J0 b* e; b4 q! b& P* ~9 ]2 E6 J- Y9 z$ E+ e' D8 v6 D
</script> |
|