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

|
网页之不断弹射的文字-特效
<style type="text/css">
% w( {. S6 F9 \0 o- ~. E#supertext {
8 t6 Q4 ?8 n" @$ v6 J! Fposition:absolute;
( `6 t+ G; k4 L5 M/ P7 jleft:0;
, C* v( Q0 Z2 q( P, x- Ctop:0;
1 r) I7 C0 A- t/ t6 ovisibility:hide;
* W, I& l' t | K P' n: F1 Evisibility:hidden;
& O5 P+ o& r' o9 j}# W, G' J- ?2 B
</style>
- {* b9 Y1 V6 T4 t' k& x<script language="JavaScript1.2">
9 I$ ^9 ~0 Y5 M<!-- 改变下的字体的大小。颜色-->) _9 `* |" E" I6 y& C. J% q
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
9 x* _2 D* |( C/ o, e5 p% V* }var hidetimer='';4 A+ j! Z+ W8 U" n/ W
<!-- 改变下的弹跳速度-->( u# x/ _0 S) E& R2 \& k6 D0 \# }# ?
var BallSpeed = 20;
$ _: p6 J4 g. A5 d9 e8 lvar contentWidth;; c# p, y( R/ N; g2 r7 {; ^
var contentHeight;
4 Z- J! A) ~/ y, t6 V6 `var maxBallSpeed = 50;
8 }& K4 O, M8 \
0 o/ y1 k* n( }5 j5 A8 u+ g" J( A5 H/ R
var xMax;
K' d2 d5 K! [: S8 ~) X& [var yMax;$ i( e3 o |( S- `& b$ @
var xPos = 0;
! q" X, Y0 I" p7 o: O. ivar yPos = 0;; L& O3 U+ n: ]* c
var xDir = 'right';9 y' P: x6 R' K: U. j6 Q
var yDir = 'down';
. e: ?6 z0 U1 p t8 [var superballRunning = true;8 l( N- L7 y7 J4 @* E: I
var tempBallSpeed;
* k1 ~" N* { E$ Ivar currentBallSrc;- C, ?8 |& {; { Q6 M8 ?& p
var newXDir;
3 J @% R6 n) f) D' p! `. e+ U( m0 |& Yvar newYDir;
1 p! I6 E. Q, E( h! e8 l1 G' J, _ G: W
function initializeBall() {
' t' M' R- s% e' r if (document.all) {
! p, I$ J1 J& E9 V7 P2 Q, j xMax = document.body.clientWidth J* m v* U" b8 z6 C
yMax = document.body.clientHeight+ S: T* h+ _- e" Q* N8 D
document.all("supertext").style.visibility = "visible";: Y- X {; L+ k
contentWidth=supertext.offsetWidth, |! O% `/ n m: T! W. v
contentHeight=supertext.offsetHeight5 Y9 `9 L! q. ^+ i* f3 A
}5 ]+ y) U, w( r5 q6 Q/ ^
else if (document.layers) {
7 H; r! s4 Q( n" [. c- v+ d, A xMax = window.innerWidth;# A( S) ?- G) A& }
yMax = window.innerHeight;) w S( M) k" r, } O
contentWidth=document.supertext.document.width3 L' `" h* x( h+ F2 h
contentHeight=document.supertext.document.height
% G m2 k0 b; p4 O document.layers["supertext"].visibility = "show";
0 r) B8 L6 K* ?: _ }
6 R; q v+ j& P1 r$ ^ setTimeout('moveBall()',400);0 h2 H0 Y# O! Z/ `: E" b
if (hidetimer!='')
. }9 J9 H% r. s' h0 y4 M setTimeout("hidetext()",hidetimer)
! o: z8 G- l% S! f }# K+ _# D7 ^ @" s& y
( W6 a/ W) V: t6 P; L/ H- G
function moveBall() {" `. Q" ?' i- a* w$ u
if (superballRunning == true) {! R- C0 [; d1 _/ @
calculatePosition();
( y' Q% p6 H9 M7 ? if (document.all) {% M, q8 d$ q: Y
document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 V4 f/ d# O/ l: y* x document.all("supertext").style.top = yPos + document.body.scrollTop;9 e3 S% Y1 z! Y! g# `9 n/ [+ n8 O, c
}; M6 {3 O: C4 Y: W6 P( w* g1 E" h
else if (document.layers) {
8 ~- K4 l1 S* H! @ document.layers["supertext"].left = xPos + pageXOffset;) G( t0 r5 k$ T$ y. Y' x
document.layers["supertext"].top = yPos + pageYOffset;% {* Z2 h1 o3 p( j) H
}7 U# j/ I' |& a( Y
animatetext=setTimeout('moveBall()',20);
7 U3 G# I3 s+ ?3 G$ j' T }- ?0 d8 _9 h: j" |, V# @% ?
}
6 s9 a5 j3 ]# W F7 G0 t/ k. W: h6 {* a" P2 K3 U: r8 I2 n7 Z0 N, o) P$ R
function calculatePosition() {2 A! R% j+ G6 Z' J* i8 z3 `+ K
if (xDir == "right") {
" z/ ]" O }& y$ C( D% F if (xPos > (xMax - contentWidth - BallSpeed)) {
F* v# W' P4 o* F2 U4 p5 i xDir = "left";8 I' y5 f2 i* c2 [1 `
}
+ @9 N; w9 G, j1 K! q# ? }! w7 }$ X; r! w" h1 o6 r! [
else if (xDir == "left") {9 [' h3 z8 \0 M) g0 h* b/ |
if (xPos < (0 + BallSpeed)) {6 X% S I$ Y t' G4 u
xDir = "right";
# e6 F P" D8 T" ^/ a }
9 H" ~% Z2 `* W( z& R }; B l8 \! T; v/ n W
if (yDir == "down") {
! W* w. i' y$ [/ p/ u2 ]9 k: F if (yPos > (yMax - contentHeight - BallSpeed)) {
3 N' ?! ~8 K6 U7 n/ | z yDir = "up";
8 Z9 p# {+ F8 J p. C }
) a5 Q: B( {! J; V. A7 J }- ]1 Q3 b! Z0 ?9 J+ i
else if (yDir == "up") {, H- P7 s. U! M
if (yPos < (0 + BallSpeed)) {
5 W2 L% R( s+ x- j1 s yDir = "down";8 x& \& V# q6 f* A( w
}7 K9 F4 e* l+ U) N
}6 `( y; Q5 @1 U+ B
if (xDir == "right") {1 A. A; R, p5 l& b v* O
xPos = xPos + BallSpeed;7 v: r/ l3 z$ x1 a5 V0 ^& z: ~
}0 A/ G8 U8 n, J7 @& b2 c1 F! m
else if (xDir == "left") {( G4 j7 |$ c1 y; S
xPos = xPos - BallSpeed;
+ r* x0 c9 L p/ s }- v" p% G9 d/ `7 L( W* }
else {( n; b% l; z5 d. r+ z2 o4 M3 p( x
xPos = xPos;
) t9 B: ^) L. b }
t6 g* Y4 X2 ]7 v if (yDir == "down") {
* t9 V$ _- \4 U6 q2 Q yPos = yPos + BallSpeed;
" H. } ?3 ]# M% H. g }
w6 |& Z# a8 @0 K else if (yDir == "up") {- j/ I( U) m1 R y
yPos = yPos - BallSpeed;
: @- c ^$ ]0 Q0 N3 r }" a+ C* H. {( d
else {6 `5 m! w+ g ]
yPos = yPos;9 e' ?% _7 w' p y! t
}8 r0 }: i2 F3 w; C2 M
}- m# d& H3 c, E
! F- z. A4 w1 o7 s) Cfunction hidetext(){
& f9 a2 o, E. F% r8 T4 Jif (document.all)8 l3 Q: _& ^5 w% m4 A3 _; t' g
supertext.style.visibility="hidden"
1 i0 U) c4 q9 v8 d K' X: w' ^ Helse if (document.layers); O T4 L& @& i! a3 M$ Y5 a& b$ u, d
document.supertext.visibility="hide"
) J2 N* a9 R, h5 ^ d9 JclearTimeout(animatetext)
: p& B M- u; g+ X3 b# q' X& h" b5 k# b}* D$ b7 m- R/ D' ^ Q2 W e
3 X+ Z/ i0 a1 T; g5 ^ J
if (document.all||document.layers){
. G# L0 \, d6 N2 v( idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 F" ?5 ^( b' o, g3 V8 ?- T4 f$ Kwindow.onload = initializeBall;
9 n1 K5 }/ F1 ?6 s, \. Hwindow.onresize = new Function("window.location.reload()");& o5 ?1 J+ Z1 \
}: M0 w- _4 [! g
/ K; C/ Y+ a6 G7 H7 i6 Q* D; V</script> |
|