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

|
网页之不断弹射的文字-特效
<style type="text/css">
( S* _! ^4 f+ ?#supertext {
y( r6 ^( [& y2 zposition:absolute;+ M; X8 |' W5 e7 x% r
left:0;
) }! e% H3 Y! ]6 qtop:0;9 s# C$ J: n. U2 R# ?, n) R; z% r
visibility:hide;
* E6 B' m, F' \6 Rvisibility:hidden;
8 u" ^8 B3 E3 U7 d, m" Q& p, b}/ t7 Y" E1 y4 S. G8 E
</style>
' _! K1 I; c* W1 Y) o; W9 m5 q<script language="JavaScript1.2">0 I u3 h! Y/ M2 N! Q/ x
<!-- 改变下的字体的大小。颜色-->. [# l# ]! A) ^6 O* W
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'9 S9 v) h0 @$ z# N5 ~
var hidetimer='';
# ^( K- q! S9 _, _ h& v<!-- 改变下的弹跳速度-->
! i8 l2 e* r% l) Tvar BallSpeed = 20;+ m8 f7 r. v' q# z' ~
var contentWidth;
/ \, i( P3 l# z$ X% O7 uvar contentHeight;
2 |5 I! i2 K3 B6 s9 X/ J& [var maxBallSpeed = 50;
+ Z5 X8 }, \& k' k1 L; n
# R9 v: l( t7 t1 p6 }/ u9 F7 L0 H; S; }$ @
var xMax;/ G1 ]% W& @5 X
var yMax;
! Z; g, k" i, R1 evar xPos = 0;
9 y+ [* _' T! K% tvar yPos = 0;- J% M3 \% M6 a/ a# D' A
var xDir = 'right';: B3 P4 D# Y; K
var yDir = 'down';
# r7 T) j; A9 @* \3 B- R" Avar superballRunning = true;/ {/ a* K. k- a, w
var tempBallSpeed;
: q g0 L8 T9 a: k8 Qvar currentBallSrc;
7 o ?' L& L( R- Ivar newXDir;- f+ A8 a6 }* Z1 ?8 S, e
var newYDir;: v& R M- U" I
4 b3 X* r( G# i8 J9 T9 b
function initializeBall() {0 M5 J) @5 O1 @2 n, z% L
if (document.all) {
$ \ g+ u8 B9 r* M xMax = document.body.clientWidth0 i* J0 B0 z0 \; H# }8 v, g
yMax = document.body.clientHeight
" T, U C0 @/ {) @9 a" |+ T document.all("supertext").style.visibility = "visible";
( }2 X2 K0 X/ _$ z! z contentWidth=supertext.offsetWidth/ O5 k# j1 I7 s& ], d+ V
contentHeight=supertext.offsetHeight( ?; S% Q7 O2 l3 i$ h; K% a& E
}% K0 x; Q" i+ K+ z
else if (document.layers) {
0 I6 ~8 r4 Y6 T$ L xMax = window.innerWidth;
* l( d8 V. k" R/ }' y w- j9 C yMax = window.innerHeight;" |2 ]6 [2 q: f0 @! }
contentWidth=document.supertext.document.width* u+ Q' N+ c$ F) x( z# h% N
contentHeight=document.supertext.document.height
% D( Q9 P( E( v) G3 E L& J document.layers["supertext"].visibility = "show";
" O5 t- s( T! `- ^+ g& f }
X( j' C s+ z0 m- V$ `/ W7 s$ @3 ` setTimeout('moveBall()',400);
$ D% k: D9 z$ \ g if (hidetimer!='')5 y( x. L J \
setTimeout("hidetext()",hidetimer)
- o9 S* K6 X0 [ G }) g4 i f+ ~0 V7 y+ ~
9 A+ H4 \5 J- e6 Q: g' Q; {% [
function moveBall() {' @+ x- e6 C4 S" X# n. l) W
if (superballRunning == true) {
( g4 d, a5 W9 V: B0 T" K. f B calculatePosition();5 K/ i) k% _1 {5 P+ w
if (document.all) {
6 @/ K+ X& v/ C! L3 j document.all("supertext").style.left = xPos + document.body.scrollLeft;" c$ Q' X& u9 Z- M# [
document.all("supertext").style.top = yPos + document.body.scrollTop;- G* M P8 j( s" @+ j1 h# d! ]
}
! }1 g( ^* p0 b- `/ H8 o L. t else if (document.layers) {
5 e8 f) n+ A& R( e1 |4 ~0 u document.layers["supertext"].left = xPos + pageXOffset;4 a: I9 V2 `4 k
document.layers["supertext"].top = yPos + pageYOffset;8 c3 {3 ]" i3 d( @' ?# @
}
' ]' v/ l( A- |1 Q' S( g* {- J animatetext=setTimeout('moveBall()',20);# m$ r: w h2 f) m" `4 N
}: q7 \/ ]$ k8 f5 W# j- |
}
6 c2 F: Q4 S+ {: ^( F3 F/ G- j& u& l" F
% i9 I, Q3 o1 [- M: A) q+ Efunction calculatePosition() {: X" c7 c1 b& V! `. k
if (xDir == "right") {
7 \4 i9 N! r3 t) j7 u# d' Z if (xPos > (xMax - contentWidth - BallSpeed)) {( E Y2 R8 L3 T9 ^; m% i! w8 R
xDir = "left";0 y7 r, I' ^# e' D8 @
}) Z& {" H g9 \; ?! l- g1 F
}# j0 U- E) T2 V' B$ A4 j
else if (xDir == "left") {0 i; e) C7 |( [9 Z8 c/ u H
if (xPos < (0 + BallSpeed)) {
/ I$ }& N! h5 e) S! D" J( s# I xDir = "right";6 ^ K/ |( S# j# j& F7 n N, d% F
} c! }1 \( c3 d- A) o
}
7 u: @* C/ u& i9 s# ] if (yDir == "down") {4 d& I: l& {+ O6 B; p
if (yPos > (yMax - contentHeight - BallSpeed)) {9 y f3 l/ F$ ]2 o( m! P
yDir = "up";" `9 ? j: B' X
}9 o' Y2 l: _4 l6 l: d3 y+ O' O
}
: x6 _0 h" k4 G else if (yDir == "up") {
- i$ E7 i9 K* u8 a, ^% c/ s" `1 ^ if (yPos < (0 + BallSpeed)) {
3 d' e& U& g9 K% t+ f yDir = "down";1 A1 I8 P* Q* N: o" c% J
}1 ?) v- M( }$ K! R$ v
}
3 ^4 m& t+ z; x/ t2 y4 g if (xDir == "right") { T. J3 A$ ?% b
xPos = xPos + BallSpeed;6 S: U) T( f( X
}: ?* U2 ]/ L1 Q u' G0 q
else if (xDir == "left") {
6 `& z* ]# T7 \. N* D4 s" M xPos = xPos - BallSpeed;
2 [- Y1 Y: J5 @( d- d4 T7 \ }$ }) ~" |% Y3 s0 Y3 |
else {
( x2 p0 A; {0 R& m+ W xPos = xPos;
2 T; I9 ?9 p8 m* I1 u }1 F: H! x" V% s6 k# A1 r
if (yDir == "down") {
. [5 {3 ?) T+ F2 e; I yPos = yPos + BallSpeed;
" o$ x8 Q+ U( M4 k0 ? }
/ p; L: _" X& i4 s, R' J t( D else if (yDir == "up") {- ~! x* ]4 P& L2 h ]8 ~6 x8 c
yPos = yPos - BallSpeed;5 w! h ^& n" ]- [, M5 J/ U
}
f0 r* t1 n: r; a r9 T) ?, I else {6 |4 y6 t+ Z; Q% i3 \
yPos = yPos;! _* G R% [+ ~$ v; g, N) q" h
}% y# [" }0 R7 b+ }; R7 Y
}5 u+ w& `1 G4 y) u2 S
& G h+ g) [$ q) G! t9 O0 cfunction hidetext(){/ |. T" x- d3 I: R! @) C6 q
if (document.all), }) B+ W+ e( y# ^ N6 D# u
supertext.style.visibility="hidden"4 [7 V! ^9 D+ v; i8 p
else if (document.layers); u' R( V1 Z. s _
document.supertext.visibility="hide"
. @, z, i9 U. @3 FclearTimeout(animatetext)
/ `# I. B- R* c}
+ l% k ~" }+ p) O8 t. o; `0 s" W
6 u' p+ K' o8 I) x" _if (document.all||document.layers){
2 N+ c( Y1 U. @2 e, O! e$ S$ Udocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 f! \, F+ J5 W6 G* C e9 W# C X, Owindow.onload = initializeBall;
" [# D, L8 R1 {4 U; Owindow.onresize = new Function("window.location.reload()");9 ^0 o' l: ]( R7 u" u ~# R$ s9 j
}1 q4 D3 G6 j3 u7 u8 y3 C" o
3 o5 I- M$ y, l2 S
</script> |
|