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

|
网页之不断弹射的文字-特效
<style type="text/css">5 U; T% M: C; i7 ?) v, _8 K
#supertext {% I$ x3 M0 T- G4 y$ p* h" @1 T
position:absolute;4 ~/ d/ p0 b) E& I% X
left:0;( B: ^7 ?4 R' _4 `7 x- U7 }
top:0;
! v$ M* b: o7 Dvisibility:hide;$ h- F+ Y: N( J
visibility:hidden;
3 L, y7 {" Q* u# p}
) ^: L- a- I7 b+ U( {" L</style>& Y8 R( T1 r3 `# l! D* e/ B
<script language="JavaScript1.2">
, u! T% z! Q) X6 u# y" L$ t/ e<!-- 改变下的字体的大小。颜色-->% ~6 `9 I0 [: E$ ^$ j* P0 W
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 U7 }, \+ F( w2 F
var hidetimer='';
8 F& |: A f& S5 {1 t<!-- 改变下的弹跳速度-->
; |3 s' o9 T2 R' a$ Gvar BallSpeed = 20;
! [* [1 F5 Y! `9 g& P. cvar contentWidth;5 Y6 x' i6 \+ L1 d3 L
var contentHeight;" W, D- S4 V7 M. j& C3 [( R! o
var maxBallSpeed = 50;( L* e) G8 P+ [. V! z
7 A$ H8 R0 p9 ?5 N. F, a! X, y9 M4 M. w) K6 }
var xMax;2 G T. Q o! r- U' C5 |1 o
var yMax;
$ X/ Q b3 V5 D( ?var xPos = 0;
" N3 h5 u. E& R8 y1 a2 qvar yPos = 0;
" y, L7 p: S' O/ rvar xDir = 'right';6 g5 Y# E* \7 _$ @- @( |
var yDir = 'down';
& K7 |5 n2 ?$ T' S bvar superballRunning = true;
( X E/ k* B! v8 {. a! K2 ^/ ]8 Jvar tempBallSpeed;
* w( Z2 Z* ]( Avar currentBallSrc;
# U0 u" e8 K* E( H4 Z0 j* Evar newXDir;
9 v4 f4 \$ f- Wvar newYDir;
9 Q& b* \- X: B k L: B2 n* g/ F+ B& Y( o4 i* ]. O* j8 D
function initializeBall() {
( D- k# V( |; k$ u2 b9 M if (document.all) {4 x. ~! n# f' v2 _$ h3 f" O/ x
xMax = document.body.clientWidth
6 [1 q7 U8 `# `$ z2 N1 R& v; ` yMax = document.body.clientHeight
5 f$ h+ L; N. e- }$ r" N document.all("supertext").style.visibility = "visible";
* B3 ]& p" x$ q contentWidth=supertext.offsetWidth2 Q* q7 Y9 M$ @6 P# ~ L5 G9 N
contentHeight=supertext.offsetHeight! j. S3 M9 B( L4 d
}
) |7 L- l7 w, q' x5 r/ v c5 r% R else if (document.layers) {% U7 t7 l. @$ O* T+ Q
xMax = window.innerWidth;
& _" r; r0 H9 k* e, d5 v yMax = window.innerHeight;/ F" _1 E) h1 e. g5 [8 b5 ^ o
contentWidth=document.supertext.document.width/ W6 U% [3 n" Q+ q- E
contentHeight=document.supertext.document.height
R6 c" A% e5 x0 [" ?9 O2 c document.layers["supertext"].visibility = "show";. c6 H1 q" S, g% m& X, y. }& s
}1 m1 I# }5 J4 L3 f
setTimeout('moveBall()',400);% [7 d4 j% M$ u& A, R0 ^
if (hidetimer!='')
7 h& O m& c0 v+ Y! ` w9 W- n5 q' ` setTimeout("hidetext()",hidetimer)
* X8 [2 z( w' z6 b4 j6 y }* z5 i5 H5 [% L! } J8 C S6 M
/ v2 L* N6 y1 ]& ]9 J" q
function moveBall() {9 H3 q: G0 C& N) p1 ~8 T3 v
if (superballRunning == true) {) R) I* ^) V; G2 v
calculatePosition();
" j% Y0 y+ X* c" W5 K- j if (document.all) {! h1 N$ R& E# ^: h- O4 e
document.all("supertext").style.left = xPos + document.body.scrollLeft;' [; @( t/ s3 s5 t$ o
document.all("supertext").style.top = yPos + document.body.scrollTop;, {7 Q$ R% U( k* o5 M s( ~6 {
}
Y8 u2 q: |% [3 l else if (document.layers) {
/ @* G3 U4 i; T a) k3 F: M document.layers["supertext"].left = xPos + pageXOffset;
% b- G& b; ?/ ^4 D$ q* j document.layers["supertext"].top = yPos + pageYOffset;
+ F G% @% Z3 R2 |3 Z6 T }
2 H9 a2 I: E; Y& V2 k, [3 d5 U animatetext=setTimeout('moveBall()',20);
& j* o/ s8 I0 S; [2 i: r }
' g. h2 K/ v' ]/ r( H } g% i& h, I# @4 i2 k( V3 d
: A4 d$ G0 N; K1 g+ I/ Ufunction calculatePosition() {2 v! z, w3 x% R6 N6 Y) R
if (xDir == "right") {7 s0 N1 h9 ~, N
if (xPos > (xMax - contentWidth - BallSpeed)) {
# s; B$ n: Q4 ? xDir = "left";# V; L& W/ }( `* G2 F& B
}
- T+ s$ d) G( \ }
6 p% F: J$ {* q+ c3 q/ A& T& @$ p/ q else if (xDir == "left") {
+ Q0 O/ y) h$ U) N, H T( N if (xPos < (0 + BallSpeed)) {4 q5 I" k) I/ m3 |% k/ I* F
xDir = "right";
: J, `3 ?" Y/ y* m9 { }
8 P( R% Q: c. T7 {' H. [ }- w& B; {! g0 Q5 ]4 g) x" Q% Y8 |5 j
if (yDir == "down") {
, z z4 R j3 [5 |/ R, R3 w if (yPos > (yMax - contentHeight - BallSpeed)) {
4 d$ E% q m7 t0 X. l: s# c yDir = "up";( ?3 c2 ?( v" p) Y$ D* i3 Y
}
) o0 o$ q$ U) [ }! M/ e# }8 Z: z
else if (yDir == "up") {
1 t# S- Y5 b5 X. a. Q, ^8 `. W if (yPos < (0 + BallSpeed)) {7 z5 i# Z) Y1 W$ [/ d
yDir = "down";
" [3 A& }8 c, `+ h& C }/ u( E1 P A* l7 X# t5 M% J
}. N6 r7 s% V3 n) f
if (xDir == "right") {3 C( i6 D3 \( C) u2 U% W
xPos = xPos + BallSpeed;7 O' J. h/ ^9 h6 [8 z1 m. M. e
}
3 Y" h+ j! o! I- Z* @8 L else if (xDir == "left") {
. y y) b4 k7 w0 d9 K+ C$ u$ m+ a xPos = xPos - BallSpeed;
7 {& e- q$ q [' l8 g }
# i9 c7 K0 ^+ J+ L( U4 ]: K else {. K, m2 Z) {3 z& i* A5 D0 c
xPos = xPos;
- j2 J8 q+ |4 ?* W o. p/ T+ o }; k- x* a! D! g
if (yDir == "down") {. W9 y0 v7 ~! P/ {3 J0 D+ V' Q* l
yPos = yPos + BallSpeed;0 `- @- K3 \' b
}
) g5 o+ M! Y9 [" j# s9 s" ~% d. Z else if (yDir == "up") {
" H0 |: m3 x- _% C; c7 D4 a( }/ k yPos = yPos - BallSpeed;# s! { M2 S; l) n
}
2 B' f+ L- V' A2 q1 A5 w/ C- t else {
& w& r- ^5 o/ L8 c5 o/ E$ m yPos = yPos;7 T/ O" }& t5 K" K
}/ A7 L; u0 m: Q2 ^ S5 Q: C. B
}7 P: c6 m. _# g; M9 }8 _
: K4 v7 R5 d. n3 i: k. [
function hidetext(){
. @- z7 c8 c& s- m, s, hif (document.all)2 I% d9 {( a, Q
supertext.style.visibility="hidden". k; `+ R# H1 Z1 h7 e: \( z$ |( y( t
else if (document.layers)
7 D0 [ p9 l5 |' h2 V$ R4 @document.supertext.visibility="hide"
4 G) D+ \0 \% {2 v0 Y9 N" a, nclearTimeout(animatetext)# H: ^; T, R; L2 S4 _
}
, _& \* m$ n) g8 E2 _7 \1 M) [
" ]2 h4 W2 i, ^; @if (document.all||document.layers){
5 t4 ?- O3 t, e4 P/ v: u, Jdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>') l" v5 Q( Y- y1 k& H
window.onload = initializeBall;8 [0 U0 X0 n+ D5 a
window.onresize = new Function("window.location.reload()");, x5 h6 B( N- h) z
}
8 N. X m5 V- \) E& C1 u4 F0 N. v# ?' U" g0 _ j0 y' s" p
</script> |
|