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

|
网页之不断弹射的文字-特效
<style type="text/css">
! [ P) ?" X7 t K& p" f#supertext {
7 B' j5 S5 G1 K3 e n! y# f" U& Q9 G# oposition:absolute;
) ^+ P5 z4 W2 x% Q I, Q% F; u' Kleft:0;4 ~. ? Q4 C3 V
top:0;5 q5 Y% r5 l* E% Q
visibility:hide;8 P; F3 ~: X) u8 E) A; i* b
visibility:hidden;( m' B T9 v4 H4 F
}7 h+ \( B+ d/ i2 h8 c$ W$ `# o
</style>
6 E7 c+ T" D5 H/ q# P. b9 r1 R<script language="JavaScript1.2">1 A+ n* X% I/ L6 g. K
<!-- 改变下的字体的大小。颜色-->
; v+ F3 i# r$ z! B2 x4 Bvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" M/ @" n. b8 q) ]2 ^$ Svar hidetimer='';2 v o( r; W8 @- c }6 R Y7 ~( H
<!-- 改变下的弹跳速度-->& L) ~; {* g: J& c/ H' z( Z
var BallSpeed = 20;
) {6 v6 R9 r# P7 W; {& k& Yvar contentWidth;
7 G- Z! |4 ~8 |: f- O( ^var contentHeight;
, _- e5 H5 _5 ^1 Xvar maxBallSpeed = 50;
8 _$ _% |3 ?/ Q% y, _7 i
9 p) Q- i6 m# G+ l) { s
p3 L& g3 Q. g. @5 W4 s5 A7 R3 Rvar xMax;7 r( b: e6 ~: A6 b, y: |0 C, n
var yMax;
$ C. x0 }' u0 r$ Bvar xPos = 0;
7 j: ]5 z' R+ e2 Avar yPos = 0;
. W) Z: r. p7 y# hvar xDir = 'right';
K. l- c' ]$ [2 L6 X/ X4 E$ Hvar yDir = 'down';; E3 n: [! T8 }
var superballRunning = true;, V# p. M3 H( i& `/ s( X3 v
var tempBallSpeed;6 z6 S p: M; S" |0 z. b$ S
var currentBallSrc;* O+ S, U8 ^- F) D
var newXDir;
& X6 M& M e( C- o; t6 x% z$ e8 |- \var newYDir;
- d9 \2 G: H8 T/ @# L& ]) w1 ~! L8 z3 G
function initializeBall() {1 V4 }" Z; R4 g3 J* O+ S* T
if (document.all) {3 V: V O; q# L
xMax = document.body.clientWidth
6 ~! U& `& R! Q& d- J yMax = document.body.clientHeight; W6 p5 r' m1 O( B% _- Q& D
document.all("supertext").style.visibility = "visible";; j+ {5 B/ J. e3 l: J+ s0 m) _
contentWidth=supertext.offsetWidth
" v) U2 ]6 a: f/ `* r contentHeight=supertext.offsetHeight
5 u: s# b( v7 W }
& d5 |+ M! p8 k) O. R0 f# O1 X else if (document.layers) {/ S: b, p3 [: H
xMax = window.innerWidth;. r# z4 u5 L$ `
yMax = window.innerHeight;
. w; K1 n5 y l2 _5 @ contentWidth=document.supertext.document.width$ z7 _* k% U; X! _7 e3 N" h5 m
contentHeight=document.supertext.document.height, Z0 o# O* j3 J8 P8 [
document.layers["supertext"].visibility = "show";
7 h- P( O r- x }
/ a& D Z$ |2 t1 N- U! u setTimeout('moveBall()',400);
2 R0 y+ g' @+ H) g% _( U5 x% L if (hidetimer!='')
9 h! o& X# X' X setTimeout("hidetext()",hidetimer)/ l) U( O* {" ~
}
! X& @& Y3 @+ f" x& N% v, A
2 W+ m8 X6 Z8 }% J O( ~function moveBall() {) `5 t) N% _' M# n. k
if (superballRunning == true) {! g3 O$ N) n; _4 p
calculatePosition();
" C0 y/ v! r. o2 S& t1 m6 P if (document.all) {
. T" Y: w( C, ?, o& s. s& `5 U document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 F8 Z' [! \% e4 e8 k& Y- p- P: i) J document.all("supertext").style.top = yPos + document.body.scrollTop;
7 K9 r- O2 s# n+ } }
7 ?" z. ]1 c, g else if (document.layers) {
) A/ G3 @7 q9 a/ z5 Y$ z document.layers["supertext"].left = xPos + pageXOffset;% r% u/ y b! V+ f# s6 P) v
document.layers["supertext"].top = yPos + pageYOffset;
9 u1 Z [$ W8 h, A$ U) a& a }
# b/ F) d5 N5 _/ G, {2 d) H8 ^ animatetext=setTimeout('moveBall()',20);
! ?0 O/ C' z7 N* [ }; X* Y9 j! v+ h
}
8 j7 X7 O& Q& U7 _
4 R' N9 f6 d6 Y! ~# dfunction calculatePosition() {% a; F5 _2 { Q# U) e
if (xDir == "right") {
& w5 X2 T- D& ^! l if (xPos > (xMax - contentWidth - BallSpeed)) {# G, v. S! L5 R
xDir = "left";
7 t2 D' |4 {; a, {4 c2 l6 x }
6 i) j+ \$ V; d8 S! x, J }1 G) a/ [) N" g; `8 U
else if (xDir == "left") {
$ S- D! f7 p# S! R R# r if (xPos < (0 + BallSpeed)) {% X3 W; y% y% T
xDir = "right";0 G- [6 O1 F8 [
}8 K0 F0 \7 a6 b3 s, ?$ F
}$ }$ Z8 x& n5 ]3 }: N7 V5 l
if (yDir == "down") {
# s2 m9 R& |: f if (yPos > (yMax - contentHeight - BallSpeed)) {/ w) I% v+ |" m
yDir = "up";
& w# t% A- {; V' z% l8 R! l2 \2 j3 e }% Q' w) j6 B" t, a) u. y
}" M& ~( U- w, v- p) A ?8 n
else if (yDir == "up") {
- X" @- t% m2 C1 H8 K if (yPos < (0 + BallSpeed)) {. {. _$ a. }3 _
yDir = "down";
$ M$ K* M3 D4 U% t' f }, C' ?4 O# l5 M
}
& d$ y$ u+ _! S& h7 m if (xDir == "right") { w+ N f! n; [% r) t w- W+ b
xPos = xPos + BallSpeed;
5 Q" k0 e" G+ q- o1 ^' Y1 _ }
' b( Z8 ?6 k& o else if (xDir == "left") {
1 a6 Y& A; b) Q" b xPos = xPos - BallSpeed;
, m7 H6 r0 j3 R) i c. n }
4 O4 L' u! i$ _# l else {# E) T' I+ v4 c/ O' S( M. Z
xPos = xPos;
9 B- f/ y$ Q3 j: @ }
# Y; i# w! ?7 x$ b if (yDir == "down") {
0 E$ H6 R, h* |# B5 q% r. R4 w yPos = yPos + BallSpeed;
8 L% [- _ u7 u3 S) W9 I$ } }* q+ H: i0 i8 K. a9 B7 J# T
else if (yDir == "up") {
% g0 }4 W7 X) B. o7 w' S yPos = yPos - BallSpeed;
7 S+ P( {( z$ I& w8 o1 z }
5 q. Q0 o* n/ p. _, J2 g else { Q4 z( H& l$ ]) r
yPos = yPos; D1 E# d$ i6 y0 I9 f. P
}% d5 |4 }! a! S- Q) i* u. ]$ m
}! d# x2 Q" Z8 h3 B! f
9 U6 W' Z/ w' ~) L8 vfunction hidetext(){
2 n }( k, _" i% }. B5 S5 y7 I2 @. ^4 Tif (document.all)3 R4 K( N7 z9 B" U) b
supertext.style.visibility="hidden". w2 |7 X& X1 h) {' v
else if (document.layers)
# e8 [: L! X/ `document.supertext.visibility="hide"9 c4 u+ k6 Y0 u
clearTimeout(animatetext)) ~0 r6 J5 f% L
}; u+ S$ C! f! g: G
@6 S6 l& j, w5 ~( Z+ vif (document.all||document.layers){$ S5 l1 ^7 n( v* X3 u
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')' P" p a- v: h
window.onload = initializeBall;6 r) j4 Z: `) e$ L' L# x) Z* w
window.onresize = new Function("window.location.reload()");3 H6 |* a$ d# y( |# N
}
, G7 Q( f2 P$ a
( k1 J9 [+ @& A8 I: O</script> |
|