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

|
网页之不断弹射的文字-特效
<style type="text/css">* k% f# n: V! I* b+ q; H2 K1 }/ C' w
#supertext {; G( t2 y; C( ^! V
position:absolute;
/ P4 V8 b. [. W, w( _6 q, d5 y3 p9 wleft:0;
6 l9 q2 Y7 X" c7 v3 Wtop:0;
6 V( o/ X" N0 Ovisibility:hide;
3 J% P& n4 c- Q& q& tvisibility:hidden;* v4 i0 K/ K# Z
}! A3 F5 P6 ^' | o
</style>/ C, ^% J# `) q# {
<script language="JavaScript1.2">
3 K* C0 l7 ]' t( A# i<!-- 改变下的字体的大小。颜色-->1 ?0 B! n' ~( G( C3 ^
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') S7 S5 l- |9 o% `4 H$ O
var hidetimer='';
~! t7 J; h( e9 |) Y<!-- 改变下的弹跳速度-->4 U9 j+ T9 @" X/ b( s
var BallSpeed = 20;( G, s5 f3 ?- ^' [, M8 X
var contentWidth;
* W+ m& x9 B! I4 Jvar contentHeight;
$ {2 L) h& |; I5 evar maxBallSpeed = 50;8 j3 r- }/ e3 q0 ?) u# t8 [
$ l; \/ d/ ^1 W e/ ~0 a7 i) Q9 w9 s4 J% `0 v: ]2 G
var xMax;9 j" t% b7 }. J T3 V& k
var yMax;
3 { j2 G- R% U; Zvar xPos = 0;
' n5 l0 b; `; M3 {) v Mvar yPos = 0;
) I5 q9 k$ F2 Nvar xDir = 'right';
* W9 h2 k/ k: r/ n% ~* pvar yDir = 'down';
& }; A8 G1 m( n) P% gvar superballRunning = true;& t6 I/ n! M$ y! S2 X. u# x* e
var tempBallSpeed;
( c2 I0 ~0 _. h+ j' X3 d+ nvar currentBallSrc;
* J2 p4 e) y3 Avar newXDir;
3 s" Q# q5 k; N6 evar newYDir;% Z# t5 C+ Q& y# c% }1 h
; v$ q8 g4 F; |/ ?( d% [
function initializeBall() {1 d* [' W' l! W; I" {( j& e6 V
if (document.all) {
6 I+ J" K/ \8 h xMax = document.body.clientWidth8 E6 S4 u% U) R, I& Z
yMax = document.body.clientHeight
0 e/ Q; B x2 ~4 M1 u6 s6 J3 H document.all("supertext").style.visibility = "visible";
5 `8 ?1 q- r% ^* } contentWidth=supertext.offsetWidth
- j% t! G8 f1 t7 O contentHeight=supertext.offsetHeight
4 {$ V+ I2 ^ I }; h8 a0 g h6 b1 ^" I
else if (document.layers) {
1 f" X- A" Q$ A) h3 L xMax = window.innerWidth;
* b/ J' O/ }) c8 U% ?7 b: A+ t yMax = window.innerHeight;
3 l2 z8 ]0 C$ o7 n contentWidth=document.supertext.document.width
6 B" t5 }, ]( Y. ]" }' |. W contentHeight=document.supertext.document.height4 F% `0 K! [8 L$ T( c
document.layers["supertext"].visibility = "show";
2 Q/ k; W% M9 |: t% b }
$ J' I2 e! G1 O! H3 f* k2 V setTimeout('moveBall()',400);9 a: k2 h/ ^, R c1 F
if (hidetimer!='')7 c: z) V R k# D+ z
setTimeout("hidetext()",hidetimer)
8 N' D* G$ @5 m5 ]: Z: A }0 |# x9 Q( O) ]" \
2 h' s4 `0 y% [4 s# K3 r
function moveBall() {2 A6 b" _! ~1 T. R3 R
if (superballRunning == true) {
: _) ~& Z* x" z2 Y7 F: Y calculatePosition();
: t) B# W* B3 Z9 h, ] if (document.all) {1 u2 r _# @2 G8 U
document.all("supertext").style.left = xPos + document.body.scrollLeft;
' \" N/ ]( x+ w document.all("supertext").style.top = yPos + document.body.scrollTop;
$ a& v# j* Q0 P, Y4 h' v }- H" J3 B* D! [$ I; }! a+ U: o% |
else if (document.layers) {3 \+ T# I; J' B
document.layers["supertext"].left = xPos + pageXOffset;
2 Y3 b1 t4 X5 r& e6 B7 R5 k document.layers["supertext"].top = yPos + pageYOffset; U K' O, g! P7 R$ _1 c" Z
}- F/ b- r5 A9 F" a- W
animatetext=setTimeout('moveBall()',20);
' b& d/ s) |. @( t$ n+ | }) t8 D, s7 j$ i
}! N% e6 h3 C n9 U
3 E2 [% X1 ^0 T/ X4 F3 X/ [function calculatePosition() {
1 |( J1 f4 ] j$ y- Z if (xDir == "right") {( i6 V* D0 S+ J" M) m; n
if (xPos > (xMax - contentWidth - BallSpeed)) {
% i( E' ~1 V2 P. Y xDir = "left";
- F2 f1 j6 d8 N3 X" G }
' z1 }: \/ [% T& n }
* P! d. H) Y4 P) {0 B else if (xDir == "left") {7 ?! e! T: B' N% O4 c7 i
if (xPos < (0 + BallSpeed)) {
. @. r& G: l4 b1 ~* A+ D xDir = "right";7 b1 f# ?; e2 J) r# R% F
}
7 L8 K& q9 s/ n f7 }, t }4 ~9 }* k5 k! A- S. k
if (yDir == "down") {
% P) N T; B' J if (yPos > (yMax - contentHeight - BallSpeed)) {7 a$ O. s; z, k2 B3 t# S
yDir = "up";, V2 H# v) n# J( W/ R& N( @3 x
}! q) @" E% ?# N4 K8 d
}
0 y6 v t- C# n* y2 T8 y( O0 v: D else if (yDir == "up") {: X1 B' s- }" ?6 |4 [
if (yPos < (0 + BallSpeed)) {
; Q9 a4 o$ {4 g, V) @ yDir = "down";
% b* l# l3 z% Q! K: b* z1 x( c' G }9 ~: I, }0 h+ m6 x7 B: c
}
7 n; k' @; T( V) m: \8 w6 ] if (xDir == "right") {
: q5 `4 G, H5 e* H xPos = xPos + BallSpeed;
& j# P$ H' H2 v: o- }3 u+ X }
7 j. b* N" @2 y- `4 o else if (xDir == "left") {
9 K' [$ w/ P' S+ j; L xPos = xPos - BallSpeed;
9 i- G% D2 m9 X2 r5 a' ~8 G! U* j }
L- t. z- C( y" @! t else {1 _& m+ z( T( X
xPos = xPos;
& j) J/ I% \) k% ~$ y2 V/ ]: @ }
6 W- G3 r4 _9 i3 Z0 C5 ` if (yDir == "down") {
& r6 u$ [+ R- Z3 v yPos = yPos + BallSpeed;1 Q a6 C1 Y' f5 X! J( A
}$ P# U8 H* @) h
else if (yDir == "up") {) I9 Y1 _6 c! ~1 ^" t5 _" i
yPos = yPos - BallSpeed;& L0 d, E6 L& T2 S2 K# @- Z
}
9 m i1 ~. R- d" l3 g6 I else {
) g% ^/ D( C) I5 c. d yPos = yPos;9 Z N& f% b* t3 Y3 x2 R8 I
}6 @. |' a* L' e
}
# G- [5 ?! G* _+ y1 A) o
9 q! O( D9 J$ e* |2 {function hidetext(){
+ d3 K) n4 f! f+ Q% ~: Q) C ?if (document.all)
- c* x* [& Y; ]) G) _supertext.style.visibility="hidden"3 O1 M* \1 G% \2 T* ^: f+ c/ w
else if (document.layers)
; r/ L; t6 B$ d" ~+ `5 Kdocument.supertext.visibility="hide". |( U% R$ m6 f7 |/ a
clearTimeout(animatetext)
& Z) t8 @8 {9 T* W9 z}
( v2 V; \( Q' p, J
0 g1 C' d0 t |% E# f6 | S2 [5 T( Zif (document.all||document.layers){ d5 w+ e: p: R- r, T1 p7 U d8 H
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')* J# H+ ?3 v3 @4 M/ _8 v) @1 `
window.onload = initializeBall;
+ }& H) Z8 e/ e! ?window.onresize = new Function("window.location.reload()");" F# V" @+ k9 s* {& g4 z; `
}6 r1 N/ k1 N; P- _$ z6 a! F
/ C7 \7 C `5 L- J</script> |
|