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

|
网页之不断弹射的文字-特效
<style type="text/css">
7 D- T* g, W0 W: y#supertext {
' E4 E& @" ?2 |( \2 L, tposition:absolute;3 |* q5 n; W" N4 S7 L9 E n, g
left:0;
9 R& J, Z4 m ^1 J4 K& xtop:0;
8 ?8 d# W0 T( Y9 Y; ?$ P; Y9 v. mvisibility:hide;
5 W7 l& Z* o" t/ Yvisibility:hidden;
m. ?* v( Z! \% p1 I; t0 l/ b X}4 _2 I) D- v9 @' ~, ]
</style>2 I+ }7 Z! w* @$ A) b
<script language="JavaScript1.2"># y4 D' d3 M; V" ~0 |
<!-- 改变下的字体的大小。颜色--># @ U2 }! b6 N* ~/ ^ C8 ]
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ G5 B$ @& M+ }! X6 |% ~6 P! r! g
var hidetimer='';
( [8 \$ b, L+ p8 v<!-- 改变下的弹跳速度-->
* X9 M! e W& S d' U; f8 T$ _var BallSpeed = 20;7 q& J) J6 w* ]* \ V/ `7 }' J
var contentWidth;+ |1 a+ u5 X' U# n# W
var contentHeight;# `. l8 v( U! \
var maxBallSpeed = 50;% i4 u& f. c1 E- R0 r
) k* z5 v1 D$ Y |3 f
+ H3 L0 l+ g* K! s. N! y: f6 d
var xMax;
9 ?, ]0 q6 l( D& x q! vvar yMax;. l5 p9 v& P3 F- L! K, j4 W3 G3 o5 V
var xPos = 0;# H1 A# ]% Y: R* s D% L
var yPos = 0;
% X5 T3 b+ L/ p L7 Gvar xDir = 'right';
# O- A0 y) U2 O3 {) s n8 Q4 Qvar yDir = 'down';4 T" z" v3 J+ b2 p- ~
var superballRunning = true;: J% _$ A1 v) V! t7 Y5 C
var tempBallSpeed;* c' a* E# s0 ?! t+ O7 ?" b
var currentBallSrc;1 k% e" m: o$ }4 V5 s
var newXDir;
! z. }7 u% ?# P1 ovar newYDir;7 H* l0 C) N7 e, w+ J- c5 T' n) ^
0 E4 o: Y ^. C. F5 W9 Kfunction initializeBall() {+ o# p6 `8 Y7 ?1 ^0 Y# v2 _4 ^" ?
if (document.all) {
1 b" J% ^- j) }; j6 V xMax = document.body.clientWidth
; K( }1 S- `" T3 u( } i. B) P yMax = document.body.clientHeight
( Z- I* V& ~ i* J; b document.all("supertext").style.visibility = "visible";
9 @9 d' h* l, Z1 T( C) A3 f( w contentWidth=supertext.offsetWidth5 J8 G% [$ t8 s0 E9 k: T7 H
contentHeight=supertext.offsetHeight# E7 @# U& c! S: j. o
}# y. _, W: M7 f
else if (document.layers) {
" m6 n! ]% Y1 y; u3 W xMax = window.innerWidth;: n2 x7 t* D: r6 V% W, ]
yMax = window.innerHeight; h1 b% ^8 t, t9 w8 a3 V; i
contentWidth=document.supertext.document.width
6 D" B$ ^. V; U" b2 e contentHeight=document.supertext.document.height8 R+ l" }* C3 T
document.layers["supertext"].visibility = "show";
, R2 K% Z8 |$ L i3 k' W) A: ? }
6 ~) r7 Q: h5 r. ?8 J0 {; [0 g setTimeout('moveBall()',400);
; ?0 }2 B8 u. j5 ? if (hidetimer!=''). T9 r# E6 O5 ]3 q# a* D% f: L8 W% \
setTimeout("hidetext()",hidetimer)6 b2 q& @1 J$ h& F
}/ Y8 e- t3 E" D) g
: r' \* V' ]7 ~3 w2 B+ ~+ {function moveBall() {/ O* j3 z5 N0 j% }9 d
if (superballRunning == true) {: e& G# _; ?* W, i- L
calculatePosition();8 P- g( B% E/ G! {5 c
if (document.all) {7 b% t: S2 U9 \6 ] }
document.all("supertext").style.left = xPos + document.body.scrollLeft;& B, P& d5 g' i% r* Z3 ~9 ]3 O5 x
document.all("supertext").style.top = yPos + document.body.scrollTop;& j8 w1 o% S8 F6 T1 j+ l: T4 M
}
! M3 E6 s" U% ^/ P+ v9 T' w else if (document.layers) {$ Z1 |7 m' n- m$ ~# t
document.layers["supertext"].left = xPos + pageXOffset;1 |; w$ x$ C- ?, x; {
document.layers["supertext"].top = yPos + pageYOffset;' \* j0 R" H6 v2 _& u2 D
}) l6 Y% X3 F5 s/ t' N( ]
animatetext=setTimeout('moveBall()',20);: `: x9 J; z8 U8 P' F! D
}
% l7 B, O" R1 e, S u" g, S+ e }9 w. Y7 H4 w w: q) G& n
8 ]* L: {, V& E n* K
function calculatePosition() {3 @5 j3 g6 N8 e: ]6 u( P: s# h/ D9 D
if (xDir == "right") {
' f; ^9 S5 O; ?. J: A1 a3 B. o; Q if (xPos > (xMax - contentWidth - BallSpeed)) {; x7 R2 ?8 @7 S" m! ?/ s
xDir = "left";
- e$ ~, `5 O9 p9 s) T }6 L; Z0 P n1 w( R
}
5 I. z/ g% l0 _( O else if (xDir == "left") {( ]: A( c# N! O- U
if (xPos < (0 + BallSpeed)) {5 l6 Q! k6 `' G
xDir = "right";
& n/ w B; e4 u }! j, [- L1 ]1 O4 p; Z' F# Q( K9 ]' C
}! a0 k* A( m/ L) E* Z, G2 L
if (yDir == "down") {9 U/ Y& D% x$ N( {" e
if (yPos > (yMax - contentHeight - BallSpeed)) {
' `7 V) ~$ K/ p/ _- R yDir = "up";" z. M+ z6 O3 z% P Q* z+ n
}
5 ~. e: ~8 q/ u, l }6 t# E$ D9 C) E% T0 A- m8 ` y% Z
else if (yDir == "up") {/ Y4 p2 C/ G' V
if (yPos < (0 + BallSpeed)) {$ Y/ ^3 h8 c4 R: n8 _1 T8 b
yDir = "down";, j0 I- M& V6 M& [
}
/ w& Q1 h; i) g9 k3 } }
0 n$ n1 h+ D' J" n, [+ C ]% } if (xDir == "right") {6 e" f; d* B; H; G, m' W8 W9 C# W, Q
xPos = xPos + BallSpeed;
" W8 }* ~* c+ {. ]8 V+ L! x }
7 Z4 W. u0 o- V9 J3 N; C2 K# \ else if (xDir == "left") {
3 X$ t: f1 `0 ]5 g0 S- }; C6 L xPos = xPos - BallSpeed;
! w, I! N5 {5 e5 Y% i; C3 W$ ? }6 L7 G9 z! Q" g) o: l' f
else {: u7 M( I( {: |
xPos = xPos;5 L) v7 O1 E) }+ `4 W- J, x
}* q" v* B* }3 z( t; f( d( R8 }
if (yDir == "down") {3 v" D" M7 T) l9 M% T1 Y7 V
yPos = yPos + BallSpeed;
! |; d A, r4 ?+ f4 c }
& ~0 E; t& d6 q b else if (yDir == "up") {6 p6 s4 R0 g8 n( \4 c; \
yPos = yPos - BallSpeed;" ]+ }2 G" M. V" L% A: m% s
}
3 a9 O1 R2 }: ?' R# K) G else {
; H- |' e6 V) k) j+ a: B yPos = yPos;
! C+ ^5 s1 W* x }
3 z( ]/ n2 J1 I7 @, T }
; N4 _* {0 C. }+ M6 R( J, p7 q; f7 f6 Y& @6 I8 Q4 X
function hidetext(){5 a, r+ u, ]- R8 G" e& p
if (document.all)
5 T& l/ h) \- L1 a9 S3 qsupertext.style.visibility="hidden"
" W6 G( R: B) B* n. S7 }else if (document.layers)# Y& e( |" Y6 U* B8 K; s$ j
document.supertext.visibility="hide"7 z! e2 i' A0 k
clearTimeout(animatetext)- ]' B' @& V& m% s
}+ J7 y3 ~4 [) z. @, N, b% q# u
7 ?7 ~9 e' P0 Z/ s% u. w+ {5 ^
if (document.all||document.layers){
! X, Q3 g. L; T/ ~! ^ mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 v) m% G' j4 Z0 a/ @) e
window.onload = initializeBall;. j1 g+ | H! {( B, H1 o* N' a
window.onresize = new Function("window.location.reload()");0 f$ ?5 B6 Z) m0 r6 {$ _
}6 M& B. U, f$ H1 o K9 s" ^5 F
% \* U0 F* B, ?: O. i
</script> |
|