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

|
网页之不断弹射的文字-特效
<style type="text/css"># {2 n0 j1 e* j/ k+ V( k
#supertext {
5 k1 ^4 l i; H# f1 v' g$ [position:absolute;7 g g/ U8 c5 @; u% w% d* S" h
left:0;
! U) Z! a: X, H' R/ Wtop:0;
# |8 L0 ], X1 Q# T) uvisibility:hide;6 R* b! E& w2 J
visibility:hidden;
' a* _8 O5 C# F' L5 K& @; }& D- ^}& `1 g! W% ]2 e% _ r
</style>
8 I1 q) W. j: F5 k* U* D" C<script language="JavaScript1.2">
$ Q$ ~3 h) w8 k% O1 ^<!-- 改变下的字体的大小。颜色--># e9 W2 \: _. I' ]4 c
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 t' s: }6 q: Y/ i& H2 p& Bvar hidetimer='';1 E7 i1 ~2 O' @- `/ R! @4 I
<!-- 改变下的弹跳速度-->1 ] P% D& S0 n! I) X5 u$ v
var BallSpeed = 20;; [* J f5 p" F7 m
var contentWidth;
( w) E3 Q, r4 H2 e1 x) m! I6 V/ {var contentHeight;( h4 @; z5 k; b( e! A8 ]; k
var maxBallSpeed = 50;* }: [, y" b+ f1 K- Q3 f0 f) @* m
! w$ T7 T2 E n$ x
4 Y3 T1 ]+ E: u5 x8 i+ O: @var xMax;
" k1 f, n; Z6 P! K% H7 X) hvar yMax;
/ b1 n! L3 P' h6 s% D. Svar xPos = 0;& _ x# C, f0 S$ V2 z
var yPos = 0;
9 E4 j8 o# l5 n# I2 s% A$ _var xDir = 'right';
$ L5 W, s' U3 B1 d y8 Bvar yDir = 'down';( G2 V4 d! o6 g) o1 \; J7 o
var superballRunning = true;
+ M1 J/ j1 `' i$ S5 E: D7 }0 gvar tempBallSpeed;9 V# k3 {& V2 @1 R; `3 s$ w9 j k
var currentBallSrc;
, k, P5 ]$ Y+ ^. F( G& |/ qvar newXDir;
" r0 h, `+ p9 a8 p! N) r% Hvar newYDir;7 a: H' n% R6 F( j5 Q8 K& @
, G5 l4 g! B8 j% M" @function initializeBall() {' n3 S, J3 G, E) }6 Q
if (document.all) {
9 M& [8 \- P! M3 @2 y1 o: @, L xMax = document.body.clientWidth
. ]: _- q% m' ? yMax = document.body.clientHeight# W& K! I% i2 {+ @( ~7 Q
document.all("supertext").style.visibility = "visible";4 Z6 ]. A% v0 R8 z% J& D3 X" h
contentWidth=supertext.offsetWidth1 D) }" L. B2 n
contentHeight=supertext.offsetHeight
6 q. s- h" t' x! j% E7 W+ B/ ^ }+ n7 v" u1 E' Y0 x* X& S
else if (document.layers) {
; l& n1 W8 h: f0 E9 I xMax = window.innerWidth;2 [, T: A7 C0 ?7 E! J; A
yMax = window.innerHeight;1 ^2 _! k& ^7 @' X1 r1 a& ~( E
contentWidth=document.supertext.document.width+ k/ C* H/ p3 q" f# u* @7 l* W
contentHeight=document.supertext.document.height: s4 m8 K9 _" u$ e
document.layers["supertext"].visibility = "show";
% M5 M1 Y$ t5 e/ ]; M+ I. l: O( F }
3 c* u+ J5 b; [( ?3 L. ~7 { setTimeout('moveBall()',400);2 @' N; q. e' M" U+ I6 \% i
if (hidetimer!='')
: x7 z% j6 n; w n( H setTimeout("hidetext()",hidetimer)
+ U7 w: _5 o1 K' e- N3 _ }
! R( O5 R( F: u& i) }, x* H# e1 ]
) t+ g) Q6 S! ^" T; \2 dfunction moveBall() {' o* ] S# s J- A' m: g8 b' r& K% i4 N
if (superballRunning == true) {( `2 h- s* o) p: g K/ C5 f
calculatePosition();
+ l( ~" Q. k* r- {3 F. e if (document.all) {
3 y$ ? e6 f6 k6 T' z! n, E, s3 ?5 q document.all("supertext").style.left = xPos + document.body.scrollLeft;* X5 F/ N f2 T
document.all("supertext").style.top = yPos + document.body.scrollTop;
6 w" a3 u e7 c' W5 d }
: N' t5 |2 h6 y& _ else if (document.layers) {
: _$ c! D$ K- W: {" [ document.layers["supertext"].left = xPos + pageXOffset;! J; u* {1 l. [
document.layers["supertext"].top = yPos + pageYOffset;8 e/ [ n# f7 y5 ]0 l
}
9 x! f/ K5 ?: @6 o animatetext=setTimeout('moveBall()',20);
: Y+ J% A# |* K) b0 ~5 A+ `& h }4 f% e6 X0 F( M6 K; s9 y/ L
}
/ y! F4 o' V b- E# o
2 P+ C# l2 B2 U. Qfunction calculatePosition() {$ U1 I& @1 l+ `+ G( M4 ]) d( V
if (xDir == "right") {4 d) s2 Q$ o1 b
if (xPos > (xMax - contentWidth - BallSpeed)) {
3 c) p6 C' N5 C/ O4 Q3 Y ~ xDir = "left";3 g2 c. J6 g; q) H" y
}* \& s8 Z6 m- d; ?" k
}
7 d6 N; G- M5 R9 | else if (xDir == "left") {
% X9 B7 ~7 j3 o* V0 M/ d7 O if (xPos < (0 + BallSpeed)) {9 ?7 v2 J& K( [" X) Y
xDir = "right";
& w/ F( h* L7 A# | }5 j) L1 G3 R' c! Q. i7 Q
}
3 S: v, j0 P4 x, F7 p* u if (yDir == "down") {
) y2 C! n) I# _+ [ if (yPos > (yMax - contentHeight - BallSpeed)) {
# ?/ J0 V& j& d) P$ K yDir = "up";
" t) h& N/ K& i' Y }- f" {7 r. ?# _, ^4 c
}! M8 D, g0 U' |9 f8 Y* U
else if (yDir == "up") {7 Z2 q+ c" z: G, I0 ]- h# v: J
if (yPos < (0 + BallSpeed)) {
& m9 a7 d$ [9 [3 r/ |% ^ yDir = "down";8 \2 Z5 U0 J& v# M
}
" u: v2 Q# P9 Y h2 w/ W7 k }8 r4 L& s( W6 p) i) S6 b6 ^
if (xDir == "right") {
' {% {( {- t! o+ t, r/ w/ V' i xPos = xPos + BallSpeed;" a# z. Z) ` t5 c9 E3 f
}
: X7 y' @7 M- P6 p+ b else if (xDir == "left") {# R' i1 q4 O, N" K& q6 C; r/ r
xPos = xPos - BallSpeed;
; Y% ^( |; y7 |1 S }
! N6 ]/ a1 q8 ? else {; H: N$ |# s2 F; d' e
xPos = xPos;% z j! ?# i: S5 c& {7 e8 E
}* B0 w- ^. K7 n
if (yDir == "down") {
& x& h. K! i6 c- l" p7 F yPos = yPos + BallSpeed;- p- _, H- t3 `! ], F
}
2 ~2 M; ^; A' z- l" l else if (yDir == "up") {8 `* k$ Q5 S$ o( ]) v
yPos = yPos - BallSpeed;
/ ?- S8 n! \; f4 G! T; { Y }
# ?4 N. @/ [9 X8 q9 s9 F, g2 u else {) D5 P/ V7 I. C6 P* k6 w6 }7 G2 a
yPos = yPos;" v' B, }2 W" f
}+ L$ c' V* c! a3 h# s9 i$ A/ I
}& A t3 W2 n4 }; T4 A. Y
, z5 I7 b7 }6 Ffunction hidetext(){
) a d! @) h( g, _4 \if (document.all)
/ E8 Z9 a, {; y% N1 v0 [/ Z) Asupertext.style.visibility="hidden"' O+ r/ ]+ P! {- h
else if (document.layers)
7 G: \" |( d. j6 c4 p3 g2 E a/ Jdocument.supertext.visibility="hide"! R+ W" ^3 g+ m, g |
clearTimeout(animatetext)
i p4 k3 T# |9 Q* m7 }}
$ a! t7 Z( }) ^4 I7 Z5 |" P$ q, R, c/ w' R0 j7 V7 \% U6 X
if (document.all||document.layers){5 E) z* I w1 o# E$ T1 s
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ t, X& n: d0 _
window.onload = initializeBall;/ z: r& I- |' h& I& [- ]2 b
window.onresize = new Function("window.location.reload()");
/ G% Y* K6 E- P0 J}
& S/ ~9 C- l3 V; `# L
5 O: @) e2 }) e' y# U: Z8 W8 [</script> |
|