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

|
网页之不断弹射的文字-特效
<style type="text/css"> X' e" v& P- a: ^
#supertext {
2 w2 t) c1 R+ n; ?position:absolute;
9 Z1 c$ C/ T5 C l) Ileft:0;
0 `. ^ @# S8 T9 v" ztop:0;( O3 ~ {4 i2 N% Q
visibility:hide;
# J4 M. G# S% F6 m( svisibility:hidden;
# U( _7 M2 g/ N}
( M, m; v0 ?. r M4 X/ v</style>
! D/ L# @% S' }! ]1 J! i<script language="JavaScript1.2">
; P& p0 ]6 F, N) v<!-- 改变下的字体的大小。颜色-->' c" c7 z% l! {- O1 I9 H
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') m0 y: D- u3 J+ G3 M
var hidetimer='';
* q y0 R% E$ c+ G1 _' n<!-- 改变下的弹跳速度-->$ n6 t/ Z: j. K* v
var BallSpeed = 20;$ k* z8 _7 p* B$ p+ L; v0 C
var contentWidth;
0 r6 P a* c x! x& f+ y& bvar contentHeight;
; B1 a6 k* b2 J' L8 I1 |5 _" c J$ avar maxBallSpeed = 50;7 g0 L6 D& g! U: j+ g: A
7 V5 `% A/ P- r
. B g7 d& F1 H: ]7 tvar xMax;) U+ R1 b; L1 @* n
var yMax;
' z8 i6 d/ n. ~/ ?3 J0 q/ W5 b1 W9 H: Vvar xPos = 0;
, b( s& L* x6 s. X' O2 L4 I1 ~var yPos = 0;
) P5 M; R5 P- u& g a6 J" z9 Q$ Nvar xDir = 'right';" I- B' o6 l6 X
var yDir = 'down';
1 _! t# H8 v0 [/ d: n" U4 f/ ]var superballRunning = true;
. o: ^4 x/ ?6 B+ F% ?var tempBallSpeed;0 E: K: ` H/ g8 z
var currentBallSrc;
% k3 K; y) _. x0 n9 ?+ nvar newXDir;9 |5 j8 h# U% Z
var newYDir;' e7 {. J+ ] h* e* z- `
4 B5 X6 K5 z7 E1 e& U: Nfunction initializeBall() {
9 b: E4 _* G4 g, j3 W5 a: c- k! S# _ if (document.all) {
9 K; A9 b4 ~. d, K% y xMax = document.body.clientWidth G: J8 C! F' J0 O; V4 E9 L) G9 O; k
yMax = document.body.clientHeight
$ V' U( u+ E- k document.all("supertext").style.visibility = "visible";
9 o( _( x2 [) H4 T9 K4 a contentWidth=supertext.offsetWidth
7 ^' J2 l& ]1 G5 W) W) L% C contentHeight=supertext.offsetHeight% @. h$ q h- o, X" ? a# \
}' C: o+ Y2 M8 p& {" V: t6 [+ d3 t
else if (document.layers) {6 w6 y1 a3 M7 t* Q; ?2 L* c8 K
xMax = window.innerWidth;% r4 Q0 b' S* D+ ?/ R
yMax = window.innerHeight;
Z; u9 ]6 x5 Q4 P contentWidth=document.supertext.document.width9 b/ R* x' L& o! N3 C
contentHeight=document.supertext.document.height, S6 G8 c3 p$ v
document.layers["supertext"].visibility = "show";
2 F# U+ c% L n4 `' m3 d }
7 }/ L% C7 x/ j1 _ setTimeout('moveBall()',400);
' X" D; z, M, P* N. j if (hidetimer!='')" G# j' @5 D% |8 R* ~# u# S* y& V
setTimeout("hidetext()",hidetimer)% B& n( h3 ]& R9 L( P
}" K# t5 P& C; v& s2 C+ m
; u/ O( j n' F2 y! o, l
function moveBall() {5 O+ q! k0 D3 x n3 v
if (superballRunning == true) {
3 j. o$ h: Q1 I4 |% Q" b- e0 S( D calculatePosition();8 u7 Q4 x3 K ?7 k
if (document.all) {0 Z9 g* d5 z* ]! ^( y# {) o
document.all("supertext").style.left = xPos + document.body.scrollLeft;
, P7 m+ q: E9 \* D7 G: X% e document.all("supertext").style.top = yPos + document.body.scrollTop;/ o( W$ S8 o- z0 u% A
}. g% k+ W- C5 p k
else if (document.layers) {
0 d5 |- D0 }) a4 h% d document.layers["supertext"].left = xPos + pageXOffset;
( L0 y% W+ x6 C, s$ m. A document.layers["supertext"].top = yPos + pageYOffset;
% u4 X5 z3 w$ b. E+ C2 g }
( v) A- ~ M# w H* f; U animatetext=setTimeout('moveBall()',20);
" a- D" {# M: f& W) h2 d }7 ]4 P+ {6 }7 W3 p+ i* H9 }/ f4 ~- t' e* J
}: `5 C# `/ ^! p" b5 K$ J
, z4 h, D8 m- U& f! R. s9 r
function calculatePosition() {5 {" i. O$ Z2 k& Y# @/ w
if (xDir == "right") {
3 l: u4 _( L2 K% d( } if (xPos > (xMax - contentWidth - BallSpeed)) {
0 f0 R v7 x( s xDir = "left";
: N s5 H8 k/ l' L" E3 M: W }7 C' H7 o2 G- y
}
+ k7 x' e9 ~2 t1 p, W3 V' H) E else if (xDir == "left") {. l% k ]( o1 I: h# D, [
if (xPos < (0 + BallSpeed)) {
- D' A& _7 M- c' ?4 j+ E# W xDir = "right"; k0 g1 }2 j) W; u# u5 J
}
% o4 q/ {! V6 h7 _$ a5 k' a# r }& ]% Q- A% p' g3 j3 l
if (yDir == "down") {
6 S( f9 V* G# A+ h1 M8 e7 e0 K if (yPos > (yMax - contentHeight - BallSpeed)) {/ A" ?1 H( r$ i/ Q
yDir = "up";
' Q: x$ [0 u+ G7 K T } x2 |& X: w7 `4 d
}
) P, B5 t9 M' D) M! B& x else if (yDir == "up") {2 `; X6 ~% V/ }) q6 W5 h1 ]
if (yPos < (0 + BallSpeed)) {7 S" D/ h7 B% C* v, t5 X
yDir = "down";/ T ~4 H: m$ N* h( y; t6 {- H
}- l6 x" t+ {& C3 T+ K0 D' \
}* v4 U( G! D2 \0 s; L
if (xDir == "right") {
% ~! ^. n9 g! x xPos = xPos + BallSpeed;
( U8 _1 D' W0 ~2 L8 p! Q6 B }9 v( P# Q' D4 l9 W
else if (xDir == "left") {
6 o* ]9 y, H$ x) _5 b xPos = xPos - BallSpeed;; d' L2 R( V# s( s, {- I. s: y5 ~
}7 b Z, m; R5 S5 B
else {
% ?; }7 j6 |# [( ~& j* K xPos = xPos;+ H7 O! \5 l; _7 O
}
# I- R# H! Y( z6 R: j if (yDir == "down") {
( r2 ]: s, U6 k5 j& W- T yPos = yPos + BallSpeed;
$ a& [" i% i/ r- O }
, Q$ a# V- U" n3 H: G else if (yDir == "up") {
: F3 s" [6 Z5 |- T yPos = yPos - BallSpeed;+ A" F4 U( S. T5 f1 A, |1 W
}
/ J' y4 ^8 ?& _/ U7 \ else {
, A: O4 l e! p9 l& [ yPos = yPos;
3 q- n: W' [! I1 [5 w$ u, s }
8 y+ M9 t5 y; k- x0 H }. I% E( g9 S4 y/ Q7 ?
) Y' r6 ]# g6 p$ rfunction hidetext(){& K% Q3 z7 ~, B8 a7 g- F/ M
if (document.all)
; X( G3 Y7 v% r2 O% }supertext.style.visibility="hidden"
$ y* n) n& _2 w+ S; yelse if (document.layers)5 U2 N5 Y& g" ^, L1 d6 S
document.supertext.visibility="hide"
b' \! H3 H' j: yclearTimeout(animatetext)" I v/ p9 d+ m/ P' l! V' `
}* [: r+ ^( }8 S2 C
' |$ }# H8 a2 G3 a! E J
if (document.all||document.layers){: i5 @$ J K) h7 o d4 w
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'). t4 Y8 U. J3 U& I" }( o/ p
window.onload = initializeBall;
* Q Z( k) z' w; G. M" ]window.onresize = new Function("window.location.reload()");# i V/ u8 g- t+ a9 L: G" U
}: L) M! o! [9 \. X9 W" q
& Q" \- s8 `: Q# z O; A, R</script> |
|