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

|
网页之不断弹射的文字-特效
<style type="text/css">
1 y, u' A i, J" t#supertext {% m. w4 b9 B/ a& L8 p) i
position:absolute;
4 r! L$ K1 b4 _: t( {3 p6 w9 M8 hleft:0;
1 v# j# X7 R# C- u+ |( ntop:0;
; R# B* J2 v P$ T7 Evisibility:hide;
- Y" A' R& D1 Evisibility:hidden;
: h( ^7 d2 b5 v" r9 r/ S5 F}
) W$ K6 M0 g* y. ?/ w</style>( G7 A9 k# d* e/ Q- L. W. l5 L
<script language="JavaScript1.2">
2 m$ _$ M$ c- c1 m# x<!-- 改变下的字体的大小。颜色-->, n, I1 w. T4 c& k
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% X) Y0 \8 K2 h2 S, Svar hidetimer='';
3 Q' x d* J# F$ Q8 n<!-- 改变下的弹跳速度-->0 S9 v( O7 z! H* _
var BallSpeed = 20;
3 o& |& B6 K, i; m: {: l! {var contentWidth;4 x( l* p8 h3 g* m7 x9 n7 v+ W
var contentHeight;. e8 o) Y( K& V) L: Y& Q# [
var maxBallSpeed = 50;8 Q9 V( b8 K( g8 h! Z" h% k
3 f' M/ b" J* y6 j I! V) J
0 _( l) ^! _2 x( v( O
var xMax;. B/ z) i }2 g- }- E; u0 g* _
var yMax;
7 n- e* v( |7 w$ q4 V8 e- Yvar xPos = 0;
& ~1 D- n, y9 U, Gvar yPos = 0;
0 i7 u9 z" L3 x/ T, evar xDir = 'right';
$ s: |: \' b% P z, B1 `var yDir = 'down';% C; a/ t8 v% C) N% l4 {
var superballRunning = true;: H8 E* k+ z @, x# J' k9 Q( l7 V
var tempBallSpeed; ~8 u. T, J6 W& O0 i) f/ |$ ^
var currentBallSrc;! g$ P% y+ P, ~' C
var newXDir;4 K2 C s7 \. p0 S# y S+ d' P
var newYDir;
* l4 T% V( O- t6 D8 C6 y6 D7 h$ f
4 [# Q- P/ _ ? s. w4 nfunction initializeBall() {8 q* M5 H8 O, k& R* J) N/ g+ Q, T
if (document.all) {# G6 l. e0 c" K9 h
xMax = document.body.clientWidth" d( e" j- W, K U7 S# m1 P+ A
yMax = document.body.clientHeight
1 ^. A9 g( z. m1 h1 g' r+ O5 k document.all("supertext").style.visibility = "visible";5 i0 _" [* O$ {
contentWidth=supertext.offsetWidth) d8 H1 g# {& I; J" _+ B$ m6 c
contentHeight=supertext.offsetHeight- @% E# U8 y. N
}2 s0 T9 v: p2 @
else if (document.layers) {) ]* ] F; d5 j: ^3 f$ F' Y
xMax = window.innerWidth;6 G* f8 w9 `& y
yMax = window.innerHeight;
; Q o* X* S, N8 _5 ] contentWidth=document.supertext.document.width
: U" @6 I8 K5 {" F contentHeight=document.supertext.document.height
) |/ s. S. L- e+ ]. R; g" X document.layers["supertext"].visibility = "show";1 k5 z0 Z. d) f7 [. @5 I2 |3 d
}" b8 f1 f) v" X0 s2 a! T! M A
setTimeout('moveBall()',400);
! U' `# R( m, G7 o if (hidetimer!='')5 u# `6 y( l. c4 t, r
setTimeout("hidetext()",hidetimer)1 f6 [% a- G+ |& I
}& G9 K& p. c, y. i
$ s5 D1 y C, w: h+ W
function moveBall() {
: h1 s* u6 J/ a* M- e' T' B0 u if (superballRunning == true) {
* l6 p1 y1 `1 W$ Z# Q calculatePosition();
# A) M8 }+ [* o6 x: g if (document.all) {
, X( x2 v& _1 E3 |8 H3 l document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 Q8 W: [& T! n5 t document.all("supertext").style.top = yPos + document.body.scrollTop;
$ x( v* a- ~4 i% ]. M4 L2 ~7 G I }
& }$ k8 k6 x$ ?) R" l, Z/ s- I else if (document.layers) {( v, `( I1 |4 Y% x- X) H$ X- v
document.layers["supertext"].left = xPos + pageXOffset;
0 Z0 |, w1 r8 T' V! B1 P+ W( }' q document.layers["supertext"].top = yPos + pageYOffset;5 s5 O6 B! Y# L* C- o* y( p
}. T* { Z" j9 m, @7 o. G ~4 Y. ]/ h7 P
animatetext=setTimeout('moveBall()',20);1 A( a7 U5 z X5 |
}
! W$ ~9 h0 K. z$ f5 Q/ l o( Q }& K/ ?7 U: F- r! E
! u3 {; e5 r/ c$ w0 ?- j: I
function calculatePosition() {: }! ?' l, E9 J% Z
if (xDir == "right") { I$ R) L4 D$ `2 |
if (xPos > (xMax - contentWidth - BallSpeed)) {
( F, @+ L4 `& I" |* ? xDir = "left";
5 i; p' L1 N! s3 I }8 V2 m: f7 d( H6 |+ x- T
}
/ z* v5 m& Y1 {3 P else if (xDir == "left") {/ d1 u \- T9 J$ n0 P- ~* D* ?
if (xPos < (0 + BallSpeed)) {6 b. L2 d v8 I
xDir = "right";
1 u) ^7 S: X! V7 @: d4 j5 h }3 I V- c2 J: d C t
}
0 q' S' r2 E! Y' g9 A+ X O; T* I if (yDir == "down") {
% X+ j' ~7 d9 [& o+ F" @ if (yPos > (yMax - contentHeight - BallSpeed)) {
1 @4 l" `, S0 y( p3 t- C W yDir = "up";
( A$ I) q4 A3 p. g% Y5 u }
; q, p) s. x8 g% t8 x7 ^ }
/ g0 `) i, x# R" [. [ else if (yDir == "up") {
# t3 H/ S' { c0 U1 B if (yPos < (0 + BallSpeed)) {
- e, @: S" M. O% c# o& e% N yDir = "down";; C8 z$ [6 Z6 J* _/ k% G
}7 d9 J% d/ P3 E1 N! X
}
& c- O$ T/ G. l* E& q2 V/ ~ if (xDir == "right") {: A6 p+ W1 {( s: r
xPos = xPos + BallSpeed; l6 _* P' o3 N( [2 @
}' f" v, E* u3 i6 [0 Q3 j$ c. }
else if (xDir == "left") {4 m7 L5 h8 ^* M2 a+ e
xPos = xPos - BallSpeed;' v+ y5 w8 s: s( N. F/ q7 t$ b0 U' U0 m
}0 B! E) R9 z% G# `0 |
else {
' Z; J; N4 k- G! q& G+ h7 @* O xPos = xPos;6 [% B& V0 F& g6 e" {& K
}
1 c& o+ E6 L+ N" T' v( E: V6 ~6 L if (yDir == "down") {( `6 n' j) Y+ I. p( D
yPos = yPos + BallSpeed;
$ p& K+ n0 S+ F0 l }/ f$ g0 P3 |+ f5 O
else if (yDir == "up") {
I' q, `! D- G# l1 @ yPos = yPos - BallSpeed;
\4 B0 F M& {; f3 k }* s5 Q) x! x5 ]* U
else {7 U" y6 y! I" o/ _& a. c
yPos = yPos;3 [2 Q& h# ^- q$ ]% x
}& r6 F5 g; |2 Z- U# x
}
; N; Z) W/ ~, ]) E8 ? F! W; J: a+ ?2 a, w: L; X8 [
function hidetext(){% P7 t1 R/ N( ]% s2 W5 J$ `
if (document.all)8 ^) [& b6 K2 Q) ~1 H1 a' E
supertext.style.visibility="hidden") A, a% }0 t0 @- F9 s3 I2 D
else if (document.layers)
/ V1 I( V" ]! a; P+ R c! h3 {document.supertext.visibility="hide"2 E5 k0 y' V0 n# M
clearTimeout(animatetext)* H7 Z# E# {+ W* U8 F; u
}1 d0 h" i! H1 Q1 ~# f
* ]- d, L3 H7 {
if (document.all||document.layers){
9 D6 e v" F5 j: ddocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 C3 ~4 B( \2 s+ G, K x
window.onload = initializeBall;
; Y2 Q5 S ^+ X. A/ Xwindow.onresize = new Function("window.location.reload()");
' B% G2 p* c% }' V8 v}
9 e; W }3 H0 ?5 {) U; D9 ~3 g& N6 x; f* o. c4 u# |
</script> |
|