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

|
网页之不断弹射的文字-特效
<style type="text/css">; f- C8 c& b5 R @7 A0 ]
#supertext {5 y0 E- I# @ W: D' Z- t
position:absolute;
9 j5 g) C. P3 y- B3 D9 e8 Nleft:0;
% e/ t& C3 E! |top:0; D& n5 L6 A/ Y3 u. V( O+ A
visibility:hide;
9 ]5 _$ K* r. m! r' c8 f, l" ovisibility:hidden;0 A& H$ l1 r+ h: ~
}; W2 ]1 b+ N* o5 X
</style>
5 B% k. a' s* d<script language="JavaScript1.2">8 Q1 ^, v% g' l3 P& q, R( q
<!-- 改变下的字体的大小。颜色-->
& `, o4 v% b$ S8 M1 P/ Dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ m: b2 ]4 A, _5 y& B8 @; z
var hidetimer='';
& @( d% G0 C$ h" y5 X<!-- 改变下的弹跳速度-->) c% {2 i" N0 b- M% t K
var BallSpeed = 20;
4 v' t* L/ U# O; u( mvar contentWidth;! J: m5 y2 B/ H) W% T" ~
var contentHeight;
3 q9 x8 ?+ A6 l0 @- a! H; Z) Q, Yvar maxBallSpeed = 50;4 \6 g! L) r' A; P
* e9 t% T1 w3 ^. x3 P: m
8 G3 J" q; X9 A3 _7 W8 {% d: b
var xMax;
$ n9 M: B( L4 A' [+ o1 Nvar yMax;
6 y' U' H1 R* |! X `7 o* o Qvar xPos = 0;
$ V3 `, b: m+ L* M; h. Gvar yPos = 0;$ U- y& s8 Q! ~% r! o0 l
var xDir = 'right'; I: a$ f9 H) I$ F/ W
var yDir = 'down';
3 T. h$ B) m' b% {var superballRunning = true;
6 I' w! p: E$ Hvar tempBallSpeed;
6 c3 |; e5 f5 }var currentBallSrc;' l2 M( M+ d5 r
var newXDir;' j' @0 r, \8 M5 w+ P0 S, V/ X
var newYDir;. c6 u* Y, U3 X3 k9 f$ H+ X
! j; k0 u7 e$ I6 y; r
function initializeBall() {
5 c6 m; J7 u! @. p, H$ M" d) X if (document.all) {5 I9 Q' T7 {! a! {6 y
xMax = document.body.clientWidth3 V8 H9 r% x X. S+ m; t5 L: G/ P' H/ h
yMax = document.body.clientHeight
: _. w9 w0 V, j) i* M9 @9 C document.all("supertext").style.visibility = "visible";# W3 h5 G8 c9 ~/ H* C+ I2 ^0 G8 G' _
contentWidth=supertext.offsetWidth
3 F1 P# Y) D: ` contentHeight=supertext.offsetHeight; Z- Y8 c$ d$ g1 k0 x
}" j7 y4 F! J+ @
else if (document.layers) {
3 L# i. `$ N. p1 I( s2 R& P xMax = window.innerWidth;7 A% E5 r) }/ @
yMax = window.innerHeight;* x0 O9 z& o$ X. C
contentWidth=document.supertext.document.width
7 _0 w$ Q M( m8 Y contentHeight=document.supertext.document.height
2 |) R; R4 g- w! H% l2 O% C document.layers["supertext"].visibility = "show";
U# P4 a! N' L0 o h6 `$ i }
- H6 ~* G1 h- I1 N setTimeout('moveBall()',400);
# B' n4 x2 W/ z: w! E if (hidetimer!='')
& I+ H& c* x2 o setTimeout("hidetext()",hidetimer)
% Z$ S& J! C7 E }7 i; g( g- E1 G; p" _3 a4 F" u- M
5 ^# `( e+ k2 u" |$ c* Ffunction moveBall() {
6 A, B0 F$ z$ v0 ?: c( ?1 I+ `" h if (superballRunning == true) {8 Y; ^+ P7 C' x, w
calculatePosition();
& R* Y3 \6 |5 N! ]* O! V if (document.all) {; G1 n/ N) | d7 P( c, c
document.all("supertext").style.left = xPos + document.body.scrollLeft;" ~) e4 z6 E0 q$ h6 P6 A
document.all("supertext").style.top = yPos + document.body.scrollTop;
/ y. V' S% v0 ^* h6 M8 b }
* P! u( X2 n3 H# Z( L else if (document.layers) {" M& W6 `; g6 O8 U
document.layers["supertext"].left = xPos + pageXOffset;) k# A$ M# E* P: R* w3 y
document.layers["supertext"].top = yPos + pageYOffset;+ j# u- Z0 {4 x/ o) I5 M/ i
}. `; P8 d: V9 j( a2 d; a
animatetext=setTimeout('moveBall()',20);
$ u6 w! L( ~! p) q5 _) k3 s* i: { }6 t0 e2 X! G/ k/ U
}
4 D0 R4 }) }- s$ t: S
5 q5 M' I* o6 Y: R# ~$ Q) w3 m+ Zfunction calculatePosition() {1 e* K, i) O0 F) [& k
if (xDir == "right") {; g6 c6 z* I1 z1 O' E
if (xPos > (xMax - contentWidth - BallSpeed)) {
9 G7 \ j1 j; V& g6 A xDir = "left";8 R" h4 m9 u0 p, ?, B
}& _1 J- f7 u- R* s
}
- G1 C3 w" r/ W& F else if (xDir == "left") {
& w" h+ {, i0 H3 J2 v if (xPos < (0 + BallSpeed)) {, E1 T' P8 _! _9 G1 q$ |# N
xDir = "right";2 _: f2 _* z, z6 X9 a7 n" z
}
% M( z* H8 W" o0 [* o) Q: C }' j& k, j5 M1 i: R9 w9 i
if (yDir == "down") {" ^2 S$ ~# Y- T5 H* U v
if (yPos > (yMax - contentHeight - BallSpeed)) {! `$ B+ a" B/ s0 k) A( J
yDir = "up";
0 f. Q1 A& ^1 M- e6 D- r$ [ }
4 D4 L: }0 I$ |" I' j& Y7 c- V }
/ d# e1 O0 o: I# G& w, A; ?0 ] else if (yDir == "up") {
3 l6 u0 h/ @. z! d4 E! ^ if (yPos < (0 + BallSpeed)) {
9 J h' u) {" Y' r yDir = "down";
7 i9 x) X- {* D9 K7 D, f }- o D! l% @0 Q) B4 ~8 M
}
5 }1 j( c: w S9 j, i if (xDir == "right") {
/ V1 C7 h" h% M2 v5 ~, S xPos = xPos + BallSpeed;
7 E. w; k- B w8 y% i0 l- x }
, g& ^" E" D. f# }) t- |4 V else if (xDir == "left") {8 F2 d$ P8 x/ O! x0 c7 T+ X7 m: b
xPos = xPos - BallSpeed;
; h$ ~6 B- [) R }
! x- b# W2 E; a7 g$ V else {
4 @8 V$ B* g' m' J, [ xPos = xPos;
5 P' w- `$ Q+ \9 |0 H: \ }
0 B. y' k2 q, t# {& i0 U' ~) p( a if (yDir == "down") {- z c e3 R6 g+ ~2 L4 I f, G
yPos = yPos + BallSpeed;& f$ v6 Q1 ]7 Q
}5 t' P' E% l1 Y4 r
else if (yDir == "up") {7 J; v3 \* Z% m
yPos = yPos - BallSpeed;
( [/ W8 o: l7 g8 G) \- h }
7 m% e+ U8 ]2 K else {, Z9 E. g$ x0 o+ d
yPos = yPos;* j5 {1 ]1 o" q6 n2 | R- a$ _
}2 [- h$ G7 _ v
}
0 ~& U5 E$ r* j* ?) ~" x2 _
6 A E* f% h0 K$ E$ t7 Ifunction hidetext(){! V$ m5 o/ e7 n4 n2 A' y/ t
if (document.all)
$ B/ }, r6 R2 L+ I2 zsupertext.style.visibility="hidden"4 n; r4 c- C) Z8 x X) e1 E; p
else if (document.layers)
3 C" O8 E' C# A0 qdocument.supertext.visibility="hide"% Q, f( t6 \( `. A& ?
clearTimeout(animatetext)
$ v9 S$ R! i$ O2 K/ o6 m}' _, i7 I5 n- j0 g' e% T- J
6 c! n1 g" l h$ f, n% ~- P2 |if (document.all||document.layers){
' }% h7 |( _6 h7 T; T( rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# j% [* m4 J/ b/ Y% O6 }, ?4 p6 Hwindow.onload = initializeBall;4 ~$ i( b' I9 S$ F6 }
window.onresize = new Function("window.location.reload()");, m0 D" W" n3 c- h- P8 y
}
, b' W; }. u/ I1 y6 }$ t4 L, f6 b. H# o3 J h
</script> |
|