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

|
网页之不断弹射的文字-特效
<style type="text/css">3 T4 s1 H8 E+ p/ S4 w' {
#supertext {" b3 w. J+ i, |8 e& Q" @3 j
position:absolute;
7 F5 i; ^+ L) k3 Z$ T: v8 I- pleft:0; @1 y8 O* B/ U2 n& f! R6 s
top:0;
* a* w6 H( Q1 K9 ` t. Vvisibility:hide;
- X+ T$ f& z( B9 `* @visibility:hidden;$ R" W- n( [4 J' g; n" m
}
9 r7 O( Y, e8 O# p# F</style>
7 R+ H9 B& X, B D( G<script language="JavaScript1.2">
0 N1 _! D8 u1 x4 r* |! r<!-- 改变下的字体的大小。颜色-->" n" g" I* u% h' z0 k' G
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
t8 R9 h9 o* n( }8 M( n3 M8 A4 U xvar hidetimer='';
* d6 ~* F/ p3 \$ t3 v<!-- 改变下的弹跳速度-->1 h- @ F; \, s3 O% O) h& G
var BallSpeed = 20;
5 y% ?. W# g# Y% `, fvar contentWidth;% `+ I! }. Q& Q8 I/ k
var contentHeight;
- ?0 H2 I# _6 r6 M' Q3 S9 yvar maxBallSpeed = 50;3 W; t, f7 i' C
( _9 w) A" v* e+ H7 s$ L3 X8 e( X$ N# k* Z) o
var xMax;
" ]3 Y) w$ M, h |% J) Qvar yMax;6 o4 @8 K) }+ s* q! o) k
var xPos = 0;
% h) z. {' ^7 Z4 \9 b( `2 ~var yPos = 0;
# X: f0 x( t& c; l# c8 O: q. Uvar xDir = 'right';
' U, D4 V$ |6 S: z# a' ?2 t: w$ U. nvar yDir = 'down';
. w3 }3 g- t: ^var superballRunning = true;
[% g8 ?+ a4 Uvar tempBallSpeed;
1 T0 F/ i( G/ U. P- w/ Kvar currentBallSrc;
" j) A8 B: g" p. ~( A9 Y: K* n Y+ zvar newXDir;
: S- K7 ]* N7 s# z! {var newYDir;, s& I+ j B* ]" F
6 f6 a* [. W( s6 N3 }) _4 ]
function initializeBall() {
& n% l, @ E, _7 m+ J1 R/ a1 E if (document.all) {
, b$ P; c: w# v: |+ [ xMax = document.body.clientWidth
7 a' q2 l/ f' B3 I. ~1 t yMax = document.body.clientHeight
0 V) h5 }& y' ] document.all("supertext").style.visibility = "visible";0 C0 r* L6 f1 n8 l, ?: T2 r1 a
contentWidth=supertext.offsetWidth
2 z: t8 O% w# Y5 Y- t contentHeight=supertext.offsetHeight8 ^1 o8 T7 c, D6 M* ~- o
} a' s& s) L2 j9 u
else if (document.layers) {
/ v4 `2 ]: E7 k Z" w xMax = window.innerWidth;( k) G: W$ e+ I1 I
yMax = window.innerHeight;1 T. \" W( I' s& e) T! M
contentWidth=document.supertext.document.width
! ^/ X+ G! e6 |, o! S contentHeight=document.supertext.document.height
* l8 u* D; o; \0 l: u! t; ~ document.layers["supertext"].visibility = "show";; E: T6 h7 b) w% w
}
$ @: _% N: f: {) q setTimeout('moveBall()',400);
* S# c5 S# Z s0 g+ S+ \- d if (hidetimer!='')
. q n0 ]5 l" B# G3 J z# s( M setTimeout("hidetext()",hidetimer)
' w& x1 q; }9 \" \$ m }5 w% O) k* G# r0 t
3 h" d" U' q5 Pfunction moveBall() {2 y' ?) a2 M* s. R
if (superballRunning == true) {
. x$ W& U% b( V7 s! j calculatePosition();
) X( A/ N4 G5 f! K# A3 o" n& g( { if (document.all) {
0 C+ Y$ F4 x. `; n1 j5 t, A document.all("supertext").style.left = xPos + document.body.scrollLeft;" u" j# x m1 V+ ]+ ]
document.all("supertext").style.top = yPos + document.body.scrollTop;
5 A4 ]' d2 D3 t6 X; w }
( {4 I2 f- g# s# {. O7 Y6 X else if (document.layers) {* x d0 ]6 V1 Q1 f& F6 P1 H9 d& E
document.layers["supertext"].left = xPos + pageXOffset;9 X* }- v5 D( o0 M- {4 o! A/ ^3 C
document.layers["supertext"].top = yPos + pageYOffset;
3 v! e9 b/ [, j+ H* `% {) D }3 q7 i' L( x' y5 W; h6 b( m
animatetext=setTimeout('moveBall()',20);& C |2 ~. d- f3 {' ?; a6 B
}
9 {& z3 {8 g, O9 D+ H }/ _: Q. f9 K5 K, f/ L/ H1 y. z
/ n1 y9 ~ N, ]& |* }
function calculatePosition() {
7 T* z ^1 r A- Z if (xDir == "right") {
9 \9 k9 K0 A b, Q0 Z) L; L8 l1 N if (xPos > (xMax - contentWidth - BallSpeed)) {
, K0 j' C9 c7 n& g' t4 K xDir = "left";; H* F S4 t. P. F0 S# I
}- I2 C8 L9 m' j
}
7 V, N, d$ h- l8 u' s8 G. G else if (xDir == "left") {" b& B9 m5 o. `1 j7 |, x
if (xPos < (0 + BallSpeed)) {
7 x; c( c$ {1 W/ E$ L0 [ xDir = "right";. m( R8 ^) Z. w; I
}; |+ J6 A( Y$ e
} N$ \; d9 t) S
if (yDir == "down") {
* x% H9 D! X0 q( ~$ P4 f if (yPos > (yMax - contentHeight - BallSpeed)) {# v" w8 [6 h. `8 W( x3 q8 l6 O6 ]
yDir = "up";5 u* u6 f% h2 I0 e3 ^
}
: h6 Y `! N% }9 ~. z } a1 U) |: J8 }% `( G
else if (yDir == "up") {% l' P# W0 J2 n: p2 e7 S8 S) W
if (yPos < (0 + BallSpeed)) {
2 A9 T+ Z& W. \0 h- m W! Z yDir = "down";+ X& M/ W# ?$ b# }. H
}
% [" P' y1 S$ F% {2 b, Z9 O, O/ z }% z0 q7 f! ^3 D7 q: t8 W9 E! y
if (xDir == "right") {
- U, Q) H, j- i6 d& A( b, l xPos = xPos + BallSpeed;
! {- n1 h j2 d) a }( I6 g/ ~+ v. I6 |3 N! i/ R
else if (xDir == "left") {
: m' W% V: @6 x n; R xPos = xPos - BallSpeed;& h/ ?8 e2 H9 C$ p6 z, i
}
0 {! o3 r+ _6 L' `8 Q; d2 N, V else {
4 E+ x; c( E: U. i- L+ e xPos = xPos;
$ J4 x' H: Q1 A }* Z0 G4 ^ n2 A3 ~5 M5 L
if (yDir == "down") {
% R% ?1 L- c2 a9 r1 w0 G8 h$ A yPos = yPos + BallSpeed;% b+ }4 ^9 \; T q7 h8 U* ?
}* c2 u3 s: j9 T$ }6 u5 e
else if (yDir == "up") {
; H) T* \9 Z3 V4 h9 s/ V( H yPos = yPos - BallSpeed;
4 |2 S( a) b; z/ C' Z# i4 t5 x9 k- K: v }
; y! P# v/ l. L7 }. I else {
b$ Y6 R, s7 G! ?# m2 w6 C% c yPos = yPos;
' C) [( S1 Y. J) i, R$ Z8 y }7 b2 ]9 @) P8 s' W6 O7 ?1 j# s7 n
}
, ]9 o! d5 g8 Z4 q. d( M, U0 ^$ ^# r2 Z. e2 C% F
function hidetext(){: h' P+ M1 G# A% a+ o
if (document.all)$ i/ r2 e# @( C% ]
supertext.style.visibility="hidden"1 Y- {4 T5 \3 p& W" |! z+ |( L3 s
else if (document.layers)
1 b) k, M4 b- @$ `document.supertext.visibility="hide"' R' \" O+ e8 i! Q
clearTimeout(animatetext)
9 `8 T/ `8 j! p. j4 l1 z}1 D4 Y- O+ M3 s
9 {+ Q$ C5 D% J" K8 f# ^ d$ E2 Aif (document.all||document.layers){
) Y; Q# @ E# a$ L0 m; T4 ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ B, E: }( i3 `7 D: A, e4 K
window.onload = initializeBall;
; w( G4 w5 M. A: z0 Kwindow.onresize = new Function("window.location.reload()");+ s$ o5 c6 R$ `4 B2 f3 Q
}
E5 W& S; U$ Q* y" q4 S+ F/ s% S: I, W: A* G+ E. h4 Q
</script> |
|