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

|
网页之不断弹射的文字-特效
<style type="text/css">
6 R' A& s1 U$ P' u#supertext {
' M8 k3 r9 A1 E, V; b T9 u! Gposition:absolute;
u/ u$ j" w3 C8 ~left:0;
s" j8 S- N9 Gtop:0;# P- E9 u$ { U/ l; G, V
visibility:hide;
- Q: B0 \9 s, \; i% e) Cvisibility:hidden;0 x3 v" b- x7 Q( Q' ]* ^4 P
}. v& N2 y4 {+ _+ {
</style>
( F0 F! H# V: _$ R' e# e, q<script language="JavaScript1.2">9 w* E d6 |3 Z& |$ J
<!-- 改变下的字体的大小。颜色-->
! [: n2 J6 B$ k7 C8 L7 U/ zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 A5 m: e) C7 J# Z
var hidetimer='';4 T3 o3 k" w# Y8 f
<!-- 改变下的弹跳速度-->
! {) i9 E0 |9 V2 X& F/ Yvar BallSpeed = 20;! K$ V6 J+ v( `$ D2 }
var contentWidth;2 o% [( @. q5 X4 i, F
var contentHeight;
. O+ r! v5 d4 {& G3 g8 f5 cvar maxBallSpeed = 50;" @" H* _# x5 _7 t) [" u$ ]
! J& R5 G8 k/ p' K; p- M
7 Q6 |; Q# L& J, d! a" E
var xMax;- K9 v( m* p3 Z! k9 J) v. o
var yMax;
5 a; L- X/ `: @* N7 k0 vvar xPos = 0;7 Y- H4 Y7 @% @# g
var yPos = 0;' }$ i: |, l" p5 r" w/ G8 G
var xDir = 'right';+ W9 H( H' f. z1 ^5 \4 n
var yDir = 'down';
# o0 F/ {1 {$ v$ S7 Z1 hvar superballRunning = true;
) w1 W% ^& ]& _( |1 I9 \: Yvar tempBallSpeed;
/ \4 t6 l2 V' c) n5 _6 Nvar currentBallSrc;
& w+ \; S5 f/ X1 H4 F# e# svar newXDir;1 k- \# C% }) P3 W- Z
var newYDir;: ?6 B2 d b$ M* ~) B( O( Y
! h, ^; I: ~& z/ B. R+ qfunction initializeBall() {
+ k* n/ L% u8 _* j$ w/ i if (document.all) {
0 R4 p/ G! } ?( | xMax = document.body.clientWidth
* a& Q% R' }/ R# M6 u$ E8 X yMax = document.body.clientHeight1 f4 P3 P# N `4 p% L3 r9 D. `
document.all("supertext").style.visibility = "visible";
3 t/ W) C0 s; \* R @ contentWidth=supertext.offsetWidth
8 F4 k8 W- g u3 | contentHeight=supertext.offsetHeight
. u: i! W8 g, Q& H1 P2 K2 i }, h9 Q9 r( q' z+ o4 M
else if (document.layers) {2 z4 K5 B4 x* e8 X; f
xMax = window.innerWidth;
0 `8 h* m* t. h# ^3 }; X6 [ yMax = window.innerHeight;
4 |$ B# U. x: k! z+ a; E contentWidth=document.supertext.document.width3 R" C* S! i ]1 k( V5 p) G
contentHeight=document.supertext.document.height
& ?; x9 f9 e' g, f9 F2 h document.layers["supertext"].visibility = "show";
; x5 x( W. v9 T% h4 D2 m }) l# G- S, H. r9 s1 q0 ^4 a
setTimeout('moveBall()',400);
# ^1 E/ r9 R, l) r; w7 |5 F2 Z' A if (hidetimer!='')
2 [% G# x0 Q5 o- q( e( n/ H/ H5 u setTimeout("hidetext()",hidetimer)
4 C9 D8 ?+ B3 [1 M* z) ^) B }' f/ ^" h( Y3 A0 r6 l
% j" }, ~ O- P" t! c5 q% T
function moveBall() {5 L. q" _* ?: p- z# c
if (superballRunning == true) {9 j9 d) A1 c+ M$ {
calculatePosition();9 X0 m3 q- v& e8 B
if (document.all) {
* {& @: E' i z9 D document.all("supertext").style.left = xPos + document.body.scrollLeft;
4 e) m0 \4 z. i document.all("supertext").style.top = yPos + document.body.scrollTop;1 H3 {+ J7 _4 E! n. x
}
7 X/ ~! w6 G: Y, U else if (document.layers) {" Q9 f% h2 V; O2 z
document.layers["supertext"].left = xPos + pageXOffset;7 \8 p; l6 i! J+ S. w
document.layers["supertext"].top = yPos + pageYOffset;- ]1 O. @" E2 g6 @! R
}
9 o# Q" _; i, r: j animatetext=setTimeout('moveBall()',20);0 M! V( ?0 v- E- F; m: k6 q" P9 Y
}; \1 i; c8 d1 w- U/ m' E, b* e7 v
}' ~. V. F1 I: P( s! i9 t- Q
- V, d2 c! N5 q% Q, V s% U: l
function calculatePosition() {/ f+ F, e% h( Z$ y9 F) y# M
if (xDir == "right") {
+ F/ H3 ?6 N: n( D$ w if (xPos > (xMax - contentWidth - BallSpeed)) {
6 r% t1 \1 `. f& P. J+ E/ } xDir = "left"; ~* [! Q" T1 Y* ]+ D# w3 S
}
, D3 j+ k0 M) e T7 [, \: K% M5 w }6 E; B0 O) E$ Z6 B8 z, V1 R
else if (xDir == "left") {
! B' f! r. z9 c ]- [- u if (xPos < (0 + BallSpeed)) {6 x/ {$ g7 ? W. n5 n
xDir = "right";0 ?5 [* b3 U1 A2 O
}
' g. a" L3 B, |' {$ s5 y& O }
2 |. e: ]3 G3 N/ P if (yDir == "down") {5 [* N2 Q6 K H, H
if (yPos > (yMax - contentHeight - BallSpeed)) { e. S& D, A: i! \9 t4 | z3 H8 c
yDir = "up";
' }8 _$ R# k% M7 D }2 i$ N7 R8 e; P0 r) d
}) p' n: ^! D5 I# V) b
else if (yDir == "up") {* d+ @6 f' o7 h
if (yPos < (0 + BallSpeed)) {
3 I/ x9 o3 l. s9 q yDir = "down";. P: `( t( ?, H9 O
}
. J+ p2 {- y% L( U' d9 E4 |$ K }
4 k. H. M( j& ^/ a if (xDir == "right") {: V! R k; g* J, r' c
xPos = xPos + BallSpeed;
- H `) U+ E& M }: k- X" G+ \2 t* n; s
else if (xDir == "left") {
% a$ I* g( e8 S3 z" P, | xPos = xPos - BallSpeed;
; x: X, v( z K% d* i/ ]9 n }1 v% D6 I0 g" r) W+ @9 n, ~
else {' ` Q2 P# E, S) ?
xPos = xPos; L. _/ e1 B8 T- n, }2 D4 j9 ?
} u, y& T3 l( r$ u. c
if (yDir == "down") {" G, Y, b! A v* c k
yPos = yPos + BallSpeed;/ S8 K# Y. I, p: k
}- Y: z8 r# j) S6 N4 o' E
else if (yDir == "up") {
% \' F$ y+ E, [7 \ yPos = yPos - BallSpeed;9 P) l% J3 k& Q
}: V3 x- Q! z. e% H# g0 i
else {
1 }9 T, i+ \ N# M, y+ g yPos = yPos;+ g3 ^) n$ J8 M t9 B
}
0 B4 E6 d6 h8 g0 p7 i- ] E& } }
3 `7 B# r; m. ]" `3 U9 e' i# O' ~5 \8 o: U, k$ y
function hidetext(){
" h0 z& ]: M( {9 U) D: X: eif (document.all)
6 s% x" B! @8 R2 Msupertext.style.visibility="hidden", i+ Q* }- N2 @1 r7 l0 A
else if (document.layers)6 T: c t! X/ c, d& ]& h2 N
document.supertext.visibility="hide"- c( k' a9 u+ ?( E4 d% G
clearTimeout(animatetext) \1 u6 z3 _' C. o( Y9 g5 d
}
' R7 A* L j) c
( `. }8 U! C8 U+ |3 f0 Z/ V7 n, n. Sif (document.all||document.layers){
* G3 |) Z7 k1 n& N, k m# vdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* q' T9 n5 A0 o6 _2 S. H1 @6 a nwindow.onload = initializeBall;" t/ _5 r/ P; O F
window.onresize = new Function("window.location.reload()");1 |+ [& p8 C5 A* O& r; @
}
J& M+ Y. v7 W1 [* R& A$ A+ @% a0 P+ h8 r5 R
</script> |
|