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

|
网页之不断弹射的文字-特效
<style type="text/css">
4 Q0 H7 S8 l/ J! r b+ z#supertext {0 l; J$ L+ ^) }# s- r
position:absolute;
& n& z7 B |6 ileft:0;
. I* D6 _; a7 h) vtop:0;. G. B; n0 q) m$ R
visibility:hide;
l& l' Y3 ]7 |9 {/ Bvisibility:hidden;
8 ~6 l7 Q2 L! r0 r+ @}
, |4 X6 I w' t5 d- i3 z" |</style>
0 j2 n5 c: ^4 q e& H+ t" d<script language="JavaScript1.2">* P3 u" r) u6 H
<!-- 改变下的字体的大小。颜色-->
* _- w& |9 L) R( @: dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 K8 Z9 t$ V0 t3 e$ Jvar hidetimer='';; ~, b9 F% M9 a, E7 g" j! k
<!-- 改变下的弹跳速度-->0 |- ?5 ]* j J
var BallSpeed = 20;* E7 P; J0 e6 y# b6 v; i/ F
var contentWidth;
; L! H. d7 O/ Uvar contentHeight;7 z% b9 ?/ a v$ f c1 j& p
var maxBallSpeed = 50;
4 C: X6 \. u" ?, H& w/ F% D( ?3 n
/ [& G: j: m$ i) R' k, r& G Y. |4 _& _- d/ q# i
var xMax;
* Q6 n$ R) s a5 ]var yMax;
- r" D" z4 q8 |1 q$ \' a5 ?& Evar xPos = 0;( T2 X7 s. i0 b) }
var yPos = 0;( k/ J9 k9 V, G, m- t0 _
var xDir = 'right';# q# p8 V2 ?* V( \ V( Y
var yDir = 'down';3 ]% ]- V" i+ N# Q4 \& A
var superballRunning = true;
; T+ d" U8 P: v6 Uvar tempBallSpeed;: i2 R) h4 Y/ R
var currentBallSrc;
+ R) \0 D, H! X! @$ v. ~8 M; h4 D! ]var newXDir;
, W# f. I' ?" B* P; m" t+ n) Xvar newYDir;
/ x; e" L" f$ X0 Y
+ H+ ~7 I, l' U- U) h" D& U: b; bfunction initializeBall() {1 ~! m9 |1 ?% a5 p
if (document.all) {
. L' G+ }! [- P xMax = document.body.clientWidth
1 J7 m' q( b( t yMax = document.body.clientHeight
# s* d& } E/ K; D2 g) R$ H document.all("supertext").style.visibility = "visible";
7 O' ]5 v5 L1 j; Z7 ~9 O' x3 d contentWidth=supertext.offsetWidth
c% K, P' _( z6 Q. U1 x3 S contentHeight=supertext.offsetHeight
0 R/ U' ~+ C; @$ S' F/ f, C4 N1 u7 u }, H" W- `2 R2 \' O; l
else if (document.layers) {# D! m, A+ w4 e4 P9 U% X4 [
xMax = window.innerWidth;$ I5 p r* G" Z$ |+ T- e+ h5 @
yMax = window.innerHeight;$ X" g# Q- ]4 \3 c
contentWidth=document.supertext.document.width9 \9 A) c2 t0 d2 z
contentHeight=document.supertext.document.height; r$ |5 n6 n0 `" p
document.layers["supertext"].visibility = "show";, w) N0 i( y/ A7 ]3 b; L
}: m* ?5 t& l5 K0 @% S, A0 b
setTimeout('moveBall()',400);
/ d/ ~3 d6 G h& \) w if (hidetimer!='')
/ p' E; q' l1 v2 h setTimeout("hidetext()",hidetimer)8 `5 t/ G# q& k( Y' N) d9 {3 s
}
. v+ j t7 B5 K) D3 w* p3 n
, v ~: P: Q# G/ [/ G2 ?function moveBall() {
: Z* T9 K! p: }% f1 P' h if (superballRunning == true) {$ U8 a* ~! T; {2 E; M3 X
calculatePosition();
. O8 z! R( ? ~, i$ g if (document.all) {
6 t1 o0 v4 F5 Z w document.all("supertext").style.left = xPos + document.body.scrollLeft;; r U& [" Z/ o9 S
document.all("supertext").style.top = yPos + document.body.scrollTop;3 ~+ w5 L8 i" l3 F6 W1 t5 s
}4 r+ L: E3 w+ M) k2 T1 `' f
else if (document.layers) {
7 G$ J! O8 P" c1 }8 i document.layers["supertext"].left = xPos + pageXOffset;/ D' T6 I7 T+ I" {" F
document.layers["supertext"].top = yPos + pageYOffset;! [0 o8 H4 N5 Q! a& r" q
}
. ~* ^0 r! q' I8 @+ n+ u6 v9 c& L animatetext=setTimeout('moveBall()',20);+ e9 W0 c P8 s& x% i- g4 P! n
}
3 N# R; R6 e% O) }/ l7 A W3 d }5 u' z$ i. o4 n' g& E G
. Y0 m% y! l: zfunction calculatePosition() {
0 J1 V% d) ^$ k+ I' a! S& C if (xDir == "right") {$ X0 P* P" t j9 Y
if (xPos > (xMax - contentWidth - BallSpeed)) {% {4 Q6 A# o' J; y" C( v
xDir = "left";& x3 \/ b2 l! y
}
) l s6 k* o2 M }: K, O$ S$ h" F" t/ Q
else if (xDir == "left") {
4 N0 [) x4 a8 V+ X4 M' w& \) x: P% o3 N if (xPos < (0 + BallSpeed)) {( v+ b8 ?6 W# u
xDir = "right";
9 M; z6 I. }8 R$ p! t }# S. j/ w) x2 f# D( b
}; ]1 @: o8 {- z) K$ Z) B
if (yDir == "down") {! A! @# Q/ N$ {0 z3 w2 G
if (yPos > (yMax - contentHeight - BallSpeed)) {& A# Y/ V) i7 [7 r
yDir = "up";
) Y8 c; O8 O! f4 B4 P }2 s3 H* R7 i& Y. ^1 x: ^+ m8 r
}
0 V$ i2 Y: C/ s, m3 o5 }: e& @ else if (yDir == "up") {
: l: l5 z, w% J$ d- N if (yPos < (0 + BallSpeed)) {
+ s+ Y2 i! G, v* ~8 J yDir = "down";& G; T1 s% G& l+ q: L
}
, I% n% b+ Z9 O# p) [4 y4 z } T' j* } J, I- [! K' ^* B2 F
if (xDir == "right") {
+ c9 L2 c; d& s xPos = xPos + BallSpeed;0 R, |9 K: J) k# Y: f
}! A6 F/ A. E: e6 v9 g" C3 ]1 x
else if (xDir == "left") {
. O, Z) ]7 b/ R xPos = xPos - BallSpeed;
0 [2 S1 L; K( b$ d6 L }" U" O6 M8 s, m! q6 n/ f5 V
else {( ^. {; r7 O4 _0 n- N1 J. @
xPos = xPos;
& @" }3 Y E' s9 r7 {/ R0 H }
: b7 J- C6 F* u0 r1 _( B% } if (yDir == "down") {
8 A5 p4 R$ F! j9 w* j3 Q: r yPos = yPos + BallSpeed;& r* e! ?' l: v: H; }2 F
}) ?1 ^2 X1 N9 j4 t6 }5 _) m
else if (yDir == "up") {5 E- A! L7 a" s0 a; u' e/ V4 G
yPos = yPos - BallSpeed;2 d, {* R! e% j& m7 E
}
" [, i- I4 D+ \7 o8 t) G else {
. z" l* x4 g3 l! p' s yPos = yPos;
& g5 v; A* k( H! x9 @- F }
3 z7 V# N/ f! s8 w6 O }
: N! ~8 i, F p; ^8 Z
3 D4 l4 G& Q$ _5 V, @ F3 X- U" Zfunction hidetext(){
+ N* \ P9 I- E0 Lif (document.all)) K) p% Q {" N- D, l
supertext.style.visibility="hidden"7 `' d- q" L. h0 e
else if (document.layers)
/ K' d% I! \- c. e! Zdocument.supertext.visibility="hide") y5 @# v( N& k4 q2 W: F. p
clearTimeout(animatetext)1 j8 y q/ I9 n7 b, i b
}
+ I/ ?+ S* g# J. j
0 F6 S0 j" ?9 f$ c, h Lif (document.all||document.layers){# Z" T, V9 P/ J$ ^9 y1 p& L( d, K) }
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'). d5 }/ u4 c+ z
window.onload = initializeBall;- i' D" ]9 d1 q/ s
window.onresize = new Function("window.location.reload()");( T1 l- s d1 ?) Q
}% Q9 C, s+ s' O% v( n7 d$ r
% [/ s1 j5 V5 b7 P! y
</script> |
|