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

|
网页之不断弹射的文字-特效
<style type="text/css">% q& ~: Z# c2 c. V; `6 k
#supertext {3 Q9 K( A& m9 D0 u6 n
position:absolute;. W% A" i' }8 w% n
left:0;) L- w6 N# v4 ^1 u
top:0;
2 X: d+ B1 U# E) j) f" c7 t7 B1 dvisibility:hide;; d5 V3 O1 u8 S5 n7 W5 ^. t; @
visibility:hidden;, }8 P$ s: V5 h: `% X, t' {
} @8 \9 T0 O. m9 _+ s, v2 A
</style>$ N1 g: u( K8 F- i+ {) P
<script language="JavaScript1.2">7 F1 W5 s, J3 J+ }& H
<!-- 改变下的字体的大小。颜色-->+ @- s0 h; @' Z- ?8 s: V( H F' @
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ @& i" M8 h# l( M* s
var hidetimer='';
* i4 |* _1 U2 Q0 k% p<!-- 改变下的弹跳速度-->
8 I- S, A8 ^+ |! K/ nvar BallSpeed = 20;
! W1 b# }' b& Z' Q8 J# @var contentWidth;
1 j# u" G2 {0 a7 k+ tvar contentHeight;
% w5 j; v n: M- f S9 Z/ }0 |5 ~var maxBallSpeed = 50;
( ~. y8 C; Z) A! ^% C0 m8 N$ a3 z; a, T) i# b6 j: U
" J( ^$ r% ?1 F! l1 W7 g+ a9 Tvar xMax;
/ o: E' j$ o1 M; f# j6 ?: nvar yMax;
1 V0 C, L# F" E- ]var xPos = 0;
! K" M, K" |* B% E1 }var yPos = 0;* X# G2 k( ~/ ]9 Q0 W- \, `
var xDir = 'right';
, \; v/ X) l$ C+ B! jvar yDir = 'down';
5 n/ i: X+ ~, p/ ]8 e2 ^) ]var superballRunning = true;( j$ R! ^, J4 t" C) e+ Z% c
var tempBallSpeed;
) r% T" _9 |2 r6 A7 A# ^4 m) r$ V& wvar currentBallSrc;+ c% b2 x y' S3 T
var newXDir;3 \3 v" a2 T$ j6 Q: N7 l
var newYDir;0 d3 a4 Y6 Q$ p; ` b
6 H. n7 t% e. |* J% s& M5 Yfunction initializeBall() {
" s7 ]4 T; M9 H2 ^# v" a if (document.all) {
# C! a3 X/ W3 Y xMax = document.body.clientWidth% Y% V4 h5 z6 ?: Y2 g$ T
yMax = document.body.clientHeight+ Y$ ~& a& C, J! n: m, l
document.all("supertext").style.visibility = "visible";
' Z0 _0 Y+ I) J3 o contentWidth=supertext.offsetWidth) ?+ c/ ?* L+ D7 o$ A, y
contentHeight=supertext.offsetHeight
a; o- W1 U5 ^# k6 _$ R }, d) M3 S Y& ~: t$ I, l
else if (document.layers) {
, O6 \. i, B9 m+ g% z2 a xMax = window.innerWidth;. ~0 Q0 k1 `8 r% i. D! y: p9 G
yMax = window.innerHeight;3 V, l' n2 R3 X/ [; W
contentWidth=document.supertext.document.width* \. T3 a) e) m7 O& ~8 i( i: L
contentHeight=document.supertext.document.height
% w0 B# s; H2 H' J+ G: O9 r document.layers["supertext"].visibility = "show";
9 U4 {5 e8 d: n% s- i- ` }2 o1 d. i/ I: [* [9 y7 b3 K
setTimeout('moveBall()',400);
8 K. F/ m. q. A if (hidetimer!='')5 q! j) T0 Q! ?0 E) p/ K& y) Y' |' G) @
setTimeout("hidetext()",hidetimer)
2 v H. o7 t6 H u \2 ?- T5 N }. R4 B F) n W5 Y/ b0 l" V
5 f. F4 q- ]9 K! p# d8 T- V& ?& Ufunction moveBall() {2 r; n% g' {4 ~. o" N; [, e
if (superballRunning == true) {4 V2 x `9 B1 u* ]
calculatePosition();
1 A) M; ^4 V0 D7 X if (document.all) {. _$ h1 Y7 ^* R3 w- i; A
document.all("supertext").style.left = xPos + document.body.scrollLeft;
+ X, s8 m" R" F% _) i b8 D document.all("supertext").style.top = yPos + document.body.scrollTop;& i* V, y R6 p+ V/ N' q* w
}0 a `1 C) ?! f" _: Z- e6 _
else if (document.layers) {* R D* F! g* M, e: _
document.layers["supertext"].left = xPos + pageXOffset;
. U( U1 E; S: x" r4 i6 V5 q9 {0 C7 v document.layers["supertext"].top = yPos + pageYOffset;
/ m% Q) T# f8 V2 u" j }; s4 l/ T, C3 ~: l) j( |% g
animatetext=setTimeout('moveBall()',20);
' d% m8 S. e4 { }6 A, _) v/ w1 e
}' L/ F+ ~2 U8 ^) X* h
* X. ~: H7 [! f4 \: `function calculatePosition() {% L- W, I3 d' q- v* @$ D! D
if (xDir == "right") {4 B/ y; H1 s) j/ m. C& ^7 R
if (xPos > (xMax - contentWidth - BallSpeed)) {0 n+ D0 ?* G# l0 q9 y5 L+ E4 v; F
xDir = "left";+ D1 q* f+ H1 X6 ~
}
" R; u) w H, b }
* f7 A$ S0 n" q5 m' r/ I else if (xDir == "left") {& m$ l: a ^5 _8 h/ C
if (xPos < (0 + BallSpeed)) {
( P# z: ^6 g$ o* p* ]- L7 }- w xDir = "right";/ ?) m/ j4 }: a% k' d
}
1 |$ `( a0 N" j! ]( N# f9 i }
' r( ^; `* s2 A: a2 u! d if (yDir == "down") {9 s+ L& l3 g. F1 o* X0 n3 @5 L- K
if (yPos > (yMax - contentHeight - BallSpeed)) {5 g9 L# S5 [+ o4 b8 p# H
yDir = "up";
- D/ _4 K8 t' f }+ U5 h7 ^" b* e8 B. }0 o
}& f) U/ r! q) o/ _7 \7 O$ Q$ A' v
else if (yDir == "up") {
7 }: R- m: [3 h: W) S/ B9 B if (yPos < (0 + BallSpeed)) {
T/ G8 F. d9 J2 l; R yDir = "down";: G' Z# ^" T4 A* M! |0 F
}
, O* A8 n! A" d3 z6 x4 @6 o" Q }0 M) b0 ` {$ M. X- d" e
if (xDir == "right") {
L4 s$ R8 N) ]9 E) h xPos = xPos + BallSpeed;9 d0 }( L+ D% V% g6 Q
}
( p; J" l0 B0 D1 O else if (xDir == "left") {9 A: [) I& b. H" |) E' x) I
xPos = xPos - BallSpeed;2 W, \3 M6 U, [1 g) y
}
0 ?+ {- V5 N1 c' A( _$ O else {
1 X0 B7 w- I3 W- Q3 N( J xPos = xPos;0 G/ I3 O- j6 b
}9 F9 l# b* M1 ]' e
if (yDir == "down") {
@. X d1 d( o) X8 k yPos = yPos + BallSpeed;
7 P7 L! Z) _# B$ s; H e }( q6 @0 Q' `; e c+ K) {2 `) X! _
else if (yDir == "up") { Q' J5 u& J- |0 y5 K
yPos = yPos - BallSpeed; e( {( x- H6 b/ _- z$ r0 a
}# i5 x6 O* [# q6 R( p1 p$ C
else {) |) j) e0 D, O) z M! x
yPos = yPos;
% u2 C6 N/ }! W& v5 |4 }7 f }
# V0 k7 G& Y) S5 o0 m- i }/ V. ^- I" P+ X) h
! j% c* d% d- W( H1 N! a9 Mfunction hidetext(){" C, `- K: {0 e1 f
if (document.all)
: X6 P7 J5 r5 S+ _3 |' T- h8 psupertext.style.visibility="hidden"
# l( w# K( k% helse if (document.layers)
) u8 S4 D! O+ B7 c9 R' E$ Ldocument.supertext.visibility="hide"
' c: a$ h% H: p/ c$ ^$ a, HclearTimeout(animatetext)
- [ _ c- r( q7 K/ w. Z}
/ h5 @ C" s% X1 l) h- w; c* ^( j; `2 s/ e
if (document.all||document.layers){& s% N9 [5 J: X+ w! n/ o6 }
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')8 U: Y! z6 i! t. z
window.onload = initializeBall;
: ~/ ?" R7 x, Y, Wwindow.onresize = new Function("window.location.reload()");
! S" f1 w4 R, C9 B. N}- A: u+ E' l+ i Y Z4 v8 r
; F' z9 W. Y4 I; m# i( a+ o; |) R6 W
</script> |
|