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

|
网页之不断弹射的文字-特效
<style type="text/css">
7 [" D- E( L" V, t) h; {#supertext {
& ~9 O5 G* t) `- @position:absolute;# z0 ]- \: H: y1 o# K) k* F
left:0;
% W& ?8 H/ p5 q1 e& J; ~top:0;. ^1 c: s, _1 n3 g& O. [. i) ?8 Z
visibility:hide;
6 y0 ?/ A. b* E1 u, \" \: Svisibility:hidden;8 F# g0 y) j$ r: `9 ?" u
}
; T7 l- {. z) { T9 t6 l: a</style>
: X+ q: h+ d u<script language="JavaScript1.2">
. e8 u$ U5 S/ O; |<!-- 改变下的字体的大小。颜色-->
# {' p. [7 y# J4 _var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 I }4 b7 J4 \
var hidetimer='';: ^7 X( y4 S, F9 m0 k
<!-- 改变下的弹跳速度-->0 Q! n0 R7 t8 ^% X
var BallSpeed = 20;
( Q& H u1 u8 Y. E& W" K! {( Mvar contentWidth;
4 t. D, _; b f0 W; _0 Y7 Kvar contentHeight;
! k% F e3 F- Z, {) Kvar maxBallSpeed = 50;+ G* @' @+ e1 g3 h! R
, z' A6 R; I" _! [* @1 |4 p
0 b7 ]3 Y; l/ e8 i, N
var xMax;$ R7 I+ R2 J7 H4 S" u+ B+ c4 m: @$ t
var yMax;
8 ], t1 d9 Y2 evar xPos = 0;
/ a; N. H) i0 X0 G7 Q8 K% yvar yPos = 0;5 {( ?, R: O* B, N% B8 a, b/ |
var xDir = 'right';
% o* o" |$ t+ p1 I4 Xvar yDir = 'down';
( I6 Y) W. r. ]$ N0 @0 |- b) Wvar superballRunning = true;
: M( ~3 B3 c* ]' a+ Q. T0 n; Cvar tempBallSpeed;
7 D" K: h* a1 Fvar currentBallSrc;
* Q6 ] d: K* a! _8 H# i% evar newXDir;" \ u! U8 g" M4 ^# d& t; |
var newYDir;8 Q! d2 b. a2 d# C6 S: H
' }9 p1 C* M0 t8 d
function initializeBall() {
! _! s5 b* a H' @ if (document.all) {2 ]2 D& D% v2 G) }- e3 Q! ?
xMax = document.body.clientWidth% b" A( |- H% L# G) |8 r7 G# s
yMax = document.body.clientHeight; `, _# m, P) S; m; G6 }
document.all("supertext").style.visibility = "visible";
, y7 W ^4 @+ H: P) J7 m6 |/ y contentWidth=supertext.offsetWidth
) `; w* x, b+ A6 `# L contentHeight=supertext.offsetHeight
* N9 g9 P2 Z( i$ Z3 y/ w }9 [9 E: W* j4 K! F
else if (document.layers) {
" [( ]* {. r, \ xMax = window.innerWidth;
) ]( S6 ]+ v0 Y- {; l yMax = window.innerHeight;
5 @; r$ z9 x% L$ n# t; t+ T+ k3 d contentWidth=document.supertext.document.width
, @9 Q. v, C( m8 q% F- v2 p contentHeight=document.supertext.document.height% n% u1 k# q6 K8 n1 i. k% x4 h
document.layers["supertext"].visibility = "show";
& C5 j$ }8 c/ K6 y6 `3 Q }
- p( ^# I1 D2 z3 l1 u0 x* \ setTimeout('moveBall()',400);
+ N3 p1 u$ T" C/ ? if (hidetimer!='')
/ E" _5 X" G! Q setTimeout("hidetext()",hidetimer)( z7 g, S0 @' s3 D! V1 Z Y
}
; r5 k& I- p( Q, M0 \' O% U
" g) c. _' H6 H0 t8 {3 N8 o; }function moveBall() {
$ @/ l% u9 U: \% u I if (superballRunning == true) {3 a( F: H0 |9 b" ]$ h! P
calculatePosition();' C, B7 i6 T: J. B. k* W& D
if (document.all) {+ P' ~: ~5 R& I8 ^. x/ W* C
document.all("supertext").style.left = xPos + document.body.scrollLeft;( \! Y0 V, n7 }& ~! t4 a
document.all("supertext").style.top = yPos + document.body.scrollTop;
; `& _7 G/ D. V& [' c }* K! m* B3 a3 B! n# h) r
else if (document.layers) {7 A! a4 V. m( K+ u/ g5 n
document.layers["supertext"].left = xPos + pageXOffset;
F2 J9 T0 h0 z3 |7 m4 j3 ]$ Y M document.layers["supertext"].top = yPos + pageYOffset;
% E2 T' U6 O3 ?1 c }
O6 Q* B3 S1 s [- } animatetext=setTimeout('moveBall()',20);
3 F K3 x& f- V3 E }. z) o0 Q; A- J6 y
}+ N' G, d; Y! L' ?: `$ B
- z3 P' G6 _$ p. ?3 @& R; a
function calculatePosition() {
9 m. M4 [& [0 A! ]( f if (xDir == "right") {1 \! I$ C: S5 ]9 Q
if (xPos > (xMax - contentWidth - BallSpeed)) { ~' A& H4 w0 B
xDir = "left";! E/ {3 L- V; R; k" i
}# ?/ B' l- d* a7 m
}
* o& K% l, B) l" N( S& R. S1 L. [ else if (xDir == "left") {
& T: z* m9 }% b" V' i if (xPos < (0 + BallSpeed)) {. x% f$ O9 U- @$ T: w
xDir = "right";
8 j: v. `, u, u* B$ F5 Z }
% p( u7 X$ B: M) U }
3 {1 E. S, i! O5 [ if (yDir == "down") {) }- N: {( @4 O
if (yPos > (yMax - contentHeight - BallSpeed)) {
; X8 Y6 k s! H) U. l& W yDir = "up";
+ j% V) u- E4 q+ j. u4 N1 f, \% t }
% P, P9 Q" t5 ^, M+ j& a- w& C }
: m2 f! S% i) b/ X& V u0 [ else if (yDir == "up") {
/ {5 [* g& g" l' f7 x$ N& O+ Y if (yPos < (0 + BallSpeed)) {$ B' x( x/ R: P' E/ U5 P
yDir = "down";1 F' o5 q' ?1 w1 z% m9 n+ v2 {
}/ I6 [1 ` D' k2 |
}
: G/ ]& E5 g: I9 t1 Z if (xDir == "right") {
- |$ m* D h/ P xPos = xPos + BallSpeed;
3 ]* v" k9 p: c }
. `/ K$ V$ R, n: ~, b+ B% h else if (xDir == "left") {: D s6 ?. K7 H! f2 Y% ^
xPos = xPos - BallSpeed;
, z0 `3 {! z6 s7 @4 O8 W# B1 C }2 P9 F" l( e; k" ?. q7 Y+ L
else {% x! y, e8 [* I
xPos = xPos;
% \, @5 F, d5 B) D) g }
9 | j* k8 Q2 c6 Q6 E7 ?% N8 M( a0 K# v if (yDir == "down") {) ~8 p: y$ ` U" J9 T, J) u
yPos = yPos + BallSpeed;
# X: F/ c7 Q" G4 d# ^# O }
$ |' ~. _6 T7 [# A& o Q; P1 ` else if (yDir == "up") {" A! E/ L0 J9 ]8 Q3 x5 U7 r% Z
yPos = yPos - BallSpeed;
5 f3 V! ~4 }7 { }
- n- o7 I1 X$ D% g& N; v else {% G: w1 O3 X' M& ~- w' J
yPos = yPos;0 x+ W* O2 K3 G) o- T) \- N1 h
}
& l! ?; d. ^1 l$ M: S; d }" b9 i8 @) O1 m' w
" C, Q7 I. p" H
function hidetext(){# }* j' w! G! U6 ^" K
if (document.all) o1 w8 A0 j& z) S1 ]. H& X
supertext.style.visibility="hidden"
" |0 u R2 \9 `1 D; N" `else if (document.layers)
9 R' T/ H$ W. S) Ldocument.supertext.visibility="hide"& X" `# u5 F9 X0 O# f; U. P) q2 b
clearTimeout(animatetext)
) w9 x/ C" J3 n- t$ y& c. A}* V3 O2 i& `3 z( w2 Q, _6 }
( V! i( M/ f+ ~( Oif (document.all||document.layers){3 O- O, m5 c3 q+ c8 T( z
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ o2 v, q; h7 @1 Z
window.onload = initializeBall;
2 P& N1 r7 O8 U1 \4 M8 ?1 q2 fwindow.onresize = new Function("window.location.reload()");' ^2 _2 s# g0 b0 b" _% r
}
' C. V! S* u# F- I k. P# `+ v: T# i* M6 _! J4 T
</script> |
|