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

|
网页之不断弹射的文字-特效
<style type="text/css">
$ v/ y/ D6 m3 x$ s* ^" O* e9 U#supertext {
7 `( ^5 L5 |! E+ eposition:absolute;' Y- W5 V1 Z( q
left:0;" k! _0 d. I9 ]+ |, @
top:0;; l% \# R3 G3 y
visibility:hide;: ]0 ?# r5 J1 o: ~
visibility:hidden;) _: X$ _1 s5 m8 h( Q- @
}
% Q$ Y N! O( B# G8 y# C</style>
" Z$ j% B: |' W0 b2 D: y7 R9 d<script language="JavaScript1.2">
* K! S- k: F4 ~8 G* ?5 g B<!-- 改变下的字体的大小。颜色-->
9 W% D9 l9 L- |5 R. nvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 q; \! @2 F" l! J& ^% |
var hidetimer='';7 `0 s/ @2 I, ?
<!-- 改变下的弹跳速度-->" K; F4 B3 z+ T9 R& B- W
var BallSpeed = 20;4 K3 L* `! m4 A& H! l2 ^
var contentWidth;
- w! @. Y3 T% k8 v" K) cvar contentHeight;' X5 Y! E7 O# Z) {9 |) D
var maxBallSpeed = 50;
* r$ \; c+ a' V4 v( {5 H, Y8 e
( `* J4 E2 g2 v. R1 A6 q% u2 H$ S* O% v
var xMax;" p. f5 @4 [* ~/ T/ ]" x. S
var yMax;
3 Y! w) ]3 l4 W5 R5 i8 F* Z" Gvar xPos = 0;$ S( d# i7 U1 K6 K
var yPos = 0;
) Z8 o. V! ^# ?, q! Q% Rvar xDir = 'right';
: q6 ]% }) |" ?var yDir = 'down';
% f$ _2 z/ o* Bvar superballRunning = true;1 }; }" V% v' Y
var tempBallSpeed;& d. V5 w- x% [5 D I' Y
var currentBallSrc;
7 T9 G- V* D3 k4 Y; r8 g; Avar newXDir;
& h- r' S6 j- o- ^1 e {( Yvar newYDir;
; _2 O- x7 ?) W- Q2 w' m
9 E, G* _1 [* c6 J- q) l% tfunction initializeBall() {3 D# q/ Q, l+ d d! R, D
if (document.all) {) w, l- }) M( e+ B
xMax = document.body.clientWidth* ?! E; o0 o4 k4 s" [- `6 P( q1 T
yMax = document.body.clientHeight
) b9 @. I! ~) a, V document.all("supertext").style.visibility = "visible";# H1 w9 p6 k: Q
contentWidth=supertext.offsetWidth: _% I' n6 ]1 W5 ^" \
contentHeight=supertext.offsetHeight# \7 V! a' D( w5 z6 e6 J% x/ x
}5 T3 o3 h- l! C0 q+ X7 j6 G5 i& Z
else if (document.layers) {- v. f* t+ g2 C; k: k: }
xMax = window.innerWidth;# j6 @/ w4 a7 Y) f+ |8 Y
yMax = window.innerHeight;7 E; r4 [4 t2 M# f4 I5 k
contentWidth=document.supertext.document.width g* {* J, {9 z. p. O3 _
contentHeight=document.supertext.document.height/ O& b" j7 N5 N; S5 O3 R
document.layers["supertext"].visibility = "show";1 U1 j7 S9 c( i
}
( W( m+ v1 @2 @# \! n) i setTimeout('moveBall()',400);
' ]2 s* j" g- Z& i! e if (hidetimer!='')
6 N. o% t* S1 `- V4 s) ? y& u' m setTimeout("hidetext()",hidetimer). V# a* ], K4 h4 G0 Y4 E2 |
}- i0 C; J2 x- l1 S6 g
" f" }* c, [4 Q3 Qfunction moveBall() {
; ^% Q6 b- Z/ \7 q/ O if (superballRunning == true) {
! f% `; @' T2 K N calculatePosition();
6 Z9 r4 Q& s7 S- ?: `8 [ if (document.all) {3 B/ _& ^- w8 o' e6 ]
document.all("supertext").style.left = xPos + document.body.scrollLeft;# {& |$ ]8 P4 H- t
document.all("supertext").style.top = yPos + document.body.scrollTop;$ H& g! M b6 i
}6 z8 p: a7 W5 D- E) E& H7 u
else if (document.layers) {
; F, n- b$ n' m6 z document.layers["supertext"].left = xPos + pageXOffset;
2 V `4 r1 f' G0 O7 ^ document.layers["supertext"].top = yPos + pageYOffset;
6 M: w' b! I4 h( m4 Q3 A0 T: p }: k7 d. B4 u, ~) i& R2 h$ x9 m9 X% K
animatetext=setTimeout('moveBall()',20);
4 s& n; p4 k9 g: P; Y2 }" g }( K% M' |4 w, g P( B* n" p9 ~7 P+ I
}
5 O2 f& N$ X8 L0 d" ~7 P, e4 c
& O% k! I5 Z. N# p7 M' Rfunction calculatePosition() {
3 ^5 m) W+ S4 \8 ~7 @. y& Y if (xDir == "right") {
" `6 ?$ t, ~4 S5 H% C5 p if (xPos > (xMax - contentWidth - BallSpeed)) { o1 k3 K) `( ^7 ^ F: q$ @
xDir = "left";
, z* }( K8 q' i6 A }
; I- L! l& C5 i* T9 I! B( B$ x }
3 k/ ~5 u) y. z: s, F, X else if (xDir == "left") {2 R( N8 x9 x0 ^, ?# D
if (xPos < (0 + BallSpeed)) {
/ @+ j/ m7 t! J V2 r* B xDir = "right";
( s9 w3 j4 R+ b) p( [8 G' e; j5 f }
; U* {, \. W$ i5 p/ H0 [* z }
7 o7 U. \0 ~2 n6 d! x" P if (yDir == "down") {
/ ]$ Z) F2 r7 i3 [- f% h% S if (yPos > (yMax - contentHeight - BallSpeed)) {
' V. ~. R3 ^3 z9 f j8 n yDir = "up";1 a! D8 \" w/ P3 L
}
( F; |( G) o0 O% c6 }4 e9 E% ?+ L0 ] }
8 J: H; y- T, ?9 r else if (yDir == "up") {0 k0 L. f8 K: E {/ H* b4 k
if (yPos < (0 + BallSpeed)) {
1 j, \4 N6 j! `" b. A! n! B6 ?) A4 D yDir = "down";3 }* P8 j& u' L. D" j3 i5 _: C& q* j% m/ j' q
}
. [+ h/ X( \- U. ` }
9 Z H; Z3 k7 V0 m if (xDir == "right") {8 V u; C( ^' q+ b: ]4 @
xPos = xPos + BallSpeed;8 Q; {4 m8 u8 B/ o3 C3 y+ q/ A
}
/ Q# L: B$ @7 L. m2 D else if (xDir == "left") {3 S+ e- W: B9 O4 S% W, P( a
xPos = xPos - BallSpeed;6 d, g' i( }& b* ~
}1 ~" g, w" Q" [5 n6 m- s
else {
6 G" d. d: R# | d8 `$ K( e xPos = xPos;
- P! \3 n; O7 m }6 T# h) u. u0 ]8 M# L
if (yDir == "down") {
: T q2 P' K. ]9 I \ yPos = yPos + BallSpeed;
% o. k% h8 o0 U }
# ?; j$ Q' u' K# X0 Z. c! f8 ] else if (yDir == "up") {+ Z' B# H7 ~$ Y: b4 ~% a0 {* Y i
yPos = yPos - BallSpeed;' w& t% H$ Z% V+ N3 E
}: O/ k; T5 u( ]( e, z# ~
else {
6 B5 d! F6 p+ Z: U! A, H M yPos = yPos;
4 K4 d0 |3 X* A }
, {' t* e* n' I8 | M }
1 A. u+ U4 y! S7 @' b/ i6 y$ @* o# U, V6 t
function hidetext(){
; l6 U2 F" z6 t1 M$ O3 c( ^if (document.all)
: e* |/ u! z6 V. {# Y+ c4 ]supertext.style.visibility="hidden"
. L$ k8 A) I& t3 W5 f/ Telse if (document.layers)5 E, K0 n i# _& X. F. K1 I( S
document.supertext.visibility="hide"
, w0 j6 e7 D( F( V9 t( \0 f$ W5 QclearTimeout(animatetext)1 k1 h5 q$ i8 {& L# o/ G
}9 z% {* {6 _& ~9 j5 E. r
$ y4 B3 f; V& V2 j- bif (document.all||document.layers){
1 h1 ]% p' x D J$ R" qdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')' o9 p% P& Q! A( B+ I
window.onload = initializeBall;
0 |. r1 l/ ]5 P& I' o& w( V) [window.onresize = new Function("window.location.reload()");
5 }, o C% `. N; d}
4 u2 Z! ]0 U! V6 t6 O9 A
6 u1 _5 I5 ^# v! h! [: L, R</script> |
|