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

|
网页之不断弹射的文字-特效
<style type="text/css">- P4 s/ Y2 a K
#supertext {+ H) [* z; ?( i+ B
position:absolute;
- F- L) x- L, z1 }' W' m- I: Fleft:0;
7 G# m3 h; Q4 P# b) @) ]* gtop:0;
* @" I$ b# Q8 L7 X* ivisibility:hide;
+ s: \5 N7 T8 Xvisibility:hidden;- c5 Q6 q8 M% O8 T
}4 X& A7 O+ M( Y' w# \
</style>0 t" }& Q- h% u" ?, _ `& e
<script language="JavaScript1.2">( _: o8 ]) \+ ?7 o
<!-- 改变下的字体的大小。颜色--> t" \! p$ p2 U8 j: l
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'6 Z* G5 d0 N0 d' b, h. `
var hidetimer='';/ L5 o2 Q" Z2 O1 j: V; k* b
<!-- 改变下的弹跳速度-->
$ v& X9 I- Q [0 }3 s2 `var BallSpeed = 20;
8 i7 m( {& q0 Tvar contentWidth;# @* ^: U9 \. J
var contentHeight;3 z+ W1 f* U, t$ R0 y
var maxBallSpeed = 50;/ y" r4 H7 ` x
; r/ O" n' c5 K9 N2 E" F8 ?
/ }5 t: W4 {0 X/ c1 X2 D6 T
var xMax;
, l! s, B7 W7 zvar yMax;
0 R( U( A* m! P! O) _! Wvar xPos = 0;
+ E: \) @3 A# }/ f! e* l3 H, }var yPos = 0;- ~5 ?* M2 w# h. g$ m
var xDir = 'right';
8 ^2 F1 b B% gvar yDir = 'down';% b" I8 X8 E0 d% |; e. L; n. ?
var superballRunning = true;
V- r4 z$ z8 |; {. ]- k. }var tempBallSpeed;
, h! E1 I) L" c/ u9 ?! j Y( Evar currentBallSrc;0 {- j$ m) B* P
var newXDir;
4 t3 o: O- p1 V+ Q6 @var newYDir;
; I- l2 ~' _4 A; k" A
1 C0 ]# U, J! e3 T0 Q2 v$ k* w* {- pfunction initializeBall() {- r% i0 J+ P, b
if (document.all) { ~- ^& s6 `# n( f/ K! C, f/ q+ |
xMax = document.body.clientWidth
% H2 Z6 ]% m# h2 D3 A _) Z yMax = document.body.clientHeight* o" [% r& G& A$ b ]2 K+ M4 N
document.all("supertext").style.visibility = "visible";
: W+ c. @+ m- j, g5 p' A' y0 u contentWidth=supertext.offsetWidth0 R" @8 u/ X G+ a( o! p1 B" x
contentHeight=supertext.offsetHeight
# o; f, C+ N+ l( D }4 q3 s$ T( b9 s' F
else if (document.layers) {9 J# b% p( W/ G7 o3 P
xMax = window.innerWidth;$ a3 s9 K' D/ b! m l! t
yMax = window.innerHeight;
, Y0 N7 C% x5 e contentWidth=document.supertext.document.width7 D+ g9 j, L# T
contentHeight=document.supertext.document.height1 V1 G: `8 ~ E
document.layers["supertext"].visibility = "show";
+ Q3 D j2 j5 \* w+ ]9 t6 C }. I2 m9 y$ {1 ^' a' H- s A( q9 f
setTimeout('moveBall()',400);% L" a. w/ X7 H
if (hidetimer!='')
& C" M/ l$ f9 m [9 g3 P setTimeout("hidetext()",hidetimer)
. W' K) d6 e2 z3 K, K }
( P3 M: u8 `, u1 t+ n/ x5 S9 D- d3 E1 g: |2 o g% b$ M
function moveBall() {
* S/ R5 A+ ]' o, H, m3 {8 G- y if (superballRunning == true) {4 @. E% Y9 g! Q: ^1 P
calculatePosition();& g, q% H, N1 |8 L7 q
if (document.all) {0 S# L0 [* z6 A$ y/ T
document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ D' |7 o/ x4 n! F/ `0 `0 h% c9 { document.all("supertext").style.top = yPos + document.body.scrollTop;! y1 M* j/ i! N* z# e6 A: Q2 J% Y
}; q% T# N7 ?, _3 o- [9 C
else if (document.layers) {
- F# W- Z/ c6 g0 a3 T0 {9 h: n document.layers["supertext"].left = xPos + pageXOffset;" A! z o: p" N' W: }' ?6 P
document.layers["supertext"].top = yPos + pageYOffset;
* F& R2 z' H5 X) a0 E2 ^( X( u }
9 B9 v! S4 |0 ~ animatetext=setTimeout('moveBall()',20);. R- k$ u; _' D6 Q& i
}8 H# p' ], m, ?4 }: D6 B- w
}9 ]) d t- R; n3 B4 i7 q v2 K
5 Z" Q% j$ u) k% z3 z& {3 x( x
function calculatePosition() {
9 e! T- W0 p2 ]0 z if (xDir == "right") {) T# U3 {# c/ Z
if (xPos > (xMax - contentWidth - BallSpeed)) {
: |' m( F( `6 r2 K! |4 }3 t" } xDir = "left";- m2 ~9 V2 f8 j5 n; c6 |
}
( N6 m2 U2 Z) I4 k3 n- {# Q }
" q7 b& I; ^; w1 q' p O/ { else if (xDir == "left") {" ]. n" Q0 C! b) p6 k
if (xPos < (0 + BallSpeed)) { v c8 \$ t: | V3 x: e) W3 q" A
xDir = "right";% Z1 w0 p" M) f5 V- e5 v" D! |
}
0 ]7 L/ m4 K" P$ h. G }5 ~4 ]6 n7 Y0 M+ f' @) D4 Y- V
if (yDir == "down") {5 @+ m) _6 |" D9 k
if (yPos > (yMax - contentHeight - BallSpeed)) {
* K, ?6 Y2 S- L3 _% w! K. L( P7 ` yDir = "up";- w g/ F% n; i
}
1 i7 j+ o& K! ` }7 m0 Q$ t c# j L Y/ x
else if (yDir == "up") {
! s: x0 p0 Y2 K: }# Q if (yPos < (0 + BallSpeed)) {
0 m- O! [* e! x# o3 D yDir = "down";
6 ~& ^, ?1 G5 v2 t% w3 N$ ~ }
; j; s, e9 L7 v' b( n$ i }1 q% \, Y c2 Z9 r/ b3 g
if (xDir == "right") {# R6 a$ U1 d& N2 J
xPos = xPos + BallSpeed;
4 a9 u- e4 I: I/ h }
7 l/ E' w& B3 S# k$ A& k: D% l6 d else if (xDir == "left") {& r3 u1 z; v, r# D
xPos = xPos - BallSpeed;
9 g! s( _( D _6 D* A) ~ }9 t& z% {) Q- O |; y
else {8 K8 [! W0 j* v9 j' H/ ]' {) q& ^
xPos = xPos;0 }* u* X6 M+ o* b6 k6 }
}
, p! j3 k- L& ? if (yDir == "down") {$ K( I" @, x0 P
yPos = yPos + BallSpeed;
9 }4 h( V4 `- V5 ~. b! e, o }
: j" v# B; u- B8 r, E4 ~% Q @ else if (yDir == "up") {- e* }9 M" C3 ~' X' ~4 H
yPos = yPos - BallSpeed;
I. d! r# p# ]4 \4 b, e5 q }& [ J- T( \! k, d8 D: I
else {
3 `( U( Z0 ~% j! `5 g; ]7 x$ H. s yPos = yPos;% d! N& B" Q; I+ Z L# J) s
}
* e4 [; ~) d. S* N$ B4 j% Y }
6 H+ K- g7 v! C# D. g+ z1 B( W# F" K% ]$ B
function hidetext(){
2 z8 o& |, y! e& Eif (document.all)
6 T2 c5 A1 S. f* Msupertext.style.visibility="hidden"
; o5 b Y) M6 F7 O* q& m$ Nelse if (document.layers)# }$ P, ?3 W9 T" ?
document.supertext.visibility="hide"" W% K4 P1 @! G$ b9 H6 g' B1 L
clearTimeout(animatetext)
+ B) R/ w" B' I}7 O( o5 L" n& H0 t( a3 @! t: c/ `
; o& F! b& d' Q. t
if (document.all||document.layers){- e( a" g8 c, a2 ?( G- I6 x9 Z! ^
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
: Q' Q( u8 z) Y, owindow.onload = initializeBall;
# h* U$ b( `. v" ?0 W; ~; kwindow.onresize = new Function("window.location.reload()");
: G/ B2 {) W. ~. ^}7 n- Y0 S0 s, F4 M0 L0 B- H
6 i& U4 R/ x8 v</script> |
|