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

|
网页之不断弹射的文字-特效
<style type="text/css">+ G" V/ y: P4 V9 x9 A, h0 K! E
#supertext {$ g R2 @3 W. R$ C$ F( D, H
position:absolute;
( k' |9 T: J) G" f8 Vleft:0;
; a3 i/ G5 q- g$ I. Vtop:0;: s/ ]( c; M. W5 ~$ f
visibility:hide;
" W* U9 V, S, [- F; ~$ pvisibility:hidden;6 y) M. w6 I! |$ j9 i3 q# k
}
& j" j! h2 T H% t</style>
- Y# T3 `" \2 }5 q0 s<script language="JavaScript1.2">
3 Q a( [& n O7 R/ q<!-- 改变下的字体的大小。颜色-->) |) e% M% y) A3 ~$ [
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'! k4 r* s7 V+ `. \* t3 X9 f
var hidetimer='';% Z2 w# l+ p+ r# X' v( L$ ]
<!-- 改变下的弹跳速度-->
. b9 L' a4 z" |) c$ Q& e! _var BallSpeed = 20;
* Y# A8 F0 K$ r6 Z4 Ovar contentWidth;3 j% E, h$ k3 y) U5 [* e8 R" b2 g
var contentHeight; a6 k" y- f9 y& I. v3 A! n
var maxBallSpeed = 50;
5 o) E' p: R' p j4 g% f
" Z' d: e- v w) `- v7 ]
# M* r7 l3 r( Zvar xMax;
8 d( Q0 r$ H0 N/ F3 ~: n8 wvar yMax;: b% q0 P5 n* b- m+ ]( V
var xPos = 0;/ l. G% s# S' N* U
var yPos = 0;' X1 H- j. Z/ k) g$ d; B" L2 d! C
var xDir = 'right';6 O, }! Z1 M8 n6 [3 h+ s+ h) _
var yDir = 'down';7 j4 p- W: B. q" V* w& @8 G6 g4 w
var superballRunning = true;" E7 k+ v6 E: y% \
var tempBallSpeed;
5 F% x' a" Z5 ]0 G! P( avar currentBallSrc; w9 I; N; @ i6 `1 Z7 \. w' R
var newXDir;3 m& p$ g! k# m1 ?) n2 I
var newYDir;- A7 K9 M( _( G+ j6 H
0 L9 `1 k3 ^, l% v
function initializeBall() {! }+ e$ M* l" V$ Z4 N1 T$ v
if (document.all) {
7 T$ r1 t; q& O4 B xMax = document.body.clientWidth
6 n+ V2 Q! }+ [3 Z yMax = document.body.clientHeight: Z" }: T0 S+ r$ S8 f, J0 w
document.all("supertext").style.visibility = "visible";
3 e) y! c" x: o' y! |/ J3 x contentWidth=supertext.offsetWidth
, |6 b+ v2 i6 N3 M8 {: d. d& W+ U contentHeight=supertext.offsetHeight
: I/ M' W/ N3 R3 _6 e; l }) g. f4 N# o9 E5 b6 K: J/ R, A
else if (document.layers) {' u! @+ i+ i6 R6 B$ R, A+ z a
xMax = window.innerWidth;
6 D3 \1 _& ^( f6 m: j" | yMax = window.innerHeight;
$ T% [+ _' h0 t& V. ^+ G contentWidth=document.supertext.document.width
. x) C& {' q& R. C9 g9 u contentHeight=document.supertext.document.height0 `9 O# s7 Z" A+ S0 o9 i# u
document.layers["supertext"].visibility = "show";
# p3 K8 f: o8 G, A5 Y) U* f/ \9 s }: v" _# D& a5 b, d, A' S) Y
setTimeout('moveBall()',400);: g4 R( s; f5 v8 a6 R. v
if (hidetimer!=''): x: Q- e k) p; B% a" E
setTimeout("hidetext()",hidetimer)$ Q0 l0 g# J ?9 V
}
% b2 a2 V& a8 {8 X( }8 I
y" @# @; T* H' E: f N: ufunction moveBall() {
) w f$ g5 P& ?$ Z. ] if (superballRunning == true) {
( L5 M5 V6 P% h8 r: F2 l calculatePosition();
0 H- H) r I2 [$ s if (document.all) {5 c& ?: K) q6 U0 v) E2 [7 @
document.all("supertext").style.left = xPos + document.body.scrollLeft;6 ]. ]6 d# d5 G
document.all("supertext").style.top = yPos + document.body.scrollTop;% s4 V- d9 g' H; A
}
+ U1 |# [0 [8 @; D& i. l else if (document.layers) {
8 l ]; i) Z- b1 p1 W document.layers["supertext"].left = xPos + pageXOffset;
0 {2 h( ]0 h! w" k document.layers["supertext"].top = yPos + pageYOffset;) ?% t! G' y9 L9 B7 \
}% J5 M% M0 m1 R. E9 q
animatetext=setTimeout('moveBall()',20);: @/ Z# H3 u$ ^5 _$ N6 J
}
! h+ d/ f+ e7 e6 [3 V& ^ }
0 j2 L0 C5 P) h6 ]6 D7 } n1 d- J2 _' q
function calculatePosition() {: @1 M+ \6 `* D
if (xDir == "right") {
# U! U3 b0 S5 ~# x) K: p ^ if (xPos > (xMax - contentWidth - BallSpeed)) {' s/ V! B" @ ^# N- L
xDir = "left";0 H: h4 a5 b: h! P0 v' V* X7 B
}' u j% e" r9 T+ v& M
}" M/ c/ |" V7 X* k" Z1 P
else if (xDir == "left") {
9 U7 u7 v7 b+ h; F4 ]( D- A- D5 k+ c if (xPos < (0 + BallSpeed)) {
% Z! p# `/ k5 \6 b9 e( g. x xDir = "right";
# \$ L4 y- p n9 o! I# ~& U( S9 @ }
) `3 z+ q, s2 G }
* _; V F# |- ~3 M) S W) E if (yDir == "down") {
F$ Z M: M, B; Q4 o; f if (yPos > (yMax - contentHeight - BallSpeed)) {' B+ d; A, c% ?: r- J/ e$ h4 T
yDir = "up";
7 s0 a2 d% q2 y2 A! T+ K3 O }
3 r6 v! D9 s+ x, k5 w } ^6 A W J4 S2 t" [& Y( J# `, \& ~
else if (yDir == "up") {
2 E4 G# ?: x5 s# t if (yPos < (0 + BallSpeed)) {
+ b1 v/ B+ S9 j( C: g yDir = "down";. W. B/ s9 {- U3 [
}1 k. h( n7 c2 K8 }7 t
}
" a) X/ V# O9 T* |% r0 f5 _$ L if (xDir == "right") {! v# W2 W" [* r# f/ V3 l
xPos = xPos + BallSpeed;
2 N+ W+ a3 p) l& D }
2 E4 Z5 Z- F8 b6 d0 J9 q5 d9 } else if (xDir == "left") {$ [$ y, C$ Y* j9 n6 E9 ~
xPos = xPos - BallSpeed;: |/ |" Y& W' H2 r H% W7 u4 w; Y" X! N
}
; W) V: \8 f- { R else {/ n7 R5 x) k* o, W0 X8 m( p
xPos = xPos;
0 U0 C8 b1 _) Y' C( [5 x }
$ Q! @' w" w+ G if (yDir == "down") {
) {, x0 {3 e: v x- n) { yPos = yPos + BallSpeed;& y8 \% B$ t9 K7 j/ K7 G
}7 p, b4 [: w! J5 g# [% B1 W# r
else if (yDir == "up") {
) E5 i' K+ G: A1 E7 q @6 D& N yPos = yPos - BallSpeed;% w! s7 {, [1 A$ a V
}
; ^- U; {4 |) \% S else {
7 e$ d. A3 ?- R S2 |& o K yPos = yPos;
% b" ^! c) T5 o0 d+ ?. L }
' s1 P) ?& Q, @. S8 Z }
) s8 w/ T; N/ W( X( h% \8 T* ?, A7 L6 w
function hidetext(){3 C- R$ o2 k: q" J( B* z( G& E
if (document.all). D. B" d' I) S
supertext.style.visibility="hidden"
, g) f4 j, z) L/ Yelse if (document.layers)
1 B0 m2 H' s# r5 O) rdocument.supertext.visibility="hide"
1 j( h, z+ |$ y0 K3 U$ G. mclearTimeout(animatetext)' @5 C3 ?4 \( Y1 g( K7 M5 ?! B
}& P3 r6 e# Z9 i" s4 M# E* Z" F
5 r% N0 ~; {) k, I: R5 xif (document.all||document.layers){+ X' C" R, u1 l# C& F* k3 W6 o
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')5 O+ t9 Q2 c) ]2 G) B" u+ J, _% l* y
window.onload = initializeBall;' v6 C+ m9 s6 Q' n, m
window.onresize = new Function("window.location.reload()");
5 ]; p0 _( a7 W. O& ]/ e0 R' N; g+ @}7 I: }6 i& `1 j5 S
' W# r+ X0 X; `) p</script> |
|