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

|
网页之不断弹射的文字-特效
<style type="text/css">& @! N2 }$ [# ]" a! T: V# G
#supertext {
$ }0 Q. a1 B8 Z7 |/ _+ Q% J3 fposition:absolute;
0 o- P y) W$ P" U# qleft:0;- e5 W8 x( E- C& j3 f) ~* a/ u
top:0;
' c' z. _; y& `visibility:hide;
! J" [' l s- T1 Z$ y9 o8 {visibility:hidden;% {/ B G. Y2 @* B7 H6 k
}9 w4 |4 _ \+ @3 D% {
</style>
! L# V7 D: X; t6 z+ u<script language="JavaScript1.2">
9 A+ d# c* {) e- [<!-- 改变下的字体的大小。颜色-->( n5 N8 o- y* S. {
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': C' W8 o8 }4 E) T! a
var hidetimer='';' X7 G2 ] Q( w, b/ R
<!-- 改变下的弹跳速度-->1 d* j1 @( v8 [) n1 l; i
var BallSpeed = 20;
0 H1 a+ b5 }4 Cvar contentWidth;1 }* ^( {. q- s$ `
var contentHeight;
8 t- _5 w* G5 nvar maxBallSpeed = 50;
3 h$ [0 }4 l3 b% Y! Y6 e! j7 G% X5 v+ [# j6 l& a* ^- z
* |0 R8 q0 Z6 O3 E( U( y/ E9 Nvar xMax;, y a7 a6 F9 M/ x) @
var yMax;8 n2 p# u& m& v/ @
var xPos = 0;: ]+ U& \! _, @. Z3 ]) W% L8 N
var yPos = 0;
, y: R; D, B, d6 Hvar xDir = 'right';
- G& K6 N& a" Mvar yDir = 'down';1 W7 h1 x; j' \2 @7 B
var superballRunning = true;
9 p$ ~: e `# X0 y& S% ?- Gvar tempBallSpeed;9 j; c% q8 m. J) E" V! j
var currentBallSrc;2 G. v+ I; [2 J, A
var newXDir;
- d5 g" h: X, F7 a f$ L! Svar newYDir;) d7 R5 G4 a' r! L' M
/ Y6 E- N$ ^( f/ [, [- }function initializeBall() {) [) a, \1 J& c0 O+ G2 g5 g# K
if (document.all) {* x' {" Z1 V' `- s$ C' x5 {( ~
xMax = document.body.clientWidth
( H6 ^4 \: J8 d# f& T3 f7 I, ? v& Z( N yMax = document.body.clientHeight# w) n5 ~) c" ]4 P' @
document.all("supertext").style.visibility = "visible";' i0 \$ J" r4 ]5 ]5 C5 ?4 Z
contentWidth=supertext.offsetWidth
% F n, x; q4 X5 }3 g contentHeight=supertext.offsetHeight
~/ }4 e _( }0 a }
9 `3 s5 x g3 \8 A) _( R- s; H else if (document.layers) {
" C- |2 M" e% h3 w( i- W) l: z9 d xMax = window.innerWidth;
$ J1 H+ n2 c4 F- X yMax = window.innerHeight;( d: Z$ |0 c% Y" O) |
contentWidth=document.supertext.document.width
. ]' B, ^ s6 I5 O0 N- i+ w contentHeight=document.supertext.document.height
" K# Q6 ]5 x0 k; V) Z document.layers["supertext"].visibility = "show";% d' U, s# v8 d; t3 }$ L3 S
}
: w. v4 D7 j' x7 T9 \% C9 T setTimeout('moveBall()',400);% T' E5 F5 S; {3 y! `
if (hidetimer!='')
4 p( k4 [, V7 N setTimeout("hidetext()",hidetimer)* ?" \/ S" ?9 F- J8 {
}5 x9 u9 q& Y% ~% }
8 f( S) ?2 i$ z; m' f6 f
function moveBall() {
) u6 x; o5 v V if (superballRunning == true) {9 y$ P# S2 y# }* m# x& g8 U
calculatePosition();( W8 Z& A( Z3 H5 b- ^. e4 R
if (document.all) {# C0 U6 d6 Z. V, G; |8 @
document.all("supertext").style.left = xPos + document.body.scrollLeft;
( q# c/ |& B% X9 u* v# Y document.all("supertext").style.top = yPos + document.body.scrollTop;# R; F* ]& l* M- j
}/ d' ~% j/ H0 Y4 X% K% q
else if (document.layers) {
! Y6 T$ _9 e+ q7 a7 _8 k0 y k6 J7 v document.layers["supertext"].left = xPos + pageXOffset;
6 R: J5 M& a0 d! S- @6 W! i' |+ I document.layers["supertext"].top = yPos + pageYOffset;
: D l( L& L( @1 o# f( H- ? }& N3 f, @ F, {+ ]0 @7 \! y2 V# h* _
animatetext=setTimeout('moveBall()',20);) i; d4 }) \ T9 x0 M, N; D6 d3 G
}
7 I) T. t" w- s7 |7 f, r; N% J J }) t9 R8 n7 c D0 q5 Q* _
& c" J+ n' d( s/ D5 r7 X0 xfunction calculatePosition() {
: Y, _% T& O; i' o! ~ if (xDir == "right") {% @0 A- J$ E2 m
if (xPos > (xMax - contentWidth - BallSpeed)) {# _: N8 H/ ]+ P# E# L! c# n
xDir = "left";( P# ` A6 J) r
}
( @4 i& K+ s) c o4 [4 M# Y- J }
$ E$ R9 M% g$ l& S3 N g/ ~" k else if (xDir == "left") {+ E' \! N a( c2 P
if (xPos < (0 + BallSpeed)) {
: g% i4 ]7 `5 M) W/ \1 l6 [ xDir = "right";
! H% y8 i! k2 v- X0 a# k }
6 \4 B3 I* A7 p+ S# \2 U- O+ o/ Z }" w' w5 r5 s# E& |& l) }
if (yDir == "down") {
2 x8 y v2 h: [3 F6 V7 ` if (yPos > (yMax - contentHeight - BallSpeed)) {7 z8 u5 D% h0 T: a
yDir = "up";
! g) w K8 j5 d$ O% D/ t# {8 ?+ h4 Q1 V8 u }
9 E, S' K- ^ ?6 p& h }. z- }; i" d% `+ ~
else if (yDir == "up") {3 i+ h! e9 W' N9 Z" K
if (yPos < (0 + BallSpeed)) {" ~; Y5 s# u$ c, L( A) R
yDir = "down";
: f7 U" `: w8 | h) C }
4 e* ?' k5 J% I' @! y, o; p+ I9 | }& }- s) w1 A I0 o* @. q5 _- E
if (xDir == "right") {& u. T/ E& Y o1 F0 v7 S, ~
xPos = xPos + BallSpeed;
, }/ z2 \/ V, x7 ]1 @ }7 h$ H# [# `: t X3 B+ G0 M3 X5 f
else if (xDir == "left") {
( {0 J5 H( q/ t {3 q } xPos = xPos - BallSpeed;
, l; K: U5 j- A; S }
* X5 ]' }3 i0 E2 c else {
/ I( S& S$ t3 Y% ^, V+ a xPos = xPos;
6 |; m$ D2 p- f" R }
2 F% M% ~% Y$ ?" }8 H if (yDir == "down") {' ?% f% r8 q: x. c- V
yPos = yPos + BallSpeed;
" \+ e4 C& {: E* |7 u) F }
8 A$ t) O5 n( S* A+ I2 Q! F) [+ f) } else if (yDir == "up") {* L& R; g: X5 x
yPos = yPos - BallSpeed;
9 |7 [( s7 W- L( W }# M" V# y* G" i* y1 N i- l
else {/ s# F: ]. Z6 t) p V( i& `
yPos = yPos;- g" y; M- V* A3 Z* B
}
4 d1 W* G( [+ T' F, ^! p- N) I }, ?3 t8 D! q+ o! C3 n" t
- }7 E* {' h( Q: c9 n+ V
function hidetext(){
4 q+ W$ z- @* l, Jif (document.all), r+ v) @# l" [) i
supertext.style.visibility="hidden"
' t3 t0 V1 C/ B& `1 ^5 t+ A" ^else if (document.layers)* n3 D+ M" K5 U2 V6 ~. }9 q3 k
document.supertext.visibility="hide"
7 M m( z) {8 l3 g! ^4 QclearTimeout(animatetext)
* T7 W7 H. M/ h2 B# K; K}* v( X; {, f! T6 G3 i4 ?
6 I5 ?9 g/ `+ f! Gif (document.all||document.layers){
: Q6 R L6 Q! ]& ~document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% j7 g2 j) o1 H7 w4 x- e% M, |* mwindow.onload = initializeBall;
0 h Q. {) n# i$ W; h4 J- X3 Lwindow.onresize = new Function("window.location.reload()");
- V2 v' c6 y) Z3 W ^/ J4 O0 o}, p6 t$ g+ F" d2 A, _/ | ~
8 I" V2 c. }. N; _6 Q8 ]8 [, X) |
</script> |
|