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

|
网页之不断弹射的文字-特效
<style type="text/css">4 M9 J9 G% E. M% Q- Y4 \0 X
#supertext {
8 b3 g& e& f. Qposition:absolute;
! V8 u9 I# w, \# W' ileft:0;
; @. r) I& P5 w, c1 d: Htop:0;
9 Q0 y5 R; [; k* ^4 Rvisibility:hide;
4 n. ^9 c& k. O) C8 ]2 o+ q3 x$ Svisibility:hidden;
0 o: X# Z& p8 l* ~- T! N}1 [! L, A U7 [( g
</style>
. k, P6 c; N- T4 z: H" D, i<script language="JavaScript1.2"># Z1 v1 F) w4 D! X6 Q% z6 a! k" B
<!-- 改变下的字体的大小。颜色-->6 B- a3 w( E9 E
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') k& u# s9 {! _) I! n3 J5 |
var hidetimer='';
- a+ u; P% [0 ?1 ^( W f9 i<!-- 改变下的弹跳速度-->
2 V2 e: J) {- c+ D* b" V" o4 L! Tvar BallSpeed = 20;
p' E: N" `, P2 b& X. T, qvar contentWidth;+ Z" c, H! I) L" o( q. d' E% L
var contentHeight;3 O/ S* s o. W+ [! z
var maxBallSpeed = 50;
, j0 T/ E e! W, @' K( l2 N7 [7 V: S# }, D
: o3 {( {9 l. ^9 x$ [var xMax;
: H6 B1 L) }& z0 b' q" Yvar yMax;
! R0 ^$ y" q& g% A. O5 L. [var xPos = 0;8 c# T- K2 r7 W, U( k
var yPos = 0;
8 _- b3 B1 }4 J( r" h1 h8 Avar xDir = 'right';4 G9 g/ l2 ?1 |# y& b: s; c t
var yDir = 'down';5 ?% O6 V% n1 ~% x, y1 }* @, e5 D
var superballRunning = true;
+ q4 X) D& U x* z3 Evar tempBallSpeed;
8 R4 E* B, w2 x& Evar currentBallSrc;
- H6 E9 f( _+ N* qvar newXDir;
, N: a. L( ^" q7 Lvar newYDir; G$ P* n7 u( @% V) z2 ]
8 n5 u3 m, Y" B! s& ?2 E; `' @
function initializeBall() {
h/ n% Y6 Z/ L+ @# v if (document.all) {
% u& z3 I; z2 } xMax = document.body.clientWidth
4 g. J% s5 {* k) J% A0 u) B! ` yMax = document.body.clientHeight& f# d1 N1 D0 d2 l
document.all("supertext").style.visibility = "visible";/ H J, n; U) j8 z z
contentWidth=supertext.offsetWidth
* p4 g" E8 E% O contentHeight=supertext.offsetHeight
* c# }8 e' [3 c, Y6 h }
- } E9 k) u! N. x3 `' U else if (document.layers) {8 S4 z. G7 `* w7 Z- _' ^
xMax = window.innerWidth;( I8 R4 U% W K. Q; c5 g
yMax = window.innerHeight;
8 J' u2 D2 m7 e" x) z6 y) B contentWidth=document.supertext.document.width. [+ o6 c" }& t" k6 r3 m2 N
contentHeight=document.supertext.document.height) X3 I. Y2 G1 `/ \/ P. Y- L
document.layers["supertext"].visibility = "show";+ } _ j" F3 ~1 a8 O2 L" l# L
}% D" n, Z1 M# o7 k. }: B: x
setTimeout('moveBall()',400);
% B9 n3 X8 c( B8 H6 A if (hidetimer!='')
) q: U9 t1 S& O setTimeout("hidetext()",hidetimer)8 |$ P- e' D% u4 y8 E K0 f
}
- D( O! ?$ E" o* {, A5 H6 g' o& u* P5 Z
0 p8 x( F3 l& g3 P0 Ffunction moveBall() {
7 s4 x0 F9 I1 v& X5 o) E' ] if (superballRunning == true) {; H3 ?; R$ z+ S5 X3 ?, D
calculatePosition();
. w% j, O) P- W; K/ ^ if (document.all) {
, ~7 ~4 `2 P2 {8 I8 e; ` document.all("supertext").style.left = xPos + document.body.scrollLeft;9 } g) T. J1 Z3 V6 [
document.all("supertext").style.top = yPos + document.body.scrollTop;) ^3 }7 K& I8 e n+ n# X
}
+ e: E) e. a0 ^* ] else if (document.layers) {4 S- D: |4 x f8 Y
document.layers["supertext"].left = xPos + pageXOffset;2 Z) {. R7 s# k. j0 C1 u% B8 _& `, g
document.layers["supertext"].top = yPos + pageYOffset;
% w& m* W7 w" E; X }
! B* M; e9 r$ M, ?: ]. I2 g animatetext=setTimeout('moveBall()',20);+ B9 o8 N. E, Q+ ~
}
, E* M! ?+ B& h+ L9 u/ b }" c& @" ^2 D9 \5 `8 M* {
1 G' a+ N3 H6 m \ A
function calculatePosition() {
* j4 s8 a* h8 K z4 Q5 z+ ? if (xDir == "right") {# ]9 J& `* L9 _9 D. l# v' ^
if (xPos > (xMax - contentWidth - BallSpeed)) {
2 |& P4 B/ k8 \ D xDir = "left";2 o* ^# U3 ]6 g' c
}
; f% j% g' F' X* a6 m }- ?# G9 ?; O. a5 n' k
else if (xDir == "left") {
8 y1 ~; c4 S. m7 C6 m: h9 s# N+ z$ d if (xPos < (0 + BallSpeed)) {1 m. ?$ T" b1 [3 P4 s0 N+ ]
xDir = "right";
8 d9 b; G9 Q% w4 R* x4 X- J, q }
0 ? e! e: e0 @ }' }* u5 t# N7 w9 y- g
if (yDir == "down") {
2 e% J# Y3 k9 R! Z% ` if (yPos > (yMax - contentHeight - BallSpeed)) {
8 Q; @+ U" T: g* z5 P# g yDir = "up";
3 q2 P! `- u% k" { }- ~/ V+ q4 ^. h' c' r
}0 E O, N+ G& {
else if (yDir == "up") {' u! I9 u V* o) o* `
if (yPos < (0 + BallSpeed)) {' C2 D" f: ~$ ]; R1 g+ \
yDir = "down";% [( D6 Y/ B6 x- x
}
/ r4 z6 Y R+ }" ^ }
4 g6 W" Y7 G b3 b if (xDir == "right") { \( w: A4 J/ x0 K# ^
xPos = xPos + BallSpeed;5 T) k S, s. g: Q+ i- [
}3 P9 d W0 T% b; L d4 f+ H
else if (xDir == "left") {
- g: D P+ n) `# F$ P! s- ] xPos = xPos - BallSpeed;5 w1 p M& E0 n# [4 c6 d8 i' G: s0 l
}
0 x- v$ x% ^6 ? B else {; I. V7 O& R0 q) |
xPos = xPos;
^/ ?8 W& |/ Y. J }7 k& J1 R8 H; {
if (yDir == "down") {
0 D7 X5 [ E( x4 | yPos = yPos + BallSpeed;# y4 A+ \* Y/ h$ l8 V' \% `- E
}0 q2 `% U/ I, I/ f8 f
else if (yDir == "up") {, m4 [+ O7 H0 W
yPos = yPos - BallSpeed;
+ V% G' [/ d# {$ j9 z# w7 V% n/ z. h }( `. M( k# H+ I3 R
else {( C1 P* T; n' v( t) D% }
yPos = yPos;& f* y% ` K: X6 w; [
}% b( r$ X; }* f: p4 i
}7 ~9 I4 X9 T5 b/ f3 P$ Y
' m+ ~1 X1 I# U9 Rfunction hidetext(){/ z( C$ T% v4 C! ?
if (document.all)- Y3 Z D: z' h$ ~ c+ E* q
supertext.style.visibility="hidden"
% i# C1 H9 n9 h1 `( m$ ?else if (document.layers)1 I, `8 Y: _6 P" g
document.supertext.visibility="hide"% i, j% U9 v8 M1 k7 l
clearTimeout(animatetext)
1 \6 A$ P b" O* N8 f, ?}
6 J" V5 Q; Z0 ]* L. j8 i0 v! V9 ^& _* U: e5 @) e
if (document.all||document.layers){, t# H$ v! P' s
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
_' b! @# }" y. n! _3 @0 |6 _8 i, nwindow.onload = initializeBall;0 f# B4 r e0 [+ u
window.onresize = new Function("window.location.reload()");; J+ f3 O/ ]/ O& \1 I7 c/ v# U& x
}
7 n8 F$ ]& j& M9 h0 Z" _/ V3 P- R- u7 @1 { B; ? c
</script> |
|