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

|
网页之不断弹射的文字-特效
<style type="text/css">
# E1 V) R4 C) U* n2 D: G$ K# E#supertext {3 M0 p" X: v1 P# m8 G" G2 q7 [
position:absolute;) V. D; B0 l8 n: d# ^
left:0;
1 i' M, a O# s' |3 |+ I" k9 I6 [top:0;" b o/ g; [; k1 f, j
visibility:hide;1 ?5 Y# r( d: O, |3 N% e# `0 F
visibility:hidden;
1 m& e, k: ]3 A2 e$ l. k \}
6 T3 R" ~: b' k8 K1 @/ @</style>! G2 e4 x4 t, C4 M( f$ [- }" k& p g
<script language="JavaScript1.2">
% H& d; j9 [& M% e<!-- 改变下的字体的大小。颜色-->( Y- [* B0 ~/ I; ?2 e
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
8 _$ K$ F: T2 T9 C! o2 D' p: zvar hidetimer='';
" \! x" T+ Z( u5 X! w' {* }<!-- 改变下的弹跳速度-->
) _( u4 I! S# ^6 K7 w# tvar BallSpeed = 20;# F; ?9 S7 o9 i; N+ Z
var contentWidth;
7 m8 Q U/ [8 t; Z0 Hvar contentHeight;! I/ o& y$ c8 I: Z6 Q
var maxBallSpeed = 50;$ H0 _! M7 G4 `% P Y+ _
) X) N7 I7 e0 f6 Y% a
1 e2 H& ~4 o! H! p, d# \ ?var xMax;
" P5 R& @8 L9 N% v6 svar yMax;1 V; T/ x# Q& I2 f$ x9 ?
var xPos = 0;
% f& ^- z. H) `var yPos = 0;. ]3 O; ^) `! ~" M9 C
var xDir = 'right';
5 ~5 [) E) D6 K$ x8 s/ ?var yDir = 'down';! |$ \ G+ w) W( j+ U1 E
var superballRunning = true;- f- F+ @# B% N' Q0 |: G
var tempBallSpeed;
# Y- s$ ~* M+ n( x2 Yvar currentBallSrc;
( B: b+ E' W' H7 fvar newXDir;
c' n/ T3 G* U; ovar newYDir;7 p4 ]: T$ Z2 U$ ~+ e% s* |* \2 b
, k3 l' r( J( P: H4 V# ]
function initializeBall() {
7 u C3 }* y5 k! p& N if (document.all) { P0 W6 T0 ?, Y' d
xMax = document.body.clientWidth ]2 Y6 f3 W; `" O, H2 q
yMax = document.body.clientHeight) \8 A1 ?. I. y9 u7 v, `! Q
document.all("supertext").style.visibility = "visible";
- b* _! ^/ m; ^5 o g7 F' L contentWidth=supertext.offsetWidth
' Q, L/ `1 X- G6 | contentHeight=supertext.offsetHeight/ K& u e6 a1 H: @8 ^
}- W9 T- m/ E. H5 W8 e
else if (document.layers) {
2 D' g5 C5 n* u1 u, z6 K xMax = window.innerWidth;
8 V7 }, L |' r; x; ~) B yMax = window.innerHeight;
0 n0 D5 X N0 p5 Z6 P contentWidth=document.supertext.document.width
2 D2 S1 L; j2 R8 j6 E8 ` s0 | contentHeight=document.supertext.document.height
, d) |: r) {8 e+ N document.layers["supertext"].visibility = "show";* f. D0 r* |. x4 t- J
}
2 n% V; h* j1 j setTimeout('moveBall()',400);
& t+ y, @! n& o8 _" Q W/ X if (hidetimer!='')
0 L6 e5 _. _5 A O4 h4 ` setTimeout("hidetext()",hidetimer)0 T m R! w( \( j
}3 T# l+ o0 H. A! B6 T: ^
) O, ~1 @4 j. }" K1 A* w8 Cfunction moveBall() {2 a! r* Q. m8 y* W2 _: r+ m
if (superballRunning == true) {. c( ]$ c& l0 @; T7 u
calculatePosition();( E+ H. q5 _2 }0 Q: I+ D
if (document.all) {
! `1 I! [5 W7 _' T3 G8 F% F document.all("supertext").style.left = xPos + document.body.scrollLeft;
& S+ @( O* s& Z$ g document.all("supertext").style.top = yPos + document.body.scrollTop;( f& z+ _5 p& Q; H
}
4 t6 q+ c4 G5 y# q5 E7 E/ x1 p else if (document.layers) {) `# S5 T V( g
document.layers["supertext"].left = xPos + pageXOffset;
1 R# n* ?; H4 b- E) ]( W) Q! h document.layers["supertext"].top = yPos + pageYOffset;, D2 m! Y) R/ K: M' I( q$ d
}
3 @7 g" k/ a; n& ^. _0 f: Q animatetext=setTimeout('moveBall()',20);3 p3 L! b3 @6 j, l( k
}
& F% K& V6 ~* B9 Z. x; o7 a7 \ }
3 ?* V, ~( D* r: t
' @- }6 e1 S0 U: n: ?function calculatePosition() {+ G/ ]6 O( ]7 l z3 F- z
if (xDir == "right") {
7 I* f) j' e' ^+ @2 ^+ m6 g if (xPos > (xMax - contentWidth - BallSpeed)) { L' U) p. s- D8 F9 w
xDir = "left";
3 m! t- }6 w' x& D7 { }
) g" \6 h, G9 J" j* t5 b }
5 `/ [- H9 Y7 j' `' S else if (xDir == "left") {
" K' q% D5 h) K& u1 d) b if (xPos < (0 + BallSpeed)) {
! Q& m' p6 s V" R xDir = "right";' \3 T; ~" m9 | Q7 c
}9 R: M3 `5 N- F: z, M
}5 a4 e0 I3 c; |9 ~7 H: _
if (yDir == "down") {: A3 n5 u* k. l, B. J+ _' ^/ `% }
if (yPos > (yMax - contentHeight - BallSpeed)) {( ]! J5 K& D: r9 p i
yDir = "up";* C7 |/ X2 S& R$ i: J) G/ K
}# G) |2 c) T" V4 ~3 |
}
) q2 a) q* i1 a else if (yDir == "up") {
* u: {( f5 c- P" P3 M) {( {: o if (yPos < (0 + BallSpeed)) { m0 k3 v1 e: w+ Y- r4 {) G6 I# R
yDir = "down";
# }" N3 f S# o0 i8 E0 ~ }9 l1 Q1 e4 D% O: [( a0 g6 V/ N
}/ A; P8 N! \, }" I- ]2 c
if (xDir == "right") {
: V3 T& k/ i* v* d( b3 F% c5 a' y xPos = xPos + BallSpeed;
* Q8 A C4 a& ~4 | W }" E% l& Y4 {# p/ N ~! a+ B5 B' a
else if (xDir == "left") {
8 A( d) v4 w l xPos = xPos - BallSpeed;
, s$ j- n0 o. T ` }
" c9 { Z7 y9 y0 H% T5 q7 ] else {% y: B. M9 {" t) n+ W
xPos = xPos;
" M# ]2 s8 \8 ^# Q }9 l! H: F0 k$ ?& c- M9 f
if (yDir == "down") {
, w( D: y1 I% B5 o, @& g5 Q* B yPos = yPos + BallSpeed;
. |, I1 F$ \: y, {0 `1 t }* ?# m7 M: d- G# Y* F$ O
else if (yDir == "up") {
3 o. F* ?/ I, h' N1 [ yPos = yPos - BallSpeed;( Z" M: g( W6 @( A5 w
}% s. H( P; B3 Q* W
else {
* Y3 { f% G( X5 }" s/ i yPos = yPos;0 y. }1 t, j N
}
& b0 K: \" y3 n2 T6 T }# [' g ?6 ?; q1 k7 ]& P! g+ L1 y
* j6 Q' `, M, t+ m" w1 {3 W8 Y+ Dfunction hidetext(){4 k/ Y* E' l' C$ z$ m
if (document.all)
( c+ |! N- D4 H; @2 x1 v, B$ Jsupertext.style.visibility="hidden"1 `. D; B7 g) h
else if (document.layers)4 }. w8 `# }* A6 x9 h" j8 R' G/ `
document.supertext.visibility="hide". `+ B p4 c# W0 B0 C& w
clearTimeout(animatetext)
% ~6 e9 T7 u$ g5 j}5 s" ]. z' D: ^6 \) H1 }2 g
% g# p; Q5 A; Aif (document.all||document.layers){
0 E' z+ {) @3 S& Gdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) m9 Z0 N, x9 t' M0 h4 F; R# [0 Vwindow.onload = initializeBall;. ]0 ^+ R$ w" {7 `
window.onresize = new Function("window.location.reload()");
. f# w8 T" D5 v# ?) ^}
) D7 ?- [. J. w' u' `! L
8 S# a3 R- w% k</script> |
|