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

|
网页之不断弹射的文字-特效
<style type="text/css">
3 [8 M* M' q2 _#supertext {$ o5 F' K8 B* a' \0 I; a4 O
position:absolute;8 j( Q# v7 h1 U) `. x
left:0;4 }! M' o( P" Q8 c9 a* D
top:0;' K v$ W- G! h6 h `
visibility:hide;* X1 W& A/ s. t0 q3 o7 y
visibility:hidden;
6 g: B8 K% x5 L# S# n3 o2 h& N}
( h1 k* _6 ~' J1 D5 V# k2 g! h2 E</style>
* M4 W( \" D3 f- S# b3 }<script language="JavaScript1.2">
7 C, T, X' \; E<!-- 改变下的字体的大小。颜色-->1 I4 o7 K* }5 D2 U% x
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 N3 [0 A0 V# F5 Cvar hidetimer='';
( D% r: a3 K0 G! u$ V# P<!-- 改变下的弹跳速度-->; l8 a) i' q: I4 k% `
var BallSpeed = 20;
! ~/ w$ x0 f7 y3 S% e! q2 Zvar contentWidth;* b: M/ p3 @' ^ b
var contentHeight;
" k- {# t1 G+ Q. o" lvar maxBallSpeed = 50;. n+ N8 r W6 O, q9 k' E+ }
8 A& |* p$ O; w2 u
) M( w: v& J9 u u* `- |var xMax;' A' I( ~: q/ V: P
var yMax;
l" T4 K L& b( y# s+ W, |8 Q, mvar xPos = 0;: |3 k) Z8 t* a
var yPos = 0;
9 {3 E9 |3 L# u' k1 h4 a5 N# |( @var xDir = 'right';+ j. X0 P1 C1 B8 D
var yDir = 'down';
8 ^" L+ d" w$ C7 evar superballRunning = true;
$ x3 V! Y' U& ~% s, x9 i7 dvar tempBallSpeed;9 r" _0 h9 ~1 F0 p: c. c% T
var currentBallSrc;
; @: k5 S* f4 F; q0 b$ |1 m1 Xvar newXDir;
# Q$ ^# \3 R7 D1 ~: u$ Mvar newYDir;
- W, Y0 _5 E, Y7 F* K# N" s
6 G7 ^( i5 w4 p- W2 z, [, ]function initializeBall() {2 J4 R( ]7 b% f7 \8 o. v) ]
if (document.all) {
) J# n" G. m( J4 n# P/ J xMax = document.body.clientWidth
0 ]' B) G1 _ {$ B2 g yMax = document.body.clientHeight
; }9 P9 d2 V \0 ]# I8 D$ M document.all("supertext").style.visibility = "visible";
$ R$ h1 K( ?8 c contentWidth=supertext.offsetWidth
4 Z) k8 i6 j" p- h) }( D; D( Q* O contentHeight=supertext.offsetHeight
. i% I5 u4 D) ~" U' v& x( C }- ]/ i0 z" O0 g& |& Z$ k
else if (document.layers) {
; q- S0 _9 a x8 f% w xMax = window.innerWidth;, o: J7 v: z6 B v* ]) r8 g% c
yMax = window.innerHeight;8 |* S3 ^/ V& Y1 D, x0 J6 ^/ u) L
contentWidth=document.supertext.document.width7 T* N* O. v6 G& Y
contentHeight=document.supertext.document.height
: [) y G# _' a+ w2 |+ H! {3 o document.layers["supertext"].visibility = "show";. N* X9 _8 }! I0 Y Q1 F
}
6 C9 l+ s$ r- l9 ~% ]9 g( u setTimeout('moveBall()',400);
3 W1 C& C- E" s3 G7 I. v- l+ G if (hidetimer!='')
1 z" `* ]+ e& \0 C! y3 v setTimeout("hidetext()",hidetimer)
! x3 ~! W7 A+ _4 w# @8 | }" U" ^* b* e" L9 G6 F8 g$ K+ z
- I2 c+ W! }: Z' G2 X' A
function moveBall() {+ h, f# E9 J1 F+ P P8 }3 R" F
if (superballRunning == true) {
5 C% T* ], a4 b t6 H- z calculatePosition();3 P2 Z' u5 J8 ^3 o
if (document.all) {1 i9 j3 c! v |
document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 I$ a3 o. H- A7 W) S2 m0 N document.all("supertext").style.top = yPos + document.body.scrollTop;
4 j7 \, J$ e. x+ O2 W }
$ V# v& z4 W5 @% g* E else if (document.layers) { H p$ P8 M: s6 o1 t4 O9 l
document.layers["supertext"].left = xPos + pageXOffset;
V" I" p. u& ?) [+ V( Z- n/ W1 ? document.layers["supertext"].top = yPos + pageYOffset;
( |/ e; x: ]0 t* x' O; B# F, E; B- Z }2 A/ D8 x8 O2 ]! K* G
animatetext=setTimeout('moveBall()',20);& q) ]9 G9 _1 ^; {
}0 O) m/ k. x5 a0 I3 P8 q
}
7 e( U% ~+ E% W% H7 l7 J5 q) P- ]9 @
function calculatePosition() {9 b# U3 S+ Z4 y% L {
if (xDir == "right") {
! Q! t2 Q0 n5 H+ N5 m+ G, E, i if (xPos > (xMax - contentWidth - BallSpeed)) {
' E1 W5 G& g% L/ u0 n9 u xDir = "left";5 Q1 m+ t! [ ?! Y5 @3 a
}
" r K& s6 ]3 X& J. P3 ] }
; {5 r. T+ W4 B* a7 W3 X) r else if (xDir == "left") {
5 d( M/ \+ g, Y: y if (xPos < (0 + BallSpeed)) {. [5 ]7 T, u2 W8 Q, F
xDir = "right";
% T+ U, m$ ], q6 D' C }
9 P8 g/ ~5 I: B+ k5 J }
, x: {( r1 Y1 r+ Q1 Q6 | if (yDir == "down") {) s) |0 x1 M4 `. v. x# c) d# N
if (yPos > (yMax - contentHeight - BallSpeed)) {
7 Q i- E- w& R yDir = "up";1 |9 p7 X6 q; ~( _% S5 p/ g+ K
}5 z( G* l+ i0 m$ y$ C+ u1 W( j
}: \( k( N0 c7 e9 s# H7 p f
else if (yDir == "up") {- w, C5 e5 w# s+ \5 y
if (yPos < (0 + BallSpeed)) {3 m# s8 D/ V n. C C. M* q1 [
yDir = "down";
: g" D0 y6 s/ k/ O* p+ L) J% Z } K2 _6 u; t& I7 p }
}0 b* ]7 D( c; _$ T) O
if (xDir == "right") {
& K7 D0 f, m* G" r5 \; L9 h: v xPos = xPos + BallSpeed;- ?# F3 H! @0 f3 u; F- X
} Q, g# \3 C: H# w1 {
else if (xDir == "left") {
, u: O* B ?& P) v xPos = xPos - BallSpeed;
7 x! @% `. D0 D" U) ] }
# o, C0 I8 j6 D& @5 }% g2 R else {
; J9 G& p$ E7 |* B9 P. `0 ~9 v xPos = xPos;
# e; e+ t2 I' a( w H1 O+ Z }
. w! X7 e1 ~, l# o0 Q" L9 E if (yDir == "down") {9 {; z- T2 F/ t$ S! s: ]- q+ w2 w* y
yPos = yPos + BallSpeed;7 v- R5 d& d$ ~4 q, ~9 u
}
6 @! _" n) [5 w9 g else if (yDir == "up") {+ x/ }% W& F) x. z
yPos = yPos - BallSpeed;
2 `' y) E4 }; f% X# X }* W. B5 i$ j3 W
else {; q4 k' C7 R4 h. W9 g& p4 V2 T4 C
yPos = yPos;- i) A" X3 s2 Y1 i) u
}
: H1 n7 w$ E3 H% V }
4 N( p6 \; E# w5 i+ Y( R: D U* L. w( C5 c' Z$ w& \# c3 G
function hidetext(){1 y! s! w% a1 c
if (document.all)
: c/ ?2 F. B- F" Z! w2 D ~; Nsupertext.style.visibility="hidden"3 M B1 G2 |3 v1 R" ]/ C/ ?* B# g
else if (document.layers)/ o: ], x" F" D9 E% b
document.supertext.visibility="hide"; A, D) \0 C- s7 l, B, }- [
clearTimeout(animatetext)
$ D0 P8 N. O3 \ i}
; z5 n5 \' {4 f& {9 ^4 M/ P6 W9 t( m4 Y/ s3 e. v. q- [( o8 F
if (document.all||document.layers){
* G% h# m7 Y; t- Xdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 m1 F6 M! B) D4 j# O
window.onload = initializeBall;3 P# L6 {7 ^+ q7 R
window.onresize = new Function("window.location.reload()");
, n I( V9 a" t4 r: N2 b2 \}
! W4 D( ~1 h9 g) J6 ?+ P5 h2 G* \
Q( q% Q( s/ `' v</script> |
|