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

|
网页之不断弹射的文字-特效
<style type="text/css">) [' q0 a( ?* j0 m
#supertext {. a1 Q3 ` L# ~0 `3 f
position:absolute;
4 x( D0 ^% ]% S' |) V/ T9 Y# X( Xleft:0;
) P& S7 Y* H4 U9 X6 utop:0;
4 S& @' i, V& X! e6 x# o8 k' o- {+ ovisibility:hide;% h. s2 ~" ]) g+ L. P
visibility:hidden;
4 h! p D/ c5 Z}
: g! R4 F2 z) e; D+ l</style># Q0 @! l# d) r3 Q/ \
<script language="JavaScript1.2">
1 v) i, C2 w; e! M" u, q<!-- 改变下的字体的大小。颜色-->
& `1 V' D5 W5 Bvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
b5 U- ~' F4 m% S8 g0 vvar hidetimer='';
$ ~0 W9 [$ s0 I# |9 g( m<!-- 改变下的弹跳速度-->
: s" s# [* J' k6 w; S% Rvar BallSpeed = 20;
2 }& j2 V# |# `; }7 M# h* Lvar contentWidth;
. c ^8 T, r6 |) ?var contentHeight;
7 a: J' X! s6 T2 P% z2 u/ Zvar maxBallSpeed = 50;
- z0 \6 }* C; u* g6 b+ f
" i* Y. K4 t1 s: W* _1 f* l4 J: A: A
var xMax;! V, T1 A, S1 A. ^
var yMax;
: A" ?0 s& R+ a. n* h- uvar xPos = 0;% o3 y5 n* K$ ^, O+ b7 E
var yPos = 0;
8 \2 f7 @) j* D7 Lvar xDir = 'right';2 @' E* g' C3 V% e! j3 j
var yDir = 'down';
; c+ Z* Z H* r% Y2 P! ], T4 o& Ivar superballRunning = true;
- ~: R1 `8 Z, {1 L ovar tempBallSpeed;, m9 g2 z) f; m2 H
var currentBallSrc;
[' h0 N) G/ Mvar newXDir;. P o7 n) c1 Q# x+ {
var newYDir;. d' H( Q( H3 J i9 Z
; f W: v4 m1 z/ P
function initializeBall() {
$ G% H2 V4 g. b4 L/ @" K$ R if (document.all) {
4 P# e% G* X$ N/ Q; ^( Z* ] xMax = document.body.clientWidth
" D* M# q* N+ H$ i0 q' J' J, R* B/ L yMax = document.body.clientHeight
3 n0 W$ B4 _. U, B ~ document.all("supertext").style.visibility = "visible";5 A* M) s( K9 x! W4 l$ q) b5 j
contentWidth=supertext.offsetWidth
1 M# p& t/ f2 N- Z+ z contentHeight=supertext.offsetHeight
8 T+ ?. {' O+ r }9 A, C6 m! ^+ ?4 M) W3 x
else if (document.layers) {% J( a% Y. f% X0 J" Q6 n
xMax = window.innerWidth;- r3 N! e% O' s* s& A9 {# R9 C
yMax = window.innerHeight;
: ]; Y9 n' a7 @6 H2 z U# t contentWidth=document.supertext.document.width
# C( ]# k, Z/ E3 Q contentHeight=document.supertext.document.height; w/ y1 ?. M4 O/ u' _
document.layers["supertext"].visibility = "show";
$ r( J: X- `+ l0 \. p. m. a }
1 Z0 X/ Q$ p/ P. F/ @9 L setTimeout('moveBall()',400);) S- Y: c) t9 [: w) X, H
if (hidetimer!='')8 x% ?( u# F9 |, f+ @
setTimeout("hidetext()",hidetimer)
7 J! R! P+ ?, e6 G# L5 T J }' T) G$ P8 [/ r/ ^7 i# B( H
' w' O; A; r, Xfunction moveBall() {
( c" V" _' ]5 K2 C5 O/ E if (superballRunning == true) {
$ |; @4 A+ e& {8 Z% t2 u calculatePosition();
! b; J# V$ u( P if (document.all) {3 h1 e" k/ ]: \+ z7 T- |3 ^
document.all("supertext").style.left = xPos + document.body.scrollLeft;; @: Z* W; h6 S/ U$ f
document.all("supertext").style.top = yPos + document.body.scrollTop; P, j* _+ u8 U1 i, V
}7 e& i1 X& I0 y6 W$ R+ _9 L
else if (document.layers) {
' w: M6 p) U: S. A2 V document.layers["supertext"].left = xPos + pageXOffset;
: @; A* b) B5 @7 m9 J: {, P document.layers["supertext"].top = yPos + pageYOffset;
5 Q3 F$ [$ L# Z; `5 S5 i9 C9 T& }: n, c/ b }
: X1 B4 C) f% `" h h animatetext=setTimeout('moveBall()',20);
. ~" Q) z! D1 m, d" Z3 w+ k }: K5 n! {& w2 X. D
}9 @, i# Z) {% j+ t/ P
) w+ ~2 Y' b& D5 V! Y* ^6 |function calculatePosition() {
4 `$ x0 t( e! g8 i if (xDir == "right") {
% C& ?, E: y# W" I' Q i v- o7 M if (xPos > (xMax - contentWidth - BallSpeed)) {
9 W3 r+ _) ~: R5 n xDir = "left";' ~$ x, W$ x5 Q( R# w
}" F, l" b7 A5 m
}
- e) V& c: b! A$ r+ g0 B else if (xDir == "left") {
, {9 q' v' q6 t if (xPos < (0 + BallSpeed)) {/ ?' k, C/ e9 o4 |# M$ [
xDir = "right";8 z! F6 v: t, T1 j1 Z* j7 j
}8 `5 @5 Z- s' l$ |
}/ k6 ^3 [2 \" R- }# R2 K
if (yDir == "down") {
6 z2 Z; _2 S" h6 C+ C$ a if (yPos > (yMax - contentHeight - BallSpeed)) {8 `) V0 v* W. H9 Z3 g3 X" o5 I1 I, r
yDir = "up";
# g$ m" O+ D2 V! G }' L# H% p! Q( d' k. p8 x/ X
}
5 H; F' ]% d' X else if (yDir == "up") {# l3 q1 a0 K+ g
if (yPos < (0 + BallSpeed)) {
2 c5 m( L- h3 h4 ^. K4 @ yDir = "down";
, W4 K7 D- E$ j1 k& l% I }
3 |3 | H4 L7 e" y$ L }% p! \+ y' R* K0 z7 B9 }
if (xDir == "right") {% G/ W4 k' w j* K
xPos = xPos + BallSpeed;
8 L4 e% @" `7 F2 i! \8 E }
/ z0 W/ E! ?$ x( _% y3 G else if (xDir == "left") {% p* X! c0 p6 t2 G* j
xPos = xPos - BallSpeed;+ N$ [5 w& M2 @% p5 g$ K) K
}
1 q2 T4 i9 Y3 n' g8 B; J else {; U# u# V; v) H3 p% q ]% K
xPos = xPos;; N/ a: V9 z6 x: u
}. t j! s. e5 d5 P2 |9 D
if (yDir == "down") {
! c7 j* h) s1 W1 B3 M yPos = yPos + BallSpeed;
2 S# h, h: a) Z1 b$ S }
& Q5 G( p' A. u# w) v else if (yDir == "up") {
8 `, v/ @ V3 q) E yPos = yPos - BallSpeed;
; S* ^4 L4 J& Q2 U1 ? }
% s4 H5 t- w! L5 ^( q0 A else {
! G9 f! }. {0 G, @" Y: f yPos = yPos;
2 ?/ t# D3 c% s* h, ^ }
0 _9 z- z ?& \/ r4 D5 v: ^& E } @4 R. |+ @0 f! W& h. \9 L
/ @9 w% x8 J: V
function hidetext(){
4 ^1 }6 j+ i# [3 q: Aif (document.all)
. {3 Y; Q1 L- ?1 j/ usupertext.style.visibility="hidden"
# o# U1 n+ v; g L- felse if (document.layers)
0 H* B9 ~8 ^% ]: q M Zdocument.supertext.visibility="hide"
# g5 Q5 k: x( u8 XclearTimeout(animatetext)7 I* [3 A# m. q' m! Z( ^- f8 I
}
! A: a0 w) w% _9 U! T5 Y3 @/ {0 Z
if (document.all||document.layers){
4 M) W1 z! ?* K# g' |1 l0 o8 |document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ N: W( ~7 x7 S6 y9 a( O5 Q/ Bwindow.onload = initializeBall;
# m1 _, Z; a. k) D6 o, F( E/ M' Zwindow.onresize = new Function("window.location.reload()");' E2 R# y& b: a3 o7 U# s
}0 R) ~% @' z" Q
1 R4 U. u Z" E' N+ Q6 r</script> |
|