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

|
网页之不断弹射的文字-特效
<style type="text/css">
" j! D! p1 v- L ^& H6 E* @#supertext {2 S0 Z9 s* T, N' T
position:absolute;
2 }+ W1 Z2 G; ]7 \4 K' k/ X3 Bleft:0;" b& \5 Z; [- A) B- i7 D
top:0;
0 C% F# \' c8 z; f6 i1 r& ]2 g' j; }visibility:hide;3 I. w' Z4 e9 ?- w# X
visibility:hidden;
: E I& ^3 e* }5 W9 k5 M+ H}
, `! T7 R0 ~: y7 j, Y; i) s</style> v8 E7 O7 d5 v8 |2 g
<script language="JavaScript1.2">% @8 q7 j) X x7 W2 @
<!-- 改变下的字体的大小。颜色-->1 S5 T; u# @# _$ g F. G+ L' H3 }4 u
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 w* E1 R! z+ s- G, ?+ l
var hidetimer='';
/ P1 L" Q, ^ K( t7 D d" U# c<!-- 改变下的弹跳速度-->( C/ R& G" ^% O k4 l s
var BallSpeed = 20;, |2 B V7 E q2 |2 d1 p7 E1 u" z
var contentWidth;
" X/ L" ]/ S! q/ \$ }7 dvar contentHeight;
9 j+ T3 E5 _9 l$ u: ovar maxBallSpeed = 50;
# l# ~3 L/ N- g: M8 i# ]6 I* S, {/ e9 b# ^* ?7 [$ L
+ F! z" p. \1 F( n
var xMax;
" z, m4 t6 [6 O/ t1 w9 b0 I' w# Q) lvar yMax;
; _- e! _# s; A; s' v6 k" |% avar xPos = 0;
% t) t5 ]6 _; g* E6 l' n3 P& Xvar yPos = 0;% _, A3 }. Q& H0 T0 |8 g( x
var xDir = 'right';4 h @3 B+ q2 v6 N3 d
var yDir = 'down';( p: i# \ j9 ?8 a& }
var superballRunning = true;: k; `( c1 {) G; {
var tempBallSpeed;$ o- J# u$ i: m! z$ t
var currentBallSrc;. i% p& R n$ U; N% @* I+ Q
var newXDir;; v; h' @$ q8 ~+ o) z7 N9 k6 J7 A+ n
var newYDir;/ x- G; J; U0 t/ C' S. W
+ U8 m. b4 c$ o1 y5 C1 {function initializeBall() {
/ E; ^( K4 m) \' F9 o if (document.all) {
$ ]7 A3 w4 I+ ?7 b) ~ xMax = document.body.clientWidth3 {& P/ S; L1 _9 w
yMax = document.body.clientHeight
* {# V+ X" K& t4 d document.all("supertext").style.visibility = "visible";' z* S* V6 T, }. Q; ~8 @4 t8 o
contentWidth=supertext.offsetWidth
& b$ \1 u+ g% p) S/ {( |: a) g3 q contentHeight=supertext.offsetHeight1 e9 x) \* f9 U# y) g
}
3 x: J! B! |1 H/ E4 ] else if (document.layers) {
5 t0 y6 z" C- u* c/ n xMax = window.innerWidth;4 b% h; { |4 o! q; p
yMax = window.innerHeight;
: d' J0 i7 [, M contentWidth=document.supertext.document.width
! U1 p/ E6 }: z" @+ h# l. U contentHeight=document.supertext.document.height9 S' V, G4 ^6 \
document.layers["supertext"].visibility = "show";
+ o; \! h, w0 L B6 W }1 E+ v. E: U: Q: i( S
setTimeout('moveBall()',400);* n+ O! _( W- X+ a% ~' @" m
if (hidetimer!='')
) b; e; F: U. F" P5 J setTimeout("hidetext()",hidetimer)% ?; w/ s+ R5 N) Z& N" D* c2 D1 D
}3 H! U- P5 \" x- ^7 R3 A
# b: i* R W: r+ ?3 A
function moveBall() {' f, @( _8 ?- x; T6 `
if (superballRunning == true) {
: v6 A: A9 R* v$ o calculatePosition();# S% j$ d; c9 u* ^1 ~
if (document.all) {
+ X; O, M: U! t) R% G. L& r document.all("supertext").style.left = xPos + document.body.scrollLeft;3 O3 ^- K+ g& J$ S K7 s
document.all("supertext").style.top = yPos + document.body.scrollTop;
5 b9 x6 ?7 `2 F% O }
J ]+ D: r8 i n* O$ ]( w else if (document.layers) {& r' R0 w9 a6 Y; v
document.layers["supertext"].left = xPos + pageXOffset;
$ @; j, |. E7 w: |6 D T- [# ]( Q document.layers["supertext"].top = yPos + pageYOffset;5 p% g( o- L( A
}
; d! _1 s. b4 V& u- m# W& H animatetext=setTimeout('moveBall()',20);
9 U$ v' t+ L# q$ [2 T- e }
2 x) P' x. ?: k O/ b- s }
8 _8 R% z3 f4 C( Q
+ d3 x) {* C, ]' bfunction calculatePosition() {# h0 b8 @' T4 G/ b" l( a
if (xDir == "right") {
3 d1 N1 d# S: A9 a5 y) q7 w: b if (xPos > (xMax - contentWidth - BallSpeed)) {, x/ M# {# D" P$ l
xDir = "left";
6 F$ _# B4 [# V# q, ? }0 n0 \; D' K2 H1 G
}
3 j1 C# [% i, ~% l+ y7 y' v) Y else if (xDir == "left") {- m! x: g) ?: f7 ^ o1 X! q
if (xPos < (0 + BallSpeed)) {) ^+ z- }" U* o8 T5 ?
xDir = "right";0 p' [: |8 G' q# j M& c, ?7 G
}
& j$ c* M. X7 C! B# @* h2 T5 ]* r }
9 X& x C0 X x* M4 c3 ? if (yDir == "down") {6 D9 V" x7 S8 G! O f& i- I
if (yPos > (yMax - contentHeight - BallSpeed)) {
q4 \5 b# R4 m0 f, ?' @2 A yDir = "up";1 @+ h: y6 J( `
}" o1 x9 R9 ~; x3 }. d
}! a, @$ W- ]; }% s! f: O
else if (yDir == "up") {
& s! i+ Z+ d8 \) q if (yPos < (0 + BallSpeed)) {
# ]8 y6 J( U" R% K J' n yDir = "down";
0 E; U+ a$ Y- N3 u7 @ }) n; \9 h5 ^" Q) O
}
) y! B) b5 V: D+ a: |" f if (xDir == "right") {& r, i& n- ` V
xPos = xPos + BallSpeed;
/ E1 a" \. @/ u9 w0 p: F( f& W }+ v1 \. a8 b1 X
else if (xDir == "left") {$ L( O1 u Z5 p( F
xPos = xPos - BallSpeed;
3 m2 `5 c4 T$ v& [' R }: ?+ K( ^, r# b8 k
else {+ u; m3 ~0 k( @
xPos = xPos;2 D4 n$ `) z5 }. Q% @/ f
}
# C# p) \) \ k' W if (yDir == "down") {
6 F7 f' ~: G: E/ r# g3 N* G yPos = yPos + BallSpeed;
8 n" t; ]% K* a# a }# S( n5 m5 `1 I2 p3 W! x( S
else if (yDir == "up") {6 A n% z. t0 {- N( U0 \
yPos = yPos - BallSpeed;
6 t3 Y+ S3 F- F* K F) | }8 b! a! r6 Y. U! n( J6 k
else {
5 K9 S3 S: o" i- Z6 E/ F5 Y) L yPos = yPos;
2 F( r4 U6 a8 ~! x4 Z }
- R" J' Z+ w1 t* j0 {7 L }
* z% `/ b4 ?: K5 c' D5 _
5 k1 N- e8 t1 u; v5 o _8 _5 _function hidetext(){6 W r2 f7 ? j0 e
if (document.all)4 d9 D5 B; y# q2 s
supertext.style.visibility="hidden"/ q6 A# t# B& Q( W: w
else if (document.layers)
) f2 u7 b; y: t" {+ _document.supertext.visibility="hide"# ] J5 E3 @% M
clearTimeout(animatetext)! ]" q. M( p) y) u1 p) Z) W1 r( F
}
+ [# \; t0 z% u/ I2 Q8 L% @0 `4 V$ c# R% k& b1 b
if (document.all||document.layers){6 s4 M+ X$ b# W4 ]" \# |4 W
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
- F$ T" Z+ n, `; n2 u& p6 bwindow.onload = initializeBall;
@2 F/ t& c! g* s) e0 a. xwindow.onresize = new Function("window.location.reload()");8 ~6 H0 R6 a2 e# L
}8 C) ]# Z* `; b4 M: Z K
- p) U! M" Y6 M+ k8 T
</script> |
|