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

|
网页之不断弹射的文字-特效
<style type="text/css">
8 a2 O+ J8 z: ~! j#supertext {
) J3 a5 m, j' X5 C! Gposition:absolute;" p9 j2 J9 K; I7 W$ ^
left:0;0 E" g& x& _( {1 ^2 {
top:0;% n; i& Q7 G- h# I1 C2 @
visibility:hide;6 m' T- c( P, p1 H* d3 q( I) a* T- W4 }$ C
visibility:hidden;- ` [7 M2 B' g1 E8 s
}) Y: o h- A& @. z: j7 @
</style>2 b, ^+ l" _- S S! F6 P5 a/ t
<script language="JavaScript1.2">+ U2 s7 r$ x7 X
<!-- 改变下的字体的大小。颜色-->0 w" D! S4 d6 S( H
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 w! s1 |7 M% v! O% q; B, U: {* q
var hidetimer='';3 v- ?1 V5 L* K& U6 ~
<!-- 改变下的弹跳速度-->
9 g, S ~' l2 X. N4 C0 a3 ]; Bvar BallSpeed = 20;6 U" o, f. J4 ]# I( S
var contentWidth;. e/ a& k: N8 J& h
var contentHeight;- i& f: s( v, p9 u6 E
var maxBallSpeed = 50;3 }4 p% h4 w+ n/ t0 A
% i7 p/ R( e) u' x& l+ _
. E; H9 \6 p% L& h1 c2 x! f1 ^: Cvar xMax;* _6 L. e/ D( B* u' |& l$ Y
var yMax; h1 b. |! T; q
var xPos = 0;9 E% h' b/ I8 b1 N5 }
var yPos = 0;
4 Y9 N7 Z! w9 ]var xDir = 'right';
6 r/ M7 |7 M8 c& Y! Gvar yDir = 'down';
" o7 h- n5 Y# M0 g) qvar superballRunning = true;
6 K/ [5 a! U1 C9 p6 H7 Fvar tempBallSpeed;$ F* S) A& S6 x6 [- n: ~
var currentBallSrc;
1 U- G4 [/ o! [6 s7 j. l: Vvar newXDir;
% `6 y' ]' u3 N. n' Z0 {var newYDir;! @* x8 ^3 w3 e1 ?
3 G Q, I- ^" N5 D, B( e( ]) J. t* l
function initializeBall() {
8 Z( h& w5 W- e5 D+ D8 t if (document.all) {
8 c p, n- T' ~ Q& f U! \% w xMax = document.body.clientWidth: d) i6 s- s2 F0 V* l
yMax = document.body.clientHeight6 q6 H- A& z! Q1 d: b/ T
document.all("supertext").style.visibility = "visible";6 f. }; h4 d( O( B, F
contentWidth=supertext.offsetWidth
8 _+ F9 O7 z' J3 i2 }" e contentHeight=supertext.offsetHeight+ W' a; @6 ^. v6 Q! ^! n
}
% ^, w1 a: T! T. V- O& T else if (document.layers) {
6 i$ l; O) b: o9 n% T3 X- u xMax = window.innerWidth;
4 {! |; O) m; k+ Y" A' i! ] yMax = window.innerHeight;
; a8 n' A' ` E- o, Y" B contentWidth=document.supertext.document.width
0 G3 ^! [. K; r) g contentHeight=document.supertext.document.height
9 @/ H/ V5 C: k5 G6 v- f8 W) o document.layers["supertext"].visibility = "show";7 Q. u9 j1 J7 \ z$ D$ S2 w3 J1 l
}. c& u% q/ e2 B5 C! w9 d
setTimeout('moveBall()',400);9 O2 h( S* v& `+ k; y# k$ R6 k
if (hidetimer!='')/ R1 r, Y) A) `9 e5 A' Z
setTimeout("hidetext()",hidetimer)
: ?1 L6 |8 c) G, K0 _! R }
6 S# T7 F; R" Q! ^0 r8 F. e" ~( C/ e* h G7 D0 V8 y& p
function moveBall() {- I; _. M \/ G: c0 f
if (superballRunning == true) {0 u4 b) r S2 d8 O$ @; `
calculatePosition();
# L5 X+ s5 C# [% C4 D if (document.all) {5 \0 J- G0 r: j
document.all("supertext").style.left = xPos + document.body.scrollLeft;
* Q9 J! D J5 W% D document.all("supertext").style.top = yPos + document.body.scrollTop;! a4 F( r2 B1 ]8 T7 v
}
# x) B+ a% n- C" A else if (document.layers) {1 N8 r1 h- Y7 ]- I6 r9 o# i+ N
document.layers["supertext"].left = xPos + pageXOffset;
8 n1 U: I0 Y) C0 G* v7 x document.layers["supertext"].top = yPos + pageYOffset;
# p5 h' e- y1 Z- p }
3 C6 @, d' m5 _% C9 C/ W! E6 j7 } animatetext=setTimeout('moveBall()',20); C# E5 d9 D# M" q
}* B+ [- J" v; L2 @
}, e3 G/ O/ O. G* j$ g' {
8 t* U* b. Y4 {
function calculatePosition() {
4 m' E, P$ x* d) z6 |$ ]0 u3 V7 E$ d if (xDir == "right") {/ U3 w" c; l9 ^4 U
if (xPos > (xMax - contentWidth - BallSpeed)) {* \5 `7 X# b+ q% ^, D2 z& [. _8 i
xDir = "left";) E+ _/ x6 N! Y
}7 d, a' U! z5 R: P6 w
}
; f1 A3 F1 K- }. b W else if (xDir == "left") {- c! A/ Y9 U4 S
if (xPos < (0 + BallSpeed)) {$ @" A. c2 {/ u1 [( q( r, s8 u
xDir = "right";
# y, m& r' N, n- A/ i; ~ }# Y( g, N! C3 o. H2 z$ I( ?8 n8 _
}
8 `2 k, P$ o7 z m2 t if (yDir == "down") {
9 f' r, x& a4 o8 `! v if (yPos > (yMax - contentHeight - BallSpeed)) {
6 R/ t8 ?. ~& W: Y yDir = "up";
) H: h+ D) J. w, H }
( d$ G! N8 |. k }
' _. d# [9 Y5 u- a' ]% I8 b else if (yDir == "up") {: l+ V, R/ i7 m" B4 h
if (yPos < (0 + BallSpeed)) {" W6 l0 d: u" V2 i. r2 Y
yDir = "down";
& r7 H7 A8 q" g }: A6 Z- Z3 j) N9 [# i, O9 K
}
1 [' }; H( P/ b* U if (xDir == "right") {
, f" i+ g$ W7 j! }7 N xPos = xPos + BallSpeed;& i# C# G" ?/ P5 T) G& O8 y7 E) M( q
}- Z! k: p8 c6 g& q9 \% |
else if (xDir == "left") {& Z! B! r# D. Q" |' C
xPos = xPos - BallSpeed;6 R5 I! w# j% B! X: S* V3 W" J6 S
}
/ C4 G8 n. ]1 ^. X( V+ C else {
& w" }, P7 i* z xPos = xPos;
. l9 t. f9 I, n4 W+ q: m7 N) V! ~ }- y8 w/ t" o5 D8 Q+ {: u3 k
if (yDir == "down") {# e, f6 { v6 }7 d
yPos = yPos + BallSpeed;
6 B4 r/ {8 c( I* g }
$ ^5 e$ z4 S4 F; I2 z4 y/ L) O else if (yDir == "up") {
) A, ^9 B+ D% E B yPos = yPos - BallSpeed;
' n4 o; K& Q2 G3 M* M }$ j$ t! a* o, z6 T
else {: ~- z2 h' o: C& U; P4 D
yPos = yPos;
- ?2 @( ] \3 d5 r }/ [1 V1 S) ~- O0 i0 ~
}
' s0 c( l. y% l% D v& y: C+ H* O! b# {
function hidetext(){. G, y' M" q: k
if (document.all)
' C4 \7 Y, X. [, Tsupertext.style.visibility="hidden"5 k9 s. o7 @: J1 x2 i
else if (document.layers)
. E2 S. k& v3 g! Ndocument.supertext.visibility="hide"; ?; `& ~: I/ l; N N! _" T
clearTimeout(animatetext)
7 B5 Q5 m" j5 R' e}; Q" S! Q% Q& X0 r& ^! b" y/ D5 |7 i
$ M( K$ U8 z+ Qif (document.all||document.layers){# g! [3 P. t# q Z" _6 X* M
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; D6 j: [/ {0 P3 k- Z$ Lwindow.onload = initializeBall;+ W& [# Y _+ h* p
window.onresize = new Function("window.location.reload()");! R. G/ s& y6 ^6 I3 B
}% X& G7 C3 s8 X
8 z" Z* a+ U2 D; t
</script> |
|