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

|
网页之不断弹射的文字-特效
<style type="text/css">, L: Q8 b. u, F! `
#supertext {
3 | u2 k& k2 R b7 iposition:absolute;
4 k1 i9 n- G. H/ D* k0 Hleft:0;5 [& z7 t! V2 c1 ~) p- s& u* b
top:0;! l4 t, L: D) l. y
visibility:hide;
; J) _! Q. ^; R4 b" Lvisibility:hidden;2 v9 l6 ^% F" ~2 U; O
}
9 j% i4 Y8 E# A3 {& E/ i</style>% C' N% d1 h) J# \5 z! i1 a
<script language="JavaScript1.2">! Y- v. D, F' E+ A; g4 y
<!-- 改变下的字体的大小。颜色-->
' s. e" a& D8 _ ]var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') `4 i% {, j. u4 {
var hidetimer='';
! \+ d. c" s8 E<!-- 改变下的弹跳速度-->1 M" r2 e& u5 o, @
var BallSpeed = 20;
* K( Z" l" Z) j" k5 @# |var contentWidth;; Y8 y5 E3 }7 B. g
var contentHeight;+ v3 r2 [+ k0 G8 s9 Q! q
var maxBallSpeed = 50;
) c# o1 b( f) @; A7 r B3 h# ^+ K6 Y' H2 k0 m/ d( [" Q
, O/ j4 T' ?9 w( e! l% A1 f# Vvar xMax;+ B- ]0 b- ]0 ]% \3 s2 a
var yMax;
! t9 V- U" l8 d, m+ ?/ jvar xPos = 0;+ n" h$ q% z* F/ Q1 X
var yPos = 0;# ^* s& b. W c
var xDir = 'right';
6 ~2 I" @, V2 D( Wvar yDir = 'down';8 Z9 | P. ~/ L, Z6 |3 m5 `4 X$ m
var superballRunning = true;2 F% m: @" T m! ~+ t" a
var tempBallSpeed;: d- m7 e0 b6 w/ E- u B. {
var currentBallSrc;
2 m6 X8 [: g; K3 M7 D6 m- g6 zvar newXDir;9 [+ {* b! @0 j8 c8 T8 k$ j1 t
var newYDir;
- K4 k+ R6 a8 b! H
+ i% @& c; }2 a$ j( V3 wfunction initializeBall() {; P( e. y; V1 d X3 J3 e
if (document.all) {- n& O& P- ?+ b+ I# t# e
xMax = document.body.clientWidth: Z8 D; t b$ ~/ V2 F6 U3 K5 i
yMax = document.body.clientHeight( R! n1 l8 c" I6 d! J
document.all("supertext").style.visibility = "visible";# p6 K! [- n: L: e0 j( ^
contentWidth=supertext.offsetWidth
+ r0 p6 c6 F$ O2 V) x; Q5 \ contentHeight=supertext.offsetHeight
" E) Y0 F9 C1 I) e }) }) G% b7 M( a4 L) f& L2 j1 X' r
else if (document.layers) {8 h8 E% G+ d% P* i: w% m3 y) F
xMax = window.innerWidth;
0 b# d8 S& |# Z; v4 a* o" | yMax = window.innerHeight;# \1 f! q. K& S. M0 L
contentWidth=document.supertext.document.width
/ Y) e4 H. d4 M; ?! C) E contentHeight=document.supertext.document.height% Q" t/ ?! [6 D8 U
document.layers["supertext"].visibility = "show";8 S f4 h6 D. h! h4 o
}7 g w5 B% u) u; b% @. N2 P' H
setTimeout('moveBall()',400);9 V( \6 s+ I0 ]4 S0 a4 l
if (hidetimer!='')! h- [; P, z7 t
setTimeout("hidetext()",hidetimer)
4 J, i. q4 Z/ I% U. g7 h U }0 d# C) D; }# Z1 L3 [8 O
4 |' C. A! M. T- R* Tfunction moveBall() {* I2 y2 r9 f% k1 _8 E* e
if (superballRunning == true) {2 t" c' N) j( B6 o# m; Y
calculatePosition();
2 d$ {1 L D; c& y if (document.all) {
7 e D2 _* U. j: I: e% ? document.all("supertext").style.left = xPos + document.body.scrollLeft;
* ^, b4 I0 s( D( I document.all("supertext").style.top = yPos + document.body.scrollTop;) D: n# ^( L8 }9 Y/ d4 }
}
* J2 \1 Y) t1 j+ _* a# t( U! o else if (document.layers) {+ K' P2 D' n( U7 {0 \# h/ `+ i
document.layers["supertext"].left = xPos + pageXOffset;" j4 R( r- n9 j7 ^2 j$ @5 T
document.layers["supertext"].top = yPos + pageYOffset;
& W8 \, V- |7 f% {1 A }* c5 M9 X9 s! S3 B& M
animatetext=setTimeout('moveBall()',20);
; |& E. m9 c. a }
: @0 B& m" W' o. Q, t2 m }6 A; X9 B+ N w0 B; |+ U) b
# y! a# m% k. e! ~ Z3 A5 u9 pfunction calculatePosition() {' d. w$ O# L$ z8 y) {( _/ i
if (xDir == "right") {
! R" w* o& ?: U+ R* ^ if (xPos > (xMax - contentWidth - BallSpeed)) {
( n, u4 I* G, g/ o3 j xDir = "left";) i5 I& E( T1 d% s
}3 C- `0 B# J+ a) ^6 h
}
8 I; E0 K! ?+ o8 b0 a% } else if (xDir == "left") {
% p5 [) O: b, D a; J if (xPos < (0 + BallSpeed)) {. V4 l- f) I# z* O: e% t& G+ c
xDir = "right";
. b9 m: R- _, x4 s }# k# }8 o0 E, N! Y! K0 N
}7 {8 O" j: f: S" t1 ~
if (yDir == "down") {& D, b5 |8 [# d% q# o: H
if (yPos > (yMax - contentHeight - BallSpeed)) {
" m g* c% L' ?; D yDir = "up";
2 V) S" \1 E* W; w- r3 R# R% y }5 A# k9 j+ c7 V2 e9 s, Y: C5 r
} f* h/ l- J+ b
else if (yDir == "up") {) ]8 P! K; q$ O
if (yPos < (0 + BallSpeed)) {
3 n) _: x) c5 x yDir = "down";2 d: @# l" X, S* G7 A- g
}
/ `6 k( `- D. x, `6 N. a$ J }
; g- N: u' E9 y/ p if (xDir == "right") {
0 k% \9 L8 M% ^* l6 K: T8 G0 K xPos = xPos + BallSpeed;0 P) B1 n9 Y! Y. Q
}
. T5 Z( p% L; I! ` else if (xDir == "left") {, H7 O5 i x7 W9 v3 |" u; e
xPos = xPos - BallSpeed; H' k }, } Z6 ?) c0 N7 P
}
0 J3 e$ C$ g* b. ~ else {! x5 m# b7 e, n! B4 F$ |
xPos = xPos;
" ~* A: \% R6 {) j# W }
1 K) U# w w/ h0 Y2 H- l* d if (yDir == "down") {# H7 R9 @0 m, w4 u7 r; e
yPos = yPos + BallSpeed;- p6 L" b7 {) u1 h+ K) \2 X' @4 ]
} a8 V; Q! K2 }" ^+ _
else if (yDir == "up") {
) @5 [: f8 {- @3 S yPos = yPos - BallSpeed;5 k t v2 ] `7 G: J
}
# S/ v& R, H; J0 ^' i% T1 V else {
4 C$ r) b' R' ]$ b" ^* w2 x( g yPos = yPos;" u8 e" H/ l! T2 h" t. M
}
7 p3 O& B9 Q+ `- Z }
3 K& Z/ ]3 z( k( L& T, N
$ ?$ s& @, C& r9 I, a8 y) _function hidetext(){+ ?' ]& K3 w9 z
if (document.all)
/ c- W' A- C3 A6 c/ o3 @6 Y% osupertext.style.visibility="hidden", G0 f' T' I7 o2 P# H; M/ _7 N
else if (document.layers)
- g- r5 b0 L+ F+ kdocument.supertext.visibility="hide"3 C b) y- k3 }& F, F3 @
clearTimeout(animatetext)
0 R5 a4 K, c1 R0 L}* ~0 A; T8 u) H3 j- B$ N
, V ] Y7 g8 T- N# fif (document.all||document.layers){
; ^% J* a- s2 _! v8 x% X! h1 M# p3 `document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. w5 ]- _# j$ f- U) m% gwindow.onload = initializeBall;; u9 Y# S% k; q, X/ {7 a* ?
window.onresize = new Function("window.location.reload()");4 n4 y! z$ v; u( a, m
}
& t! _) p9 Z. p- l1 r. E/ p
8 O- m& W; @' G" \</script> |
|