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

|
网页之不断弹射的文字-特效
<style type="text/css">" x) E- ?+ [+ h4 I/ Y; w6 h$ S3 d
#supertext {1 X+ d* w; @; i! V0 Q1 n3 G M0 C' f0 I
position:absolute;
9 s2 ^1 D: e, ^: n, f4 @. Zleft:0;( T) F, Q8 x, |" D8 }7 z
top:0;0 j( V6 g' o" L. m
visibility:hide;$ [. j5 x9 R, E. m: ]9 j2 w
visibility:hidden;; i5 g4 u; A& {5 K
}
" F, O( j0 f& \: H* T" L r</style>
9 l9 p# M- O( [1 G$ G% m. {! M; y<script language="JavaScript1.2">
/ x9 ~$ @( d ]. V) N<!-- 改变下的字体的大小。颜色-->% S# _# S3 s0 T( ~* V p
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 P% J G6 a! m2 \! @var hidetimer='';3 _9 }* O, o) y5 |2 n
<!-- 改变下的弹跳速度-->
& l% v% N/ d1 \5 A* H9 x L6 Xvar BallSpeed = 20;
U" k0 R1 a9 _3 y. _$ G% c% avar contentWidth;
. z9 T7 a! S( Y' Bvar contentHeight;) d# v2 f- g# W) N& L6 i7 `# I
var maxBallSpeed = 50; ?: L3 _8 o P7 D7 ?9 u% _
4 t- G$ d. H, l \- |7 v7 k3 B! f
+ n; g; A% W; y# x4 b0 m5 N
var xMax;
* b$ K* S9 ?4 L: N) Z# jvar yMax;
" }4 V& K4 K- J% Yvar xPos = 0;. {" R& d7 m* Q* a' X8 \
var yPos = 0;3 l" m* R- k" @+ B& ]- q' ]
var xDir = 'right';
9 e7 M( ^8 N# D E( ^( F3 cvar yDir = 'down';
]* Y0 O/ L( o+ q2 avar superballRunning = true;
# x9 [6 L% e5 |var tempBallSpeed;' I) e6 B: G' L: h- N5 V
var currentBallSrc;
( p% _! h- B7 Y6 avar newXDir;
$ X+ P h. t# _/ a) e: l. Dvar newYDir;
. K6 i( \: n4 [. n8 F {
7 c/ A! s) L$ a, X V. D7 Sfunction initializeBall() {4 D3 g4 K6 V: q0 _
if (document.all) {
( p r- ^4 K. Z6 q% k8 f xMax = document.body.clientWidth1 E5 K; L6 d9 T* P, I
yMax = document.body.clientHeight8 _2 Y0 E' ?2 ^6 D; }
document.all("supertext").style.visibility = "visible";
2 L ?4 A6 U% M3 V" O+ \ ]& Y contentWidth=supertext.offsetWidth# j& R/ k* g" @' E ~
contentHeight=supertext.offsetHeight3 I& o8 U* P* n1 i9 n
}
' J! p, R0 ]. L2 P( V, _( L: A else if (document.layers) {. ^& c0 V0 ^% i! a& j
xMax = window.innerWidth;
$ y! a2 T9 T5 y" r1 y- b: G yMax = window.innerHeight;: }7 m1 v$ `& P! G& W3 A3 K1 ^
contentWidth=document.supertext.document.width) V8 b# n' k5 H! R/ a
contentHeight=document.supertext.document.height
. w* A: {1 Z4 G" K! Y V document.layers["supertext"].visibility = "show";
0 J; B8 m. t: L% f }
+ U: o0 p* [; V# W: `! a u0 k setTimeout('moveBall()',400);
7 H0 c. }0 ^7 Q( p, g8 b# B if (hidetimer!='')! k1 U N! _+ O( R4 z
setTimeout("hidetext()",hidetimer)! Q7 Q: w; e6 j
}- j* b* l) G, ?' J
; M* r6 D, p3 I0 `; S
function moveBall() {
+ Q: \9 p4 U1 A8 R if (superballRunning == true) {
; v6 R3 s# X. g, M calculatePosition();; Y4 @; r b, C# W
if (document.all) {+ n+ I& Q* W7 [+ y( v" K
document.all("supertext").style.left = xPos + document.body.scrollLeft;: Y, ]* l6 c) s& O6 |2 H& p2 i" ~
document.all("supertext").style.top = yPos + document.body.scrollTop;
' b4 e* [9 w6 V1 v- z, X } t a- F/ p N3 g* p
else if (document.layers) {4 F! r4 u* ^6 n; q( o
document.layers["supertext"].left = xPos + pageXOffset;- a$ \7 X8 i" D* ]8 R5 ^
document.layers["supertext"].top = yPos + pageYOffset;! i7 j' E' x; }5 X+ y3 |1 s( Z0 ? g8 s
}
9 ~# L5 q: C- k6 n animatetext=setTimeout('moveBall()',20);
# k& x3 X, o/ Q/ u7 D }
* g; A# D3 T$ h3 `( z- W" `/ Y# s" S3 j }
: C1 c0 A$ A) z- s- g h$ Y ^6 \& p8 I ^ r9 w! L1 f+ U
function calculatePosition() {
6 @; z* e* g) [" o" s1 T. W% S if (xDir == "right") {7 a0 w: f; s- ?* c) V, a
if (xPos > (xMax - contentWidth - BallSpeed)) {
9 L7 q- G6 z6 g: g! O2 W3 P xDir = "left";0 x7 w5 _7 n4 h( e* b- h$ b8 z7 _
}
' e5 {0 U3 Y1 T }( l! e2 L }4 `0 ^4 C3 P# U4 a
else if (xDir == "left") {
% [6 E) v( p4 y! V if (xPos < (0 + BallSpeed)) {
+ I4 H0 [0 b' z xDir = "right";. S( W0 x; \% u7 G( j5 C" ]
}/ a' ~' G* r, y; A) e: Z( W* L* f1 S
}
z+ n v0 j9 }6 v n if (yDir == "down") {
$ n6 a' h* d6 t- I if (yPos > (yMax - contentHeight - BallSpeed)) {
6 j# \' T& G" G% g) s3 H# H. J yDir = "up";4 r9 t+ Q: V/ ^' Y
}
, u* u: S) |) ]& F& q! [ }
% U$ v3 F5 v% [- B+ ] else if (yDir == "up") {
3 V. x$ {/ x1 r+ L2 ^8 N& G: J if (yPos < (0 + BallSpeed)) {1 ]% c% B: T1 K6 {/ p$ n
yDir = "down";1 Q% h) @! L: Z9 K5 W
}
9 K/ w6 u" o$ N+ R, N }1 v+ h7 |# h) R U+ L& }0 ?! f# k$ @
if (xDir == "right") {" N3 L* v4 O; B
xPos = xPos + BallSpeed;! W+ P, K, n1 g5 m0 c' h6 k
}! V' g# d$ W7 O6 P0 E/ t
else if (xDir == "left") {
- a, `* _$ g* n xPos = xPos - BallSpeed;" `& s' E. V- B- x' r Y
}
4 S" w* ~" M/ `+ F; `9 L: Q else {
+ a5 I; H9 K& w8 ~/ K2 e% ?" | xPos = xPos;' P- z. d: o! Q2 S) y$ u, B
}0 X1 W/ x+ B& {, S3 M; h" q
if (yDir == "down") {5 P; p. T* W: Q& Y' m
yPos = yPos + BallSpeed;% Q0 U+ _# d( ^. f+ }
}9 h3 p4 u4 v9 F6 r
else if (yDir == "up") {
; H$ ]1 J9 Z+ P- t: s# i yPos = yPos - BallSpeed;$ Y# U, t8 N2 W8 K, C
}7 u `: Z8 i( {
else {
( G0 W& Q: K! ^3 i, z$ k yPos = yPos;
O7 I2 L) m' w% H5 m Y }
; i. _" Z0 X a }
' ?- |" k- ]/ _# d# r4 c: a/ T" n- Z- i2 e7 k) _
function hidetext(){
# y: s G2 ~( n) Sif (document.all)
0 K7 ]- }) e4 `3 o; ?4 ysupertext.style.visibility="hidden": |3 Z2 W, C2 E& r8 m
else if (document.layers)6 u2 u/ ~9 E- W9 B: q0 m
document.supertext.visibility="hide"
: ^0 ^4 q9 _! m9 @0 ]$ ~clearTimeout(animatetext)
/ f8 k4 J' S2 O3 g& _}
1 d2 F+ A2 W/ C# M; c6 x; }9 K0 M
c n8 q/ H9 G( v* R3 Kif (document.all||document.layers){$ t/ ~. i4 p6 L7 A$ ?. G0 t$ j
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')' ?1 T% t8 {) V5 |. D0 E2 ]
window.onload = initializeBall;0 k: p- Z9 i$ L# ?6 Z% s+ K' \
window.onresize = new Function("window.location.reload()");; d. |$ Y3 ?/ m4 f
}
* ^7 H" T+ m$ _" K
+ w: \& E3 D2 c</script> |
|