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

|
网页之不断弹射的文字-特效
<style type="text/css">
; c9 i0 G) h0 t; [+ q( l" g& x8 M#supertext {' m* g) O! B* N- R& w) }2 t' }4 k3 A
position:absolute;* i. t7 u! K$ I1 V3 |9 F5 d* t9 L
left:0;
7 }& M! V; e" _) V2 j- l) x" N) H4 X; gtop:0;
; m7 c, z! U6 M7 `8 ^visibility:hide;
% v, s" e+ P. N2 E4 Uvisibility:hidden;! E, |4 O- g1 _. i) e2 Y
}
+ V7 a7 j) b, w$ k- M</style>5 i2 R$ W v# D3 g1 ~$ z6 q- {
<script language="JavaScript1.2">) B! i' y2 n; A* c6 [' I
<!-- 改变下的字体的大小。颜色-->& S5 V7 g- B6 }2 l
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', I' Q. V2 V" |7 X+ p4 A4 ?
var hidetimer='';
4 k4 K+ D( S6 J: \: V6 k<!-- 改变下的弹跳速度-->+ z; o0 I$ X& w, I6 |7 z K
var BallSpeed = 20;! |" }8 ^0 z3 k9 W: r
var contentWidth;( k/ N' N* Y2 A f
var contentHeight;
& g8 m& P4 i( u" { tvar maxBallSpeed = 50;
7 ~3 ]' e+ L2 Z( Z- q' ~: b5 p& I' {# \0 ^- \/ c/ w& J
# {: }) w7 Q" q. X( a8 avar xMax;( x2 D$ q% ?+ q2 a8 H7 G
var yMax;
* e4 @1 o6 ]) r7 T( ]! lvar xPos = 0;
. s) A6 a+ n c. h' ?' C7 wvar yPos = 0;
0 ]/ o# N0 [7 mvar xDir = 'right';
2 ?) t/ m: x' `; Gvar yDir = 'down';0 ?1 T2 x: l q# z! r& P' R
var superballRunning = true;
0 l4 J$ P4 Q- p( y2 i. D6 Kvar tempBallSpeed;
$ u+ f" d) W1 ]4 j) Qvar currentBallSrc;
; a, {, |/ J* Z5 Qvar newXDir;4 o3 r8 M4 C( |7 E
var newYDir;
e+ t! f& T8 t
5 U5 P# G6 T0 _' h# S2 H2 Qfunction initializeBall() {
4 z4 H" B, W5 `8 A& m0 ` if (document.all) {
) {* D+ ]- V$ M0 [; x/ s/ S xMax = document.body.clientWidth
3 H+ S, E; u4 h3 e9 J& G9 V) t yMax = document.body.clientHeight; |; m' k: m2 z! H0 t$ v
document.all("supertext").style.visibility = "visible";
. p/ _1 A! v: D! e" P contentWidth=supertext.offsetWidth8 V8 L. R' Z \/ f
contentHeight=supertext.offsetHeight( B$ P) e8 D" v9 \% O; w
}! l, g& L. p1 Z0 r# w; r, x. j
else if (document.layers) { I* y. Y4 s- {, w' f4 M% A
xMax = window.innerWidth;; z2 s% Q' X, n! S& f( r
yMax = window.innerHeight;
0 ?; w/ c1 c8 m. H! X- W$ ]; [ contentWidth=document.supertext.document.width
7 [, d( @: @. F+ O* M' b contentHeight=document.supertext.document.height
8 s8 d( k& J: l: E document.layers["supertext"].visibility = "show";
) y- {; @& z# ]1 L% ]# U0 y }6 r2 C6 h5 ~ }. _1 x" M
setTimeout('moveBall()',400);
, e* @- P' o( R if (hidetimer!='')
# N, d; F# e/ f' y( d setTimeout("hidetext()",hidetimer)
' g. O# r# J' x- W4 N* c }
' |8 b/ c2 Q* `) I, s( `+ N0 t
1 O7 s8 d/ I. e, [' ~; Y, X0 L4 _/ Vfunction moveBall() {$ @$ j% ~$ y$ ^* z, {( D" }
if (superballRunning == true) {
- v: e+ [/ U# P' g calculatePosition();
- G8 M9 f. L4 l1 r if (document.all) {
+ l8 A" X' K' o) S7 S) d! D, U @ document.all("supertext").style.left = xPos + document.body.scrollLeft;5 _' W: c0 y/ m( V: }7 u$ K4 N9 y7 J h
document.all("supertext").style.top = yPos + document.body.scrollTop;0 F, g2 P$ d: A, X$ _$ _
}2 l {2 d1 u+ g+ C
else if (document.layers) {
1 p4 f" S! m' a, |9 y document.layers["supertext"].left = xPos + pageXOffset;0 L& h2 D; b) t9 d0 j M5 N4 J" B
document.layers["supertext"].top = yPos + pageYOffset;
2 c( Q* s7 l7 {' e' h }
! r# d& I6 N# ~6 ]" R7 e8 N animatetext=setTimeout('moveBall()',20);; f! F+ K* ?0 p$ d
}
4 E' r# J! e" ` }
: d6 h$ I% B9 o; I$ J+ w9 n' P9 N9 j( J7 r) P% ?
function calculatePosition() {8 d; r# l- F2 c ]2 k
if (xDir == "right") {
/ j0 P% }" g& ]- J- }8 W3 ]8 G, [ if (xPos > (xMax - contentWidth - BallSpeed)) {
1 h g0 q8 Y" }9 c& X. F( y: o xDir = "left";
- p: F4 r' G" \% J7 ?1 X; e }
$ l1 x3 r& w2 ]- E5 ^ }$ |( b- X+ ?1 r7 q( O. x) I
else if (xDir == "left") {
! q3 o3 f+ w4 z+ p- X if (xPos < (0 + BallSpeed)) {
& r& \' @, m1 o! r5 d% w1 C r xDir = "right";, X, p, o2 m" I1 q; O7 B0 r
}
7 G7 f! v4 e5 K: \# s$ [2 K4 w }
$ S0 c1 P3 E+ Z- m if (yDir == "down") {+ R) y' g g* T# q& o
if (yPos > (yMax - contentHeight - BallSpeed)) {
8 W% V5 z+ e$ Y1 T yDir = "up";; N& e2 ^5 p. w! i& j; {0 r5 K% q- x' k
}0 R. B1 |& i3 {
}
. E! Z k1 n; a5 p else if (yDir == "up") {
) t' ? Q% l' K; w% }5 m if (yPos < (0 + BallSpeed)) {
- o. ?3 g+ d) Z8 [7 R* e yDir = "down";
" k' Q" C5 w9 m" b V }
4 i; z( ^; A; C }0 F2 X# U/ D, C
if (xDir == "right") { \2 w% ]- \! M! y) j: [
xPos = xPos + BallSpeed;: t4 N- G7 M. J ^! u
}+ R" W: ^, g# E" u. ]& x
else if (xDir == "left") {- c6 Q t! Q V! H4 ]/ {2 B. a' D
xPos = xPos - BallSpeed;+ c1 @: G- D6 W. s9 a' d6 ?/ K y, v
}: O, [" \ O: l' o7 v- a
else {: [( J& Q+ f. O9 E5 c+ ]; {, P
xPos = xPos;
6 A; j& P1 N3 v( o! i4 A: S }8 @5 h4 e# F7 U+ m6 O
if (yDir == "down") {) g) m" Q3 y/ z3 {, v' E
yPos = yPos + BallSpeed;2 s0 r2 \7 u" b, W$ ^6 o, r
}
/ P; G# A: ^0 |7 | else if (yDir == "up") {
( I. x6 \) o. j) j2 ] yPos = yPos - BallSpeed;$ u: p' I# c* `1 a4 g
}& H" R- p. y: n1 o! @% c
else {' G# I# G8 t+ \' k) W" a
yPos = yPos;: T. n& I, v$ T" P; @- E1 z
}
4 ?" ?' ?6 }5 o& H0 B7 V: g& s$ ` }
4 I7 d8 J: H. B0 C d0 u6 A* G u" }, G, S8 y% I& k
function hidetext(){
1 D6 [% }% d' Z2 Aif (document.all)
; M x5 l1 l9 Q1 a1 Tsupertext.style.visibility="hidden": y0 o( v' G2 \( T
else if (document.layers)% J1 _$ r z- X! X
document.supertext.visibility="hide"; B5 g, K R0 R3 P7 _; e- c' M
clearTimeout(animatetext)) B( C/ F. R7 T+ C" b) v: \
}0 r5 T) z& B0 M2 S# `
6 z4 A, T/ G8 X6 Y# H6 D5 Q, c, e2 y
if (document.all||document.layers){# \* G( L) j6 a+ O, C2 c9 k
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; N: K. t* C3 i2 U& ]& owindow.onload = initializeBall;8 \# s& _3 O1 R) ]5 H, n2 O$ `
window.onresize = new Function("window.location.reload()");6 }; O" L$ s& K# n4 H# B- z! l
}
5 J$ ~; i3 _2 M- \5 R+ P' x3 t; h, j! t) ? |* c% [' ^
</script> |
|