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

|
网页之不断弹射的文字-特效
<style type="text/css">
; J. | J& ^; c1 i4 J `. n: A M#supertext {! c* M! y4 y9 y3 F I
position:absolute;& K0 K0 R0 b# H- w6 y5 X7 }# R
left:0;
( W @; x# ^( @4 htop:0;
# ?2 ^& M5 ?9 V/ l, F' V {visibility:hide;& ~) [4 T6 F5 o
visibility:hidden;
- r" a! u6 A1 \# G# T}- O3 ^% Y4 z+ S( _
</style>( b0 q2 _; p2 m7 L) S
<script language="JavaScript1.2">. _' C# z# r( S( N! U
<!-- 改变下的字体的大小。颜色-->5 V- f" R5 N4 N! K* A
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
$ k+ r, t# y# T) @/ fvar hidetimer='';( P' m/ i- R& }; F
<!-- 改变下的弹跳速度-->
! z( z3 m1 O1 N! bvar BallSpeed = 20;
3 f& ]+ D; d5 d: v6 gvar contentWidth;
8 a" D3 X9 a) [" _* xvar contentHeight;
- ]: O) |$ e5 ~) evar maxBallSpeed = 50;
+ {% f& u: W+ A7 { A
. ]4 Y7 ~' Q! b+ d, ^8 j; @2 `
& ?5 S/ Z$ L& j- f. D4 lvar xMax;; [3 s, a: Y3 U8 q% E# U
var yMax;
K% ?$ e, P. G* q X: o4 V3 F4 F( ^var xPos = 0;
: C5 _4 v( {) c! \8 Lvar yPos = 0;# i; R' {- Y- }3 O3 J! R4 S
var xDir = 'right';. y0 f9 i2 {( ?
var yDir = 'down';
0 B! G8 e1 c9 h+ R* pvar superballRunning = true;: `& H+ ], ^ C/ F f+ |' d9 r
var tempBallSpeed;
/ ?7 k2 s1 v8 Nvar currentBallSrc;1 Z6 ^4 Z* w, D
var newXDir;
8 c/ f; x# f4 f. svar newYDir;
$ v, M9 }) M5 {; p; o2 n G) I
; L) c5 k$ p6 Sfunction initializeBall() {; o$ S5 X; T( A
if (document.all) {
6 B9 \( D& s1 i5 J% A# G n9 } xMax = document.body.clientWidth3 K; F) ^8 F* b2 i0 R) U
yMax = document.body.clientHeight
. M& M- \: P6 Y# i; G! Q7 g document.all("supertext").style.visibility = "visible";
( Y5 l2 b% F7 a contentWidth=supertext.offsetWidth+ ?: h! v' N7 U
contentHeight=supertext.offsetHeight/ c9 o% C4 ^% H& H8 F$ R
}
e C2 _+ \8 R9 {/ h) a6 { else if (document.layers) {
. E5 j3 v* l# l& ^1 I6 [ xMax = window.innerWidth;, A$ ]+ d" V1 C; X2 M
yMax = window.innerHeight;
5 n9 r9 u1 L4 _ contentWidth=document.supertext.document.width3 Y7 T" g3 {9 J9 i
contentHeight=document.supertext.document.height
4 ^+ T7 _" Z m/ n! K" f document.layers["supertext"].visibility = "show";6 Y$ p* L! c( w u
}8 j" [& A' a/ i6 U5 F# n
setTimeout('moveBall()',400);
$ q, u( C. E! M0 _5 { if (hidetimer!='')
' B/ ]: u4 U: [ E setTimeout("hidetext()",hidetimer)
4 y. S- A% U7 N9 t$ U }
8 J( Q+ Q" K, W3 X# U, G$ x. \; Q' {. Q6 A* T
function moveBall() {% u/ G: s( r" F, s; s( i
if (superballRunning == true) {
! v Q4 R% v8 H. ]' U0 L calculatePosition();
# v# D0 f5 y7 H' S% J if (document.all) {, q. O9 q7 |5 G! c6 X# Y
document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ i) y: H& u% ? document.all("supertext").style.top = yPos + document.body.scrollTop;
/ p) `2 g6 s4 x) u3 n0 p" H }" v: |+ q0 o9 ~, a6 O2 Z
else if (document.layers) { l* |6 E& `- f8 T: k& ^
document.layers["supertext"].left = xPos + pageXOffset;
8 o4 K2 a" s, r5 c$ l& L document.layers["supertext"].top = yPos + pageYOffset;2 T: b. H Q, O8 G* U4 i
}
$ Y0 a# o2 N( t5 q f" d' d% B animatetext=setTimeout('moveBall()',20);
: p/ ^1 U: m( y' E1 N1 k' _0 a3 T }
+ x/ p: Q2 ]1 b6 X7 ~; ]- j1 S( H }
4 V7 F2 f$ `, {4 _5 A
) H. T6 r) A1 z( P, Gfunction calculatePosition() {
! ~$ h* u d- A/ ^+ H U if (xDir == "right") {
# z7 c3 l8 e) Y3 u& x: w" a% m q' u if (xPos > (xMax - contentWidth - BallSpeed)) {
" k9 @% ]6 u( ^( [ xDir = "left";
1 c0 J, b! z7 `; E }
* i' M9 Y- J6 h. p5 u3 E4 M4 @ }! ]9 H. Z, y% w
else if (xDir == "left") {
9 m% v. U1 z9 x, U if (xPos < (0 + BallSpeed)) {) z1 Z4 @1 j0 w6 L* v8 P
xDir = "right";9 M' b0 U3 l0 {$ x; |9 K
}- y2 m: P Y2 Y8 T `7 Q; @
}# ]/ w% E$ E% T* j
if (yDir == "down") {
( Z3 Z+ D- }5 |5 R4 d V2 C if (yPos > (yMax - contentHeight - BallSpeed)) {! e% Z6 s* t/ u* G
yDir = "up";, I7 v/ Y! r) P2 a+ @1 e
}
* I! Z0 M0 C: ?; m" Y) E! d }
) _2 v; q4 _* W; K. v2 H* A else if (yDir == "up") {5 Y T4 ?' j; h. i b. \
if (yPos < (0 + BallSpeed)) {
' l7 T/ P& ]: h yDir = "down";+ I+ S% M" M$ m. a& n4 a% G
}
, K0 k' B4 {, v, Z q7 ? }
; K( g3 \0 g( d/ Y- A( ?/ B4 { if (xDir == "right") {
! a. \% b: v/ @4 H4 M xPos = xPos + BallSpeed;9 ~" Q1 ^/ l3 p6 D3 ]1 F4 d
}
% t1 T# n* W6 M! J5 z- r else if (xDir == "left") {
& U) P+ m* l4 x: d) { xPos = xPos - BallSpeed;
) M, J! ]7 b7 y3 X. ^8 u }" n4 [' _. j/ @8 u! D6 h0 p/ ?# w9 f2 o
else {
" w+ ~( p) \% y) U- x6 p, f xPos = xPos;
% D" j! V& y( e) A7 j }. t4 ?- J5 A" D
if (yDir == "down") {5 f2 W/ q2 ]* l6 i* g! ^$ w
yPos = yPos + BallSpeed;
; w+ Y, V# d6 k! K$ i }( f% g' ?. u8 K; v
else if (yDir == "up") {- y2 K4 K9 { G" J6 o7 `# [
yPos = yPos - BallSpeed;
& C8 \6 r4 `& Z8 t+ f- ^, ]9 s }
' o: ]) `. S; B. K else {
1 u- X, K4 D6 g& H! F' I3 n+ O yPos = yPos;
- @/ n# F: T5 r0 Q/ c* ?5 ? }1 _- j$ t% U, t; E
}' S' K4 }! @' S' u. ?' T# h
. u% @# d3 {* n: h* O
function hidetext(){6 |) J1 Q; W( ^9 a9 j: s* r7 l/ x
if (document.all)- s' Z T, G; O! N5 g
supertext.style.visibility="hidden"$ H7 t, c! ~; ]( G- \. K7 W3 p7 w& P) f
else if (document.layers)& f6 H' G9 K& s8 Z
document.supertext.visibility="hide"; C6 r9 r$ I3 B* m E" C8 s6 M
clearTimeout(animatetext): S' z0 o' ]0 y
}
8 R$ t5 O" p/ _) Z i1 I0 @/ ]1 c7 d% S) ? K
if (document.all||document.layers){
2 S9 d& G2 N; W) V, N3 ?: n; Ddocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
+ z* [8 U/ \+ Z/ v1 h6 [window.onload = initializeBall;3 ^. X9 p9 ?) t v9 Z
window.onresize = new Function("window.location.reload()");2 ^' i' d+ A C9 S
}
8 ]3 o: D1 T6 t9 k" E
3 f: C) @ {' F& |( _2 u3 E</script> |
|