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

|
网页之不断弹射的文字-特效
<style type="text/css">+ x) D) s& R5 Y7 [- E+ K6 d
#supertext {
7 N+ \4 |( S9 V( D4 A% w/ f/ Rposition:absolute;7 }0 h; e2 ~3 E& P+ @4 U
left:0;
! ~1 w$ |' q, ?top:0;
. S9 i+ |/ ]$ }( E- O. z# I; P5 Kvisibility:hide;
: j5 i4 X, U9 ]0 T& @+ |4 O/ ] | Yvisibility:hidden;
8 I7 R9 B. Q- H3 Q: z A9 t}
2 |" b$ V7 r2 o6 W, ]5 c</style>. U3 I4 V, S7 @/ j0 e5 M
<script language="JavaScript1.2"> ]$ K0 G& D5 V) t# ?
<!-- 改变下的字体的大小。颜色-->7 B5 D g* I+ Q) G) }
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
- i; Z: g5 ^ a; [var hidetimer='';
/ B w. a- @( A% W<!-- 改变下的弹跳速度-->7 j* C5 ]6 `1 n3 h2 N! J$ P5 y- K
var BallSpeed = 20;) ], t6 g; C5 q5 U
var contentWidth;/ H0 P; ? X @# P
var contentHeight;( w" Y' F/ E. S7 X( @, X1 @% D
var maxBallSpeed = 50;1 L% a, k& {9 U- Q
) q9 g1 L$ }1 w! \8 P9 D7 |5 j
) i/ v. E4 g; x( x8 Q4 c m& Gvar xMax;, D7 `0 [1 G' a9 k
var yMax;! \" g; t1 ?1 N: O: z% ~' f
var xPos = 0;8 B+ x# l8 c- A7 `
var yPos = 0;; k+ G: Y4 p' T8 y( k2 ~# N
var xDir = 'right';
7 _; }& c5 X/ B, E+ \, Evar yDir = 'down';
5 P* i7 J! K7 Y) Hvar superballRunning = true;
~+ o) |* b) L. D4 H4 @var tempBallSpeed;
& [8 Z' J' y$ }. d, O% Zvar currentBallSrc;
( x+ ~7 w! }& N6 |var newXDir;
9 o. P7 Y6 v! R* n- T" ~. k/ ?var newYDir;
) P) I9 t3 a, q1 l, ^: C G; c( t0 J% f8 U- F: O% k+ e
function initializeBall() {' B2 S. H, v5 a& R8 i
if (document.all) {
) V' @' d* @( C- J. u xMax = document.body.clientWidth
/ m: z$ h! l4 k! w4 E6 [( A1 e yMax = document.body.clientHeight4 B' e6 E9 V0 v+ q$ u7 B) t$ \& \$ T
document.all("supertext").style.visibility = "visible";; _$ Z0 h* x8 I
contentWidth=supertext.offsetWidth; _9 i* F8 B2 V# d& h" d
contentHeight=supertext.offsetHeight
5 A3 v {0 n$ S4 U }% T( p) P1 ^& j' y7 v
else if (document.layers) {
9 {' G/ _/ X6 U" O) K xMax = window.innerWidth;
0 E" P9 b0 S3 h9 \# p yMax = window.innerHeight;
5 W, h9 l' _2 g6 ~. m/ Y/ m contentWidth=document.supertext.document.width
. Q' n$ U( V3 L" k2 c# L" d contentHeight=document.supertext.document.height
6 n4 p3 i- Y7 E$ \1 k* x( R document.layers["supertext"].visibility = "show";
, R5 J8 z! T# |3 K }% P- X7 j7 f+ u' c b$ |$ Q
setTimeout('moveBall()',400);
$ w, Q1 h% \2 g: F if (hidetimer!='')4 B; z+ o: M- V4 [/ a6 n
setTimeout("hidetext()",hidetimer)( _" {* Q9 p2 i3 f: T" \
}
0 C" {" b2 }! ^& T3 g
, E' @1 G& y: Rfunction moveBall() { k D' H. m/ C& V8 H6 ]
if (superballRunning == true) {
& ^0 g# M: `3 \9 W calculatePosition();
* M& J0 \2 O" [5 a/ n if (document.all) {& y' X( J \" N- ]' m1 x
document.all("supertext").style.left = xPos + document.body.scrollLeft;- F2 t, {+ e x, r7 _: b8 [) X9 ]2 ^
document.all("supertext").style.top = yPos + document.body.scrollTop;) [' I8 E- Q- `; T
}
: }2 n* t( A* T5 O4 Y* _0 u# v else if (document.layers) {
& j* u4 U* Q4 ^' f& s! X$ x1 T0 e document.layers["supertext"].left = xPos + pageXOffset;
4 C) u+ {( F( i. {- J! x5 u document.layers["supertext"].top = yPos + pageYOffset;$ ]- I0 h' @/ m- @7 R2 q
}8 o- l. f/ J# ]1 N% N; k
animatetext=setTimeout('moveBall()',20);% S/ B1 E+ | J# k/ `1 {7 K" S
}
- A6 G& n" p, t b# I5 H2 `5 w }
3 l; z7 h6 O( p
H6 r, s, o0 B% r9 t* h* m) Rfunction calculatePosition() {7 [8 d1 t3 L. _0 y6 R
if (xDir == "right") {
- O3 O: q' l$ d' |2 H# b if (xPos > (xMax - contentWidth - BallSpeed)) {
; d3 w1 [- V& ]6 ~, u M d xDir = "left";
, P! h- L0 m$ j9 t3 |7 i) ?7 G. M }
+ Z- n8 K# l% K* [7 X }
6 R! K& M3 c: K L else if (xDir == "left") {( k8 c% ?1 A4 N: S
if (xPos < (0 + BallSpeed)) {' b6 I1 J6 u/ D# b3 N9 F$ }
xDir = "right";
8 f" t4 {$ I4 F! S4 s }, E! `7 |, ]9 o5 O2 |9 ?
}0 D7 q$ a; `& x- ]" ]3 l! f* O
if (yDir == "down") {
( l" |/ F+ x8 `& Y, ^5 Z" N/ D if (yPos > (yMax - contentHeight - BallSpeed)) {
: q% x0 f. Z& e) W9 ?. n yDir = "up"; [: B& r J& T! B
}
6 I7 R& z7 {* m$ N }9 n; V9 n1 W% p' x
else if (yDir == "up") {1 D9 y2 l7 J. ]2 p
if (yPos < (0 + BallSpeed)) {
9 m7 v8 `$ j: d& S yDir = "down";, X1 d# t/ Y: C/ V6 e
}
& \$ G: ~. L9 @( k' \ x }* D; k9 z( D( P1 b" W7 `
if (xDir == "right") {
) n0 L8 ?6 f# P; B xPos = xPos + BallSpeed;
. J$ T' k; r- h1 E% d6 } }
- Y# H' n- h9 c5 L Z2 i. V( G else if (xDir == "left") {+ ^7 L, |6 P( Q, y
xPos = xPos - BallSpeed;& `0 a8 L' }' W* O
}
/ T: f+ A; F& D) S2 I# {! X5 \ else {
% I. y" e; I) v- t xPos = xPos;
4 X, ^2 ]0 P. N# @, @( g2 ] }
4 U9 o( J1 B8 ^4 e if (yDir == "down") {
' q- R2 ^' G" k1 y& H& P yPos = yPos + BallSpeed;
( d* k5 d9 p1 I* Z# t8 ]" e }- w' N% z" c9 ?0 a
else if (yDir == "up") {7 P- }- a8 i- r; T
yPos = yPos - BallSpeed;
) @! A8 k3 y* X }
7 m0 T6 ] d3 _% s2 j j7 O8 b else {4 ~6 `; V$ y" @* Y. S/ Z5 z
yPos = yPos;
@ Z% U0 |" {% V6 O }& Q2 i, @' U6 q
}. h, F L! O8 _( ?1 D
, X. J6 `: G/ E w/ J6 a* ~
function hidetext(){
/ h0 A& Y; g& l) jif (document.all)
8 X# H* L0 b3 _" |4 Tsupertext.style.visibility="hidden"
, E# ]! A9 F' o; z0 i: _else if (document.layers)
3 Q/ l$ X: w- v( m: kdocument.supertext.visibility="hide"
5 S/ o3 i& R$ @% [6 }clearTimeout(animatetext)
2 S& B' D {) H. G6 v* A}
- k1 A% R( g, B& `, S# w! N9 s- ]
7 ~5 J' c* [, a2 pif (document.all||document.layers){2 n$ o3 o) F+ i0 T# u
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 e# f9 ]: b& e& @- H9 H' hwindow.onload = initializeBall;/ }" W# ?# p1 h% O3 |. o
window.onresize = new Function("window.location.reload()");
3 }6 m- a0 T4 k( j$ ~1 b}
7 ?$ U. j8 ]: t6 G5 o, `3 \* n5 K/ L1 m6 F; v
</script> |
|