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

|
网页之不断弹射的文字-特效
<style type="text/css">
! r# x, ]; p' v l* w3 b% e#supertext {* Z( v& f7 [. A, ~8 N1 t
position:absolute;, ]1 w8 _! {; z `7 q- m1 E
left:0;
, ~4 R$ o8 m' f$ Z* {+ mtop:0;
0 t/ H5 ~( w' B" Qvisibility:hide;
. X4 x4 V1 ~$ \6 n; cvisibility:hidden;
+ T' Y- \/ \) l: r- L: b}
1 N0 {% w' `( k& C9 Y</style>0 T) N% i( `" T. l: i
<script language="JavaScript1.2">8 k- @! ]# g: ^% j
<!-- 改变下的字体的大小。颜色-->
2 Z( m: y. ^1 |' hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
8 v% J' J9 d1 mvar hidetimer='';' c2 {! H2 |* Z$ m% a1 M' o( x
<!-- 改变下的弹跳速度-->
* P7 R6 u1 V% j* g0 c2 G! zvar BallSpeed = 20;0 P7 |; F4 o) }1 f5 c
var contentWidth;0 N+ u8 c8 t& I& e2 n! I1 T
var contentHeight;
9 b- q* J- R; w" I9 c3 rvar maxBallSpeed = 50;* H, K, H& }% A
+ X3 R5 I D# W5 Q) L
9 h" P7 o) [ q. s- ?
var xMax;" F7 z" U" ^2 m, W& R8 E$ {
var yMax;
! n. \) m. g/ R7 R6 x9 b! ^var xPos = 0;1 G" X/ L2 T# Z* V( R' ~
var yPos = 0;- @- a9 s8 E5 d/ z7 M
var xDir = 'right';
) }1 ?( d$ C' Y. @var yDir = 'down';
& ]1 h( f5 A" f9 d$ T& U" `# Ivar superballRunning = true;
- M3 _' Z6 G ]; y- Mvar tempBallSpeed;9 I9 g2 D2 U( Z! [/ c) ]
var currentBallSrc; u3 a9 A& x* B5 s( Z5 r7 V
var newXDir;
! D' Y2 e1 v7 V9 @3 N m4 vvar newYDir;
. P z$ f5 S) v3 Z7 l4 Q% ~
. q) ^2 i \2 j/ b/ X kfunction initializeBall() {4 d5 W0 r _" ?- }
if (document.all) {
6 I+ A/ U0 `# ~ xMax = document.body.clientWidth W- c3 e7 \; k; _
yMax = document.body.clientHeight
2 q6 f! @# r: _5 ^( v document.all("supertext").style.visibility = "visible";
2 P# K) e. |) b- A; `: u contentWidth=supertext.offsetWidth- Q' B& g: ^4 c4 p4 n
contentHeight=supertext.offsetHeight0 D/ s2 Q' i; x2 `
}
0 E+ O' I- \- r. X1 y else if (document.layers) {
M: d" c- ]) n& u2 E5 L xMax = window.innerWidth;
6 i$ {0 p$ Z2 T" z; V yMax = window.innerHeight;
% Q" R- A7 s$ b3 _4 l! ?1 o1 ^& x- P contentWidth=document.supertext.document.width
4 \; U: i# f& ?# v( F' R W+ r contentHeight=document.supertext.document.height% W" t& Z0 D: ]( T! [
document.layers["supertext"].visibility = "show";
m' P6 J* G0 A2 S+ W# K }
) E$ W; o0 j( l: f setTimeout('moveBall()',400);) h8 ]/ e: { p$ O5 }7 \
if (hidetimer!='')) m9 u' z0 Q1 C6 `* J
setTimeout("hidetext()",hidetimer)4 A: [8 X3 R% [* g* j
}5 t& |. ?4 S/ r5 @
, h! p! t. F" a$ |! I
function moveBall() {) ], |7 u7 C/ P; }9 @
if (superballRunning == true) { R! l" U, C( d5 @* Q" p% B) p" A
calculatePosition();0 I! d: L c" M: r, I3 l
if (document.all) {
; s& L" C2 b4 o6 | document.all("supertext").style.left = xPos + document.body.scrollLeft;; Q" G2 h1 I. I, O$ O
document.all("supertext").style.top = yPos + document.body.scrollTop;
+ j5 Z# N. {, c# h- A }
# m2 M$ @8 s. f else if (document.layers) {
O- Z9 i/ U4 U7 L5 h# D# F8 \2 [; P document.layers["supertext"].left = xPos + pageXOffset;
( a( n% E! h: | document.layers["supertext"].top = yPos + pageYOffset;
4 x; h6 A, T, }* M+ s }2 Y6 S* d& K8 r. \& Y
animatetext=setTimeout('moveBall()',20);% R% o+ T1 J0 R) W; {" p
}5 r- ~2 a: n& B8 k4 u1 a, J' x
}3 l1 U. h" v0 F4 p
) p- m! a- \/ {- ufunction calculatePosition() {/ B# N9 D# P. p: {3 W9 H6 G) P
if (xDir == "right") {+ f9 o% Z2 I0 t6 w$ ]
if (xPos > (xMax - contentWidth - BallSpeed)) {' y1 A- B9 B0 b6 H
xDir = "left";* b' l! E; O4 `6 T& p
}5 F6 q; y6 e0 n! G' D8 h4 o4 | x
}
9 E; j4 F- A3 V/ a6 ? else if (xDir == "left") {/ B- v2 H. V$ E% e# E
if (xPos < (0 + BallSpeed)) {
* x% V" S1 [( i f xDir = "right";) s# S$ G$ a# ]" j
}
3 Z6 Y7 y' |6 g4 g3 a+ e3 l }
& O, N) v3 V9 N4 {4 }: E if (yDir == "down") {& y9 E" U5 v! c% n# l
if (yPos > (yMax - contentHeight - BallSpeed)) {
4 K7 H' I5 w/ |2 D3 _" y. t# d yDir = "up";. h' s, C. k7 A: ?; q1 w, d
}
0 Q! e" C$ \# T! _! x; Y4 \9 o( G2 D }
/ x" S2 J9 W% m) [0 u2 z else if (yDir == "up") {# @% ^1 b _; A5 p- Y
if (yPos < (0 + BallSpeed)) {# P# g) c6 ]/ }6 x; E/ `
yDir = "down";, t; q; Z% O/ C- D% \& K% }0 w4 U
}6 @# b1 Z8 \, y2 Q$ I) m7 ^
}
- g1 l& G1 t3 h( a+ k0 a0 W7 ~; [$ t if (xDir == "right") {
$ U2 s0 V. Q: s3 a xPos = xPos + BallSpeed;7 f% |/ J$ e8 J" Q0 H8 S) X/ u) v
}
2 ~. T+ O. K: P" U7 E0 v else if (xDir == "left") {
- ?1 B5 S n- w9 n9 }& e. { xPos = xPos - BallSpeed;
! h+ i; p) O m" n. k }0 Q) {$ R. e9 ~* _) R4 z0 d7 f6 ?' u
else {
3 g6 E. q% C7 v$ X( m0 o xPos = xPos;: z w3 t* H5 N7 y5 B1 g
}5 L1 W) h/ V# z+ W) d* r
if (yDir == "down") {
7 O# P9 N, l: x2 U, b yPos = yPos + BallSpeed;* @# T. |, Q" G
}
& d: V- u+ b7 \2 p$ n! H else if (yDir == "up") {
* C) G5 H6 @* Y/ g& X yPos = yPos - BallSpeed;
) F0 |: f% [9 D, g$ D5 K" ]! H: y }
. P; j' P. x- Z else {
; \+ t2 q. [& ] J1 } @* M$ Y yPos = yPos;6 Y8 I3 [9 B$ I" g2 v
}. P0 s! m" Y/ N3 Y+ I
}% {$ d3 e+ o6 `1 [! e! O
I+ D$ g3 I5 g/ a7 o) a2 ~! ufunction hidetext(){( v& a) S. U5 T
if (document.all)5 c# A% G! s5 O2 K# I) y# w: f
supertext.style.visibility="hidden"
- A& p- Z/ p- I G; w# w U/ Y4 l! gelse if (document.layers)
, g+ H E- F& w& W0 y( \document.supertext.visibility="hide"
# i, S# O1 n5 [9 P- I" X8 y; |clearTimeout(animatetext)
( X. F; j; t9 ]4 B}( q9 d/ M X+ |4 V
+ t# A( j6 v( cif (document.all||document.layers){" \/ M* A0 Z% t3 G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& \& M; B F1 h) o0 I+ N5 d
window.onload = initializeBall;
/ z3 Y2 z5 s W- O8 E' Nwindow.onresize = new Function("window.location.reload()");; D/ P) ?' C: i4 |
}2 Q$ n# }6 x- U' o' F, `" Z' U
7 B- l2 L5 G4 ^; d+ [</script> |
|