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

|
网页之不断弹射的文字-特效
<style type="text/css">
5 L$ A V2 v' @! {) P4 u#supertext {
1 I( d, }1 ]' l; h7 W) |' tposition:absolute;
" Y. _7 H/ i( i- gleft:0;
3 V7 _$ t( I( P8 K& btop:0;
6 b6 a+ l& W; l# C1 w. t1 u! _4 `) ivisibility:hide;
% C; |, Z' v+ i# {' ~9 Y, o9 Z4 mvisibility:hidden;
. l' t- j! W9 v+ X- j: _}& H7 _; i. k" T
</style>$ l& B8 ^$ G# ~% L3 c& u
<script language="JavaScript1.2">
4 p% W. M$ u) s2 ?9 D6 w- q<!-- 改变下的字体的大小。颜色-->
5 D: R5 z, |' ^+ ^+ R6 Tvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. h3 j! C; Q9 P7 \9 v$ i
var hidetimer='';( B3 I5 ^7 V4 o
<!-- 改变下的弹跳速度-->
0 S$ j9 f6 t4 B" G9 Tvar BallSpeed = 20;
: p' ~" V& M3 }% \. ]3 E/ Nvar contentWidth;# R+ Y& f2 x* q
var contentHeight;1 }. l! S/ y) A4 g! t: D* S
var maxBallSpeed = 50;) I8 x+ X9 @* O6 k7 \. f
6 D8 d' K* A7 @, }8 x/ Z
, y" Z8 y2 s3 H& L6 H- Y$ nvar xMax;
1 A$ t) F; [! Rvar yMax;
4 M0 Z4 L* E9 w6 U( }var xPos = 0;8 M- `5 p( U `) \5 h, k
var yPos = 0;
5 l" Y* m8 ~5 I9 \ hvar xDir = 'right';; I1 J+ d3 \, x2 L; H# C' b
var yDir = 'down';0 O0 `8 f: u8 H
var superballRunning = true;
: I' ^0 ?, i+ @var tempBallSpeed;
0 v9 S: m0 w. I i# svar currentBallSrc;4 a3 j* l" o0 ]
var newXDir;
0 J" ], m# x& t' E" z( G( X! _var newYDir; k& B: ], e7 @8 U0 c+ L
" ^6 A+ o: j) {5 s7 ^6 g
function initializeBall() {
" g; e9 D' c" D# D$ x9 w) N7 Q& o6 T if (document.all) {
/ i) n3 x3 b. O0 s: l/ @ xMax = document.body.clientWidth
9 J" j1 ~, q, |+ h/ \1 [ yMax = document.body.clientHeight3 w6 L1 e1 m5 P* b8 ]; ^6 S i! G
document.all("supertext").style.visibility = "visible";; D5 K$ n0 l# W
contentWidth=supertext.offsetWidth/ ?1 z! c$ U. z w# H# M
contentHeight=supertext.offsetHeight
) w# ?0 u7 J+ }- e }
5 B' K+ E$ K) y% A/ O) X. E, O* n+ V9 G else if (document.layers) {
}( T" F+ r# } H0 G6 Z xMax = window.innerWidth;$ e$ O; G" B* D) R- _ R; l
yMax = window.innerHeight;
6 O4 ]6 _0 o+ F; [% t! s" } contentWidth=document.supertext.document.width. ]6 ?& n ?- q3 a7 o3 S, A
contentHeight=document.supertext.document.height
! X' K8 `2 ^+ @& l0 T) _5 S: c document.layers["supertext"].visibility = "show"; i. }" f* G# \: i0 b/ P
}
) A/ P) {$ [: Y! O. e6 ?$ i7 y2 W setTimeout('moveBall()',400);0 c s0 i" e: n( C; e
if (hidetimer!='')
+ _) O1 M' t- S* ^ setTimeout("hidetext()",hidetimer)0 i) Y* S5 z: {4 U
}$ c8 c9 l" l2 p# D
) I% @1 |# Z. X3 p E5 b( Y' U, m) {function moveBall() {
3 X& i2 a& u/ S7 a* ]) Z9 \ if (superballRunning == true) {; q* I9 T' m5 T- [
calculatePosition();
2 r) O2 V9 o: y5 x' u if (document.all) {
- o: p. k- Q/ K" \" }% x document.all("supertext").style.left = xPos + document.body.scrollLeft;
( {; y, ~ z( K3 n8 I document.all("supertext").style.top = yPos + document.body.scrollTop;) ^ w3 h% C L6 C+ w
}
$ d4 D+ Y4 m, T1 F else if (document.layers) {1 q* }' b w* L
document.layers["supertext"].left = xPos + pageXOffset;( h$ I" F/ J" t
document.layers["supertext"].top = yPos + pageYOffset;' b$ V, c9 s7 d0 o
}. T+ U' j% {/ ]/ R: c/ ^& l
animatetext=setTimeout('moveBall()',20);
6 R# Y0 v# U5 I5 F+ M" T& @. d }3 U* n- p/ F$ F1 h8 E
}0 Y2 ~1 p% i& i
! S# d( @) o1 s3 R' R( {+ |
function calculatePosition() {
+ f- C `- v: V M$ T, l if (xDir == "right") {% B: n4 Y7 r! i/ i R+ ?
if (xPos > (xMax - contentWidth - BallSpeed)) {
* A0 i7 z" j$ T# y; |1 f xDir = "left";
+ J7 P/ |' v8 O }8 Q. v; L/ b7 H# q. d5 K
}+ x' _0 V$ n: k. z: s6 T; U( w4 [
else if (xDir == "left") {( Z) r- f1 E7 D3 U
if (xPos < (0 + BallSpeed)) {
8 W- \- D& J" H+ f7 Y xDir = "right";
8 n1 e j6 z' O" N# F" V }
, x* {5 T$ U. v! J }( m* u, x5 a0 F( v
if (yDir == "down") {
$ g* M! h8 H* h& \+ ~9 _2 W2 Y. H1 g if (yPos > (yMax - contentHeight - BallSpeed)) {6 g( |, S* c: H0 A9 ~- h; a
yDir = "up";
" s/ |' j7 y: R1 ~+ X1 I }
) w7 M# W: |3 {* h* Y. z( p8 H4 c }
4 _8 ? r, ~9 q0 O else if (yDir == "up") {6 h- \* X$ K: @- @) b* U- Y) t
if (yPos < (0 + BallSpeed)) {- B9 { m1 z [! l8 G v1 O6 l
yDir = "down";
) \1 I2 J9 ?9 @% h) ~ }
% E( l S, t7 D# M+ V7 i V; g8 L }
- j3 ?9 [- T; _! W3 z if (xDir == "right") {* `" X8 {7 J( n5 e
xPos = xPos + BallSpeed;
8 ?% }9 Z& {. W( ]$ \% R }6 i+ f) k, Z0 w
else if (xDir == "left") {) t0 z9 m g* g7 r# D& U! B
xPos = xPos - BallSpeed;6 P' U8 }( v$ N% t
}
* E: c3 I+ }7 K3 e9 v2 j& U else {3 U5 ~0 K" D0 V4 g
xPos = xPos;( L4 U" r( B/ Z! z I! c
} O% }& W: j: E, n3 c$ v
if (yDir == "down") {0 S) Z; G; e* a
yPos = yPos + BallSpeed;" l' r# K; S9 z* P9 i
}
# J! E0 Z) m- |3 Y, L$ F9 R$ l$ H else if (yDir == "up") {4 u* R: S6 c% d$ q& S- S& _$ W
yPos = yPos - BallSpeed;
2 x: z* ^0 q' b. X; O; ^0 h0 D; { }# |" D6 n, B; N! q
else {
! k9 B/ }; \1 Z1 \4 @# P4 | yPos = yPos;
6 h4 ]8 w4 \3 x% V/ g5 F }
$ A2 R4 k; W9 `% R( \* | }: |3 {0 F- J" Y; k
& @. B- B8 m2 @7 jfunction hidetext(){3 D7 {( v( ?/ i p0 @' C; k7 c
if (document.all)& S6 m( H5 q0 q3 C
supertext.style.visibility="hidden") N2 K* P8 S4 k3 h& j% @
else if (document.layers). N% H' B. ~4 l V' u
document.supertext.visibility="hide"
- C/ R6 v/ W( W* s/ G! } l0 vclearTimeout(animatetext)7 C- n7 k8 U! O) |8 l- h. B
}, ~1 P8 u7 R8 ~1 Y3 m! @
. L- ]( a4 V4 T4 c7 b, [7 j
if (document.all||document.layers){% g6 c5 n+ L" I7 E( e. B- z
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 O9 N5 x1 e( J$ r7 R$ I: I6 Z
window.onload = initializeBall;
2 o" w' i! ~/ A) x. Q U' qwindow.onresize = new Function("window.location.reload()");, {7 ?) x9 v% S6 Q' D* Y$ g9 t" f
}
U, ?" ~* p E7 M0 I/ G% G
) }& y7 o! ]4 G: r# F, w% i</script> |
|