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

|
网页之不断弹射的文字-特效
<style type="text/css">
6 r5 {' ~$ s2 t0 c; H/ G$ k6 W& M#supertext {, b. c& m+ D$ c) g0 s1 Q5 q' W( c
position:absolute;% Y( N7 y0 Y9 j' i: W8 C
left:0;; T1 K$ Q" |& u n0 d9 T
top:0;
$ h$ R1 C7 E* f3 dvisibility:hide;
! Y* J9 m$ x: s/ @6 zvisibility:hidden;
* t0 ^+ Q$ E* p5 p1 O: H1 R1 n}
" Z) k" [1 e: w) Y, n8 R/ C</style>
4 h. U% d( T' v* t3 L1 w( e! f<script language="JavaScript1.2">1 M U) n4 s# |7 H3 q1 I% y# h
<!-- 改变下的字体的大小。颜色-->( K7 ^6 g8 S6 J8 {' J# ], i
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ }% O f. r+ F# x) U T8 k
var hidetimer='';( A" ^- i5 b3 g) K! }, {
<!-- 改变下的弹跳速度-->; ^; P4 z. l) n l# v
var BallSpeed = 20;
6 Z6 z, i6 ?- z& I/ V+ x# Mvar contentWidth;
; |0 s$ r; K/ L0 ]+ V: _1 avar contentHeight;
/ y; ^; n7 _3 x) A* uvar maxBallSpeed = 50;% f0 m) F( Y( M9 f3 ?
4 l$ \; H& V# ]5 @2 ]
+ k ]6 Z6 i1 _$ H/ k D4 l+ n2 I
var xMax; J& P2 I9 U( x$ [3 p% c
var yMax;
) t& i; r# V' w( }! nvar xPos = 0;
* w5 q1 \: B: ~" e) i' i% Yvar yPos = 0;# h" A+ r c! h$ k! {! I7 P6 Y
var xDir = 'right';! r! O5 d4 `) w ~: x
var yDir = 'down';& X8 P4 o- l0 A4 |2 A/ E$ }
var superballRunning = true;
5 L8 b6 ]( J; K; h2 gvar tempBallSpeed;2 O6 h) t9 R* U" p, U% Q$ u1 o' k4 V3 P
var currentBallSrc;
6 S& e Z. U E* D6 Kvar newXDir;8 @: V6 F% U( `: T
var newYDir;
! i- t u4 _% m( \" T0 s$ d2 H1 R! g' f( n8 _5 g- `% }# F4 @
function initializeBall() {7 z2 b5 p. z& \' ?9 N; F
if (document.all) {
3 U" O$ v/ P+ D7 W xMax = document.body.clientWidth6 x, x( G$ v) y) p2 K
yMax = document.body.clientHeight3 W( F' a% z: ~4 F
document.all("supertext").style.visibility = "visible";
. f0 ^. I& T. U- S# ~( a8 A" A contentWidth=supertext.offsetWidth
1 t' _/ p" d( T4 y# t3 h" }: J! E! U contentHeight=supertext.offsetHeight |' q# l( M$ f% p6 k2 X
}. s* i/ b7 V4 F! Z; d2 G
else if (document.layers) {8 e3 [" z2 o2 @/ [$ q3 H5 K
xMax = window.innerWidth;- A' @9 W. w8 \4 |7 y+ o
yMax = window.innerHeight;
; @4 U- g1 e( N% t9 u contentWidth=document.supertext.document.width6 F; b/ j3 `- q4 j: u
contentHeight=document.supertext.document.height! {+ b! |& @; ~
document.layers["supertext"].visibility = "show";0 k+ A# B+ C7 m! w1 A( r3 x* i! _0 H# ~
}. b7 `; z- a) W5 V/ Y' y$ \; s/ A% z
setTimeout('moveBall()',400);* s( W8 i" O% x, _1 A
if (hidetimer!='')3 t. ]- i8 C7 X, P$ C4 M8 r) l1 @
setTimeout("hidetext()",hidetimer)
! b J8 B( `$ d% I+ ` }- V4 t* f% u4 x: w8 P4 | a
. F( e e2 A7 X0 D
function moveBall() {
# `9 q+ X, H; w if (superballRunning == true) {
4 i& @6 o* T! M1 Q6 t4 ?: m calculatePosition();
2 \/ l5 \+ A) L if (document.all) {6 `9 ~+ r: e" z0 i+ s( q/ |1 h5 ^
document.all("supertext").style.left = xPos + document.body.scrollLeft;
( p: _1 j, K" U% e; v( \ document.all("supertext").style.top = yPos + document.body.scrollTop;
, s9 o3 K% U1 ~ }) m; r$ d$ X9 ]& Z1 q) P6 P( I0 Q
else if (document.layers) {
( e7 ?9 a. M, ?3 _ document.layers["supertext"].left = xPos + pageXOffset;
9 v3 L& s4 q" d# U document.layers["supertext"].top = yPos + pageYOffset;" h- }: j1 g7 Y0 E$ \' ^, e
}4 K7 o3 y1 m* ?* N N
animatetext=setTimeout('moveBall()',20);
: V, x1 F+ P; [/ h9 u5 V }% V' {$ H. S- D
}9 }: p! Y$ g0 |1 S# S1 L2 x
/ X/ K# r' ]1 [5 \$ wfunction calculatePosition() {
" w- l5 y: \/ f if (xDir == "right") {
) {& F: W; o! a, q2 w if (xPos > (xMax - contentWidth - BallSpeed)) {; k% g( I, G% z2 D" a
xDir = "left";! l6 q, h3 Y: G9 N3 @ E% z. ], q1 G
}" g2 L; t S# Y2 o! P
}8 o% L+ D! l: V* _8 a# }( l/ V
else if (xDir == "left") {
( o5 b8 z) p8 G0 N! P& O if (xPos < (0 + BallSpeed)) {
" X: `' G# m$ W1 D( m xDir = "right";6 V! ~" e. A: j
}+ U, M; u% |. e' n/ i% S) E/ v, V
}/ U7 u8 F/ U. A5 U4 R6 t
if (yDir == "down") {
# c$ ?, i( o9 z2 z1 y: W if (yPos > (yMax - contentHeight - BallSpeed)) { B7 Q, |: r" `8 G6 l4 `4 e: }% u
yDir = "up";7 J1 ?8 P+ y1 C+ E) j1 G
}
8 ?: m O$ H" p0 E1 k+ l7 j/ _ }
' g5 F4 O; n6 [) E, C4 P else if (yDir == "up") {
; E7 r2 b9 e9 O5 ~" ?2 e/ m5 ^, v if (yPos < (0 + BallSpeed)) {
! J, H) @" r! A: g3 b9 J yDir = "down";
, U. D" ~, C9 Z& V! r2 u; r2 ] }
" Z8 z+ O1 R8 F$ j- H" ~" B }# v8 Q4 A: q9 j' `) X$ K% A7 l! J0 J
if (xDir == "right") {
8 q6 W/ W1 k* Z( H8 { xPos = xPos + BallSpeed;
- z: J G. d& R; c. }# g }
) g) q. R1 g! F% N! k$ V else if (xDir == "left") {
. o/ k9 j0 m* }" Z xPos = xPos - BallSpeed;/ _9 ^& z* z% V4 y
}! j4 |6 ?7 r" _/ T3 x' S0 s
else {( F- l \1 q ^- a& y1 x j3 X
xPos = xPos;
( G0 E# g0 T7 D- X; _: @9 @ }, ^1 r/ M7 W7 Z; e: `$ N9 P
if (yDir == "down") {- x# F7 b+ r7 x' f
yPos = yPos + BallSpeed;
; W/ j- Y9 z% R" X }
1 r1 ?2 ?4 F1 f% ?# t2 A( A! n! O, J4 r else if (yDir == "up") {
+ t& a# a5 {0 w; S" L. g6 H$ F+ v0 J yPos = yPos - BallSpeed;7 L7 F( v1 t( v0 {% T8 h$ W$ S
}
. C' d" E) y1 u3 y3 \" N1 t else {, @& O$ F$ K! R& b. V+ R/ a7 B: s
yPos = yPos;- Q$ z% g* @: Q2 e4 }0 o7 k
}: I5 L; |, S: h
}
/ D3 R- e5 h% l7 c, M+ d& P* l- Z
function hidetext(){9 p9 Y G! [% T6 i9 v8 V: a
if (document.all)
& p T5 [' ~1 @, G# B g9 {+ Usupertext.style.visibility="hidden"
' x# I7 G/ t3 k+ U2 V; R$ Ielse if (document.layers)
% _% h" `4 Z( ddocument.supertext.visibility="hide"1 a ^9 W" |3 R3 x
clearTimeout(animatetext)/ @( U W4 j7 r7 \9 N7 c& {
}
6 |4 u L4 x1 I
4 U4 P1 z/ K# G2 I/ wif (document.all||document.layers){/ A7 g; u5 A1 I5 w
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'); F3 }' P. c2 q# U
window.onload = initializeBall;( U J. R* c2 _7 N( G& q
window.onresize = new Function("window.location.reload()");# U$ S) A& C- l& q# G# t
}$ T" p- o3 b" Y* w0 z1 _3 q
0 Z c2 O& h7 {' o, J) X& Y7 K
</script> |
|