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

|
网页之不断弹射的文字-特效
<style type="text/css">5 w/ N. X) E% t( |; h# ?: H9 D# W
#supertext {: g7 [5 k. _& z P; L
position:absolute;
! a* A. a* w: D: G; _3 E7 F) Mleft:0;' {! o# A5 K$ b4 T- x
top:0;' T: E2 K! c+ g/ {0 a" P
visibility:hide;. ?; Q: ?6 {8 {: K& Y
visibility:hidden;
: F5 D" s" Z( s) [2 T}* y- P1 l6 y, s! | b0 D
</style>$ \& ~- [1 h; U1 T2 G1 h
<script language="JavaScript1.2">
! r0 y9 B$ p8 l: V: l<!-- 改变下的字体的大小。颜色-->
3 Y, f7 v6 U* n# k. m# Vvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 e% ~% H8 f* {3 P8 e8 d; k% M Y* cvar hidetimer='';
* D% ?# P' S" z% D2 }<!-- 改变下的弹跳速度-->9 m! i9 p1 a5 R- {7 o' r; W
var BallSpeed = 20;
! S% p# Q6 c: _; }) g/ Fvar contentWidth;
# h! Q' e+ c& uvar contentHeight;
( a2 Q/ Z# `/ C. c' b3 K1 ~! Fvar maxBallSpeed = 50;
: \ j8 ~$ ?* M! R
+ M( t. q A: ~$ O" Q
* K& C* K! Y* Z' O8 f T H7 Ivar xMax;; D) c$ }4 J, t/ a7 F) f- Y1 n
var yMax;
: y+ k7 ~2 `* J1 I7 dvar xPos = 0;
m8 y6 q7 n& Fvar yPos = 0;! g7 C2 x( X6 j1 \4 n: j" \
var xDir = 'right';
/ j3 J5 ~* X/ q3 E6 evar yDir = 'down';
) G- N7 ^# T8 c+ F9 a8 ^/ ^! E7 f8 ~var superballRunning = true;' I+ l4 U1 |0 @6 {( @; N# n
var tempBallSpeed;
0 Z' W8 ^& q1 M* ^; h+ pvar currentBallSrc; _7 K: c1 H7 [. X: O5 h% H
var newXDir;! g0 ^8 B( b9 w% {& E! q8 N
var newYDir;( ]) v, L5 [# U) g9 m, y8 f
+ i3 P! O1 ?; p! e6 Bfunction initializeBall() {
" } q) C3 ?8 V( \' u5 Z7 h$ h9 @ if (document.all) {) t% a* K5 O2 U& s* q* d
xMax = document.body.clientWidth' q7 x" o c5 l2 ~) ]5 e
yMax = document.body.clientHeight
9 ? Y- c+ H' Y: h5 R! P, S" C document.all("supertext").style.visibility = "visible";
; o ]# z7 U2 W$ |. n1 l contentWidth=supertext.offsetWidth
1 {$ ~1 p( G+ U2 f contentHeight=supertext.offsetHeight9 L- Z5 h: L( M2 C
}9 X7 B+ O7 F# K, O l; \
else if (document.layers) {! L) @. d! J* ?' Q( F( z
xMax = window.innerWidth;
2 P" x/ y$ ]) B8 M3 q8 M* ]6 g2 v yMax = window.innerHeight;5 ^5 @, z. H- ^* h" o
contentWidth=document.supertext.document.width! G9 l9 |. ?9 w
contentHeight=document.supertext.document.height
+ W' g+ U/ k) J/ A/ K- z& z: t3 i7 Z document.layers["supertext"].visibility = "show";
. Y( S o0 V2 k% C }& I, ?0 N- [6 m
setTimeout('moveBall()',400);
1 H5 d* g' @( X* A( t8 Y" l if (hidetimer!='')
# t- t1 [. e& e/ g setTimeout("hidetext()",hidetimer)
5 h* _) ]9 p4 d/ u7 E- } }
3 d: t4 y& ]$ c; c9 g( P, D3 R# T5 }
function moveBall() {
- L& j7 K h& `7 ?% T' _4 n if (superballRunning == true) {
0 U; o0 l+ O: W# O7 ^& ?; s* r/ F& U calculatePosition();3 C d S2 Q6 Y8 o1 K$ B
if (document.all) {& K6 E# b& O9 n6 D
document.all("supertext").style.left = xPos + document.body.scrollLeft;0 I; ~# o* x9 \. P5 r" u
document.all("supertext").style.top = yPos + document.body.scrollTop;
$ \# x/ C# @9 I. c, R& ]9 v, X$ z }: s: ]. f& {7 M J/ n- f
else if (document.layers) {
3 y5 Z2 R! @ _ document.layers["supertext"].left = xPos + pageXOffset;6 V3 s5 ?' o/ r. b1 f- N" Z3 @7 R
document.layers["supertext"].top = yPos + pageYOffset;
( W" T* W& H2 ?# X1 ~ }
1 Z2 v, e9 L- k0 I animatetext=setTimeout('moveBall()',20);! z# P6 K0 ~4 ]0 S/ n% u3 @
}1 ]$ J2 a3 M! w$ L0 g1 g
}. K6 P' c1 T- Q$ X! m
" t# J: U& n8 o, J. W5 ~function calculatePosition() {
% C/ u( g- C2 A" ]6 P) q if (xDir == "right") {: t1 ?3 I d5 f% j
if (xPos > (xMax - contentWidth - BallSpeed)) {
. p7 S$ h7 W- Q q xDir = "left";5 E d- o% b6 \ m" W( l) _
}
2 O' q+ {: P' ` }, u6 W, X& v- f6 ^; I6 Z% B& @
else if (xDir == "left") {
- A6 m Y# e' v2 q if (xPos < (0 + BallSpeed)) {0 f7 ~( S0 a% @! G( @3 L% a
xDir = "right";9 l9 b# V/ d1 P( A6 }& r
}; p. n) L. x& n T1 |' U2 |
}$ H, }% b0 E( f! E! F8 t/ K; d: O
if (yDir == "down") {
" H1 f) h0 J w" l# W if (yPos > (yMax - contentHeight - BallSpeed)) {
. y. @0 S5 V* C+ ~$ S# Q yDir = "up";
+ f5 p3 t2 o$ C Q) b }
& t+ z+ q( X% j0 m4 \0 X; T }
( [7 ]8 l1 q6 T. g" } else if (yDir == "up") {
4 F. o+ v( b9 P if (yPos < (0 + BallSpeed)) {2 x6 F7 K! M- q7 \1 |- \6 q( f
yDir = "down";
. C, ^3 X3 C5 u! G9 l }+ ?7 o5 m, a0 J& D; b) j% \
}8 N8 s$ N' m/ k7 \* B" l4 w
if (xDir == "right") {) Q+ d1 ?- Y3 K. \2 e- C, n( [
xPos = xPos + BallSpeed;
4 w# [) ^% e$ N7 l8 b! N0 x1 | }1 I( s: P( K/ e, N% N- `; g
else if (xDir == "left") {
7 x$ x/ l) z, A9 P xPos = xPos - BallSpeed;6 z, W- B, ], |' K |$ ^3 L
}. _1 \3 B5 ]1 p; v( k# o
else {$ u; F3 V. w& u) J' ~- M( E
xPos = xPos;6 M) g3 o+ A$ z6 T
}
! m7 `- [' V4 Z( H7 o if (yDir == "down") {5 [% k1 \+ s/ m1 L: ?; w
yPos = yPos + BallSpeed; |# j b4 L2 c3 v7 v" {
}( s; U+ B+ P' d, ^- d# T! I* j) s
else if (yDir == "up") {, q( J; `! W0 d) k! i6 `
yPos = yPos - BallSpeed;
8 u$ w! x1 h$ R/ S }
: b! B2 S2 A5 \1 R0 c' h else {
# z% Y5 c2 v6 Z# }! m- d yPos = yPos;3 B2 t* o: L, a5 E9 o; y
}
- p; y. k8 q: P) X, ?; N }( C; n3 _. ~+ u* S; t
5 \! w# e' E# o+ ?0 P$ Ffunction hidetext(){6 U8 \6 ~5 L) F9 h
if (document.all)
, V6 b. a) y) z9 osupertext.style.visibility="hidden"
* n+ A# C8 d& n' Kelse if (document.layers)
; D' G4 }6 ?3 M/ A1 u0 fdocument.supertext.visibility="hide"
6 \7 A3 c9 v/ zclearTimeout(animatetext)# m% R2 o) ~$ g- L
}1 l! r8 \! h. q
7 c# j# d. t. F$ A* A5 ` Dif (document.all||document.layers){- |6 I# r' `% Q. `% X. N& d
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
+ n; G5 O- H# l% C* Gwindow.onload = initializeBall;
r4 H9 U6 `! d0 l5 twindow.onresize = new Function("window.location.reload()");
$ S. Z% M3 k( x" @}
* m3 C* }6 R) Z( E6 i$ V" K8 ~9 Y2 I
</script> |
|