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

|
网页之不断弹射的文字-特效
<style type="text/css">
$ F. w% T" N4 _0 o& E#supertext {
0 e1 e { `# [4 U# `position:absolute;6 ]% {! }0 b6 \0 a
left:0;4 V5 O: x; q& t
top:0;( d9 C8 }1 q# y( i
visibility:hide;+ U# W0 s( |* Z% l$ t2 _" Y5 v
visibility:hidden;0 _0 t) e9 Z5 u7 t* x5 U
}0 e! ?$ o8 r9 o. t: B% u
</style>
3 @4 N+ i0 Z! s6 g, {3 T<script language="JavaScript1.2"> b- }4 P$ {: M: T# q
<!-- 改变下的字体的大小。颜色-->
) L9 T) K8 B% P j0 evar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
: I2 V2 h ^9 M& ~+ F) \2 Yvar hidetimer='';. a, q/ ]' C. |& R& Z/ K
<!-- 改变下的弹跳速度-->6 O* m. A: H% u6 o& g
var BallSpeed = 20;: w& }0 K: I7 D# z% s4 o
var contentWidth;
7 b7 }7 N1 O8 ]) ?6 D, @- p9 vvar contentHeight;5 {" f1 ?0 ] ~" N; Q- s
var maxBallSpeed = 50;! E* Q2 r+ B! D$ B& s: c3 B) o
: ~9 c) H3 S; N a- U/ E( _3 K
! } Y( }: Y" @var xMax;1 l5 f( |% J0 ? D* ~
var yMax;/ Q' R0 Q+ x7 J3 F+ O
var xPos = 0;, z4 H8 @& h: o3 I' R! K" E: n& k- G
var yPos = 0;
" |5 U. t- A! c# w5 dvar xDir = 'right';
$ [" W8 J+ A; Y8 f8 t3 l1 x. bvar yDir = 'down';
' J5 |: p2 Z2 L( P/ q k9 Pvar superballRunning = true;7 K, ~8 [& R3 U- m2 g4 E
var tempBallSpeed;
3 d( W7 ]1 z" d# Bvar currentBallSrc;
( m6 k& k( K6 B- _+ xvar newXDir;
0 N1 M# P, w' {: o2 zvar newYDir;
, ]4 j3 P/ P/ y0 b% x( d! T) ?/ ?# F% H; z/ y
function initializeBall() {& P% l0 ^$ Y6 X" H Y. A
if (document.all) {3 x0 L9 X4 U# J& [0 k/ p2 v
xMax = document.body.clientWidth
7 K# o* n* X$ f( k7 q' _ yMax = document.body.clientHeight X1 U$ [" f' w; }6 {
document.all("supertext").style.visibility = "visible";
3 a2 a8 P8 \! a+ T/ U ~) i contentWidth=supertext.offsetWidth8 j# h _2 A! N, [8 n [( O
contentHeight=supertext.offsetHeight
6 I- X& M8 t' ]6 H1 I" ^, U) n9 s }6 w; V5 } ?- b1 }) o" \
else if (document.layers) {/ Q z) s' V: T6 d" m# u& V0 N
xMax = window.innerWidth;3 p' G( \' a* R0 S4 a2 q+ b. O
yMax = window.innerHeight;
7 n/ K: [8 g9 c! m contentWidth=document.supertext.document.width
) X: z, @- ~) h |( t9 ^/ B; D contentHeight=document.supertext.document.height# @8 j5 I- {2 y6 W- Q
document.layers["supertext"].visibility = "show";7 h0 j; Y' }, @/ p. a7 j) U
}( \) E L# s& `
setTimeout('moveBall()',400);
2 o: L9 `: W/ g+ e, `) K if (hidetimer!='')- c0 L2 `# ^3 \( g, w2 M$ o
setTimeout("hidetext()",hidetimer)
d2 p' ]) t( j; s1 X }
, w+ u% \& b- @. B
2 J7 ~, E4 n$ pfunction moveBall() {& K9 T; j( z7 T* w
if (superballRunning == true) {+ U; Y* w5 \% r* x5 q: C- y4 {' V
calculatePosition();7 J6 k7 ], G3 K- o
if (document.all) {/ m+ u2 h0 @1 x* Y# Z b: I2 Z1 T3 G
document.all("supertext").style.left = xPos + document.body.scrollLeft;
% z3 b- G+ C- \$ Y document.all("supertext").style.top = yPos + document.body.scrollTop;. D. c1 h$ s% |$ ~# D
}' a4 b1 T% p' _# u, z
else if (document.layers) {2 J. _5 m: v0 }1 I8 W3 I G
document.layers["supertext"].left = xPos + pageXOffset;) C! B9 C. Z3 w' W/ f5 d' {
document.layers["supertext"].top = yPos + pageYOffset;
8 r7 B+ Z9 d3 h( ~ }& ]2 w0 V, F1 Z* A1 Z7 Z
animatetext=setTimeout('moveBall()',20);
+ P( O$ ~! a N# G$ O0 W: ?' w; r/ a }8 c1 i; t; w, Z
}
. V- s3 H1 v% R! P3 k7 v
, {1 K9 ]& b8 H% ~9 Ffunction calculatePosition() {
* K) j. u: W4 s* F t% i2 } if (xDir == "right") {
$ k/ f( F' H% G; e8 y if (xPos > (xMax - contentWidth - BallSpeed)) {0 N- z$ |8 y1 N
xDir = "left";
O! F8 z* ^0 u5 A8 T9 a }: |9 P1 F( }4 L s. x) `
}
: N" F1 e9 |7 P% {+ S p. R else if (xDir == "left") {9 i2 V" o+ V* a- f; R& H- Q
if (xPos < (0 + BallSpeed)) {3 q U/ [. b& n: c- B* m0 u) S
xDir = "right";
! m) H" }" B! ^0 A1 F }! Z3 P9 i6 V h- s: s1 X' y% [9 i8 K' X
}7 N% y6 J, x# y
if (yDir == "down") {
( M5 C2 o$ G. R8 n, a P& { if (yPos > (yMax - contentHeight - BallSpeed)) {& s' P1 E% d) H0 D3 i8 h( g
yDir = "up";+ @( H V3 ?5 W$ ?/ W
}( j4 W8 P% H# W# ?3 ^* i' g
}
J# u7 H; n# C/ y! _8 G else if (yDir == "up") {
& R' o2 r6 N6 V" j+ H+ M. \$ x if (yPos < (0 + BallSpeed)) {; U% K0 @0 w& f- p7 e% o4 O
yDir = "down";
! I9 W8 M- y! X6 e& a9 i I }$ u8 V" N- C7 I, d
} ~: w b, {5 I' g. B# I
if (xDir == "right") {
4 B9 F% r2 C! V xPos = xPos + BallSpeed; N7 s- M% z0 p) J# T* `& t8 V$ L
}
- H: b* o2 O( H: k+ L else if (xDir == "left") {
! F; m+ J2 d4 X$ T+ P8 k7 U# h% f xPos = xPos - BallSpeed;. g5 I- Z2 i( I) q4 ]
}7 q6 D, \* c0 P) Z& k
else {
) O+ |" q+ p% I" o. Y& ~ xPos = xPos;
' V* h' I0 U& Z& W4 y1 S o) A }
6 l5 Q7 `& ~; w e& l6 V if (yDir == "down") {
* K$ |7 Z# z( h9 [+ R6 d yPos = yPos + BallSpeed;
7 `3 [) V e# o. K, | }
. b5 l; f# ] l else if (yDir == "up") {
8 L. D* c6 Z0 K$ B$ p2 r yPos = yPos - BallSpeed;
# w8 l1 Y8 F' V2 W }
8 v+ t4 O; y# v6 W! X else {6 E# B$ V" j; m8 k, `
yPos = yPos;
* x7 A6 w- O8 c2 s. q8 O; Y# m }" {1 A! F: a/ ?- {$ D9 Q
}$ b0 @/ ]* Z/ i/ `2 _
& }# ~/ t, m( y8 S2 Q
function hidetext(){
1 A) d3 ?: O+ wif (document.all)4 l, L1 u6 ?# w/ k, ^, t) n9 W
supertext.style.visibility="hidden"
( L C J. L* G2 u; Melse if (document.layers)" g) w: Y% Y) @2 n) q$ k5 l
document.supertext.visibility="hide"
' u/ g5 z x/ K, N4 bclearTimeout(animatetext)/ c: D3 O; A& b+ ]3 B& y) O9 q
}6 C# J+ {8 L% x& A |) F5 g: t; J
4 K& ]( ]' y) c: `3 `if (document.all||document.layers){3 m7 I6 `/ [! z q& r
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
- Z2 c5 y, b) ?" z( ?$ i0 _window.onload = initializeBall;( L! ]4 m9 `* |% X
window.onresize = new Function("window.location.reload()");
[. S$ m I. N0 s/ ?}! n% D' y5 f5 ~
3 M7 ]( O8 s+ U3 Z/ Q
</script> |
|