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

|
网页之不断弹射的文字-特效
<style type="text/css">
2 Y0 j) [& \7 m8 g1 O# }3 o3 r#supertext {
$ @* }2 ]5 R" U3 pposition:absolute;# Q8 h9 r. }$ x3 F; w% U$ V
left:0;# W. ~0 e4 s: O! m( b
top:0;
1 F/ m: A0 H2 {2 e! K& [visibility:hide;9 p w7 I# G; E- b' A
visibility:hidden;
7 U) w- ]; A6 v, g}. I; o5 p5 V, I5 \) V& X
</style>/ S8 t" U+ ^3 f+ o) ~
<script language="JavaScript1.2">
* _) D! X, Y* X<!-- 改变下的字体的大小。颜色-->+ X7 c6 j |* l- g
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'5 X- b% n) R& F
var hidetimer='';2 L. N* j7 m- p+ H. j! s+ \( K
<!-- 改变下的弹跳速度-->6 ~3 n: W; D6 b; _( @- K, P% C
var BallSpeed = 20;' q( [0 G, K( x) a! a ~
var contentWidth;* F ~5 ~5 }) L2 ^( f$ u9 G
var contentHeight;7 W) U/ R. Q; S" ?' q0 D7 F$ e6 h! Q
var maxBallSpeed = 50;' s- L; A* _) x* }
, `/ ]0 M9 _$ F8 {% {9 A- B
M# ^7 s7 e* ^- j3 j- A7 S
var xMax;
" ^1 @; J O% G0 Bvar yMax;
u5 P4 b/ [5 {2 F( c3 Ivar xPos = 0;* q# L$ w9 B- J2 e
var yPos = 0;! P! O8 Q/ N& Z& A
var xDir = 'right';
4 c4 p( A2 ^1 y) b1 B. c9 wvar yDir = 'down';
! f% X5 c1 w/ p. l) z2 t+ }, s% uvar superballRunning = true;; h0 ?5 B8 D4 Q j8 h9 u3 O
var tempBallSpeed;
: P# ?" e2 B& C% uvar currentBallSrc;
: T. i# r0 D9 Xvar newXDir;. Z5 t, b% W: I, h( U7 l
var newYDir;
/ S2 t- P1 T s* o7 A; I/ r( e1 k4 R$ n0 Y
function initializeBall() {, `( i( i" w7 U0 _; o
if (document.all) {
J, p' g' p7 {' l xMax = document.body.clientWidth3 l2 j1 R4 U! \: g; B/ n, T4 H# K
yMax = document.body.clientHeight
& F$ [% M3 ?6 y; A L document.all("supertext").style.visibility = "visible";8 [5 V4 O5 D1 n, W0 z! }
contentWidth=supertext.offsetWidth6 o: b$ @) Z7 ~ ], B2 W
contentHeight=supertext.offsetHeight
: `) Y' R2 c9 \, v }/ i: B2 h' U# M( R. A" r( |
else if (document.layers) {$ O- u& o2 C0 M; B' Z% h7 a) F
xMax = window.innerWidth; [" b+ {0 D% V
yMax = window.innerHeight;; }& L" v$ ~% ?' O
contentWidth=document.supertext.document.width
! c; U0 a/ \# V) C* v: Z5 E contentHeight=document.supertext.document.height
9 q7 o: A2 Q3 b2 G+ Z. r+ d+ v document.layers["supertext"].visibility = "show";
& B; _1 E1 J6 G( X& X: @ }- f) Q5 |4 f4 |& j# k
setTimeout('moveBall()',400);$ {" G2 F1 e0 H3 y4 ]: {
if (hidetimer!='') x s) }% X6 }% R5 O0 X
setTimeout("hidetext()",hidetimer)
4 Q8 ]0 I% e+ S0 E6 y* i }
8 z" X7 A+ t( z6 S, x5 L3 ?/ I( p c; \7 @
function moveBall() {
4 h5 h4 {! ^; { if (superballRunning == true) {5 Y8 {2 X! V% ?8 a; M
calculatePosition();
! ]7 |" h& I& @& @5 V1 ^4 B1 ] if (document.all) {( N) C% O# e% q b5 }
document.all("supertext").style.left = xPos + document.body.scrollLeft;
* K S- I% w' l: ]& P document.all("supertext").style.top = yPos + document.body.scrollTop;
% ]$ p: a5 k( ~) ?+ J& E( k% b }
0 {2 i; X2 w5 v, B9 W3 D else if (document.layers) {
" B) z5 F6 j7 z/ }4 D) p1 [ document.layers["supertext"].left = xPos + pageXOffset;0 J9 j/ B0 ^ { d
document.layers["supertext"].top = yPos + pageYOffset;) d- G1 F$ M9 T% j* w
}
x: F1 i7 V& g- V |- p# E animatetext=setTimeout('moveBall()',20);* `2 z2 M) w7 U/ g: Q
}
3 r I: B. S8 h$ T& C7 P3 F }# m. @$ L9 z/ W, K( n4 z8 y) k
' r1 Y2 E( k9 g7 [) Afunction calculatePosition() {
! A0 P7 V5 V9 b# @ if (xDir == "right") {% G/ W% e: S9 N
if (xPos > (xMax - contentWidth - BallSpeed)) {
* N+ x. z( {/ E xDir = "left";$ N' P, A7 `4 `0 q
}
- z: W4 Q; }: j& R+ s0 d9 N }0 S! k8 x7 q+ _7 g3 q# k# Q
else if (xDir == "left") {
2 G& x. F+ o, F/ Y/ o; P if (xPos < (0 + BallSpeed)) {4 Y J% _- @" d& f
xDir = "right";
2 P. z# t! n+ F' l9 o }
* n; L1 l: a! S% T4 O, R }
4 A6 n G; f; l if (yDir == "down") {
& ~1 R2 i: b) ^! h7 T if (yPos > (yMax - contentHeight - BallSpeed)) {
8 N( i9 ]+ G* W+ A7 a: s4 L yDir = "up";. V* u' k+ z$ `6 @4 ^* X
}$ _8 _; v) C# E& \7 ?2 `
}5 w$ W0 K# s- @, q
else if (yDir == "up") {1 E% z: V) Z8 L* d* f
if (yPos < (0 + BallSpeed)) {- B+ j" q$ v# N: b& n
yDir = "down";
^7 }" Q- k9 P$ {# _( Z }+ W3 c: D. G' Y" |3 v: a+ f0 n
}" m! o# l( f# o
if (xDir == "right") {
# `" [: }7 g9 S, S xPos = xPos + BallSpeed;) [2 A, d6 W x9 _
}
2 v! O; z( |# |& `/ N/ v* m else if (xDir == "left") {
1 V. G. j3 I6 u; l6 j- c8 y8 { xPos = xPos - BallSpeed;) D% a" g2 E4 R4 S! }
}
! \& H4 v$ h, o. u else {& F$ b5 o- H/ E; r; t
xPos = xPos;
6 u' P3 W: A( Z9 O; u }
: ?9 w s4 ^1 \; j, n if (yDir == "down") {
$ P3 U# _, m) W0 \ yPos = yPos + BallSpeed;4 g, i, D8 a" f5 \$ `- Q- [) f% N
}, N7 R8 V7 V# ~
else if (yDir == "up") {( r% w9 [) ?: W
yPos = yPos - BallSpeed;* ]& @7 N# z# M! J7 [
}2 ~4 S- b! x1 R9 D' o; n
else {
7 K2 v9 q7 |! U0 ?9 p yPos = yPos;0 \; t0 W7 {; d( O4 \9 Q8 O- b
}" g) E1 t" ~2 J5 X7 F) \, x
}
' J; t3 v4 k/ U6 f2 q. H
. h7 }, s: B- A1 ~3 w! O; hfunction hidetext(){
" H, P/ f4 p/ W3 l- _+ t8 yif (document.all)
; Y$ j. e2 D( @: u1 ysupertext.style.visibility="hidden"( w) V! v G4 I
else if (document.layers)2 \6 M# ]# Z( l* O* u
document.supertext.visibility="hide"+ b, \8 |" z) {" ]
clearTimeout(animatetext). E+ B# m y7 {' U
}: j. w4 W& s7 p' G0 v
5 v* {4 g* ?' _0 o- Qif (document.all||document.layers){
% x- ^9 ]3 E q: s; Tdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) D/ i0 u D5 [+ Owindow.onload = initializeBall;
# E0 C6 g9 U$ E, c; d. ]5 ]window.onresize = new Function("window.location.reload()");& ~6 n+ W% ?9 D; c6 l
}: Q A9 {! I2 D, M4 g4 K
+ x- m, n/ P8 V5 S5 v" u# b( @</script> |
|