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

|
网页之不断弹射的文字-特效
<style type="text/css">: }0 R9 `) ]& {& ]1 D
#supertext {
, {/ u ~2 }3 M t, h0 k7 ^8 bposition:absolute;/ z V- Y+ H' V$ M4 ^
left:0;. E+ E) |$ k: M$ l+ {
top:0;8 ?! D6 f* M5 ` L
visibility:hide;* {' ~4 K3 f* \( J
visibility:hidden;" d( @0 x% w4 [+ ?8 ]7 k
}) W$ A$ R5 A9 y' ] d a. S! z `% F
</style>
7 Q" H$ T& x6 w% V/ Q _<script language="JavaScript1.2">, M: L1 e" `+ W3 L' p: \1 T. O
<!-- 改变下的字体的大小。颜色-->
9 ^. W' q$ u' |. H) C" w& Mvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': }; i: L! C! L& \; S. D. o: E, H
var hidetimer='';
$ |0 M; j8 J8 ~ G, G" s<!-- 改变下的弹跳速度-->
7 C& Z& D& f( [& N9 c# \- n. Bvar BallSpeed = 20;
5 F9 @% s L1 }$ Wvar contentWidth;5 r" i+ Q8 H1 W) \" ~
var contentHeight;0 s4 \4 w# i7 n5 V3 r
var maxBallSpeed = 50;
) f0 t( M: k5 I) R
& Y9 U! q! \6 w( f
5 A5 b% P. g: h' }8 F( kvar xMax;! I" Y0 Y" t/ l' h2 \$ h- s4 Z
var yMax;
- \7 N- `( s2 x4 v. C! A+ H) J% H Fvar xPos = 0;% e+ _" c) W. q3 B) M# A- d6 t' G
var yPos = 0;0 Y, c, X- ^3 ~2 }9 w/ g
var xDir = 'right';
& x" x4 a; J$ r' y$ h2 U; I; dvar yDir = 'down';
! Q% }( R/ P$ H& b% Ivar superballRunning = true;
; n2 }+ X7 b8 F% T0 i/ [: ovar tempBallSpeed;
2 b! |$ G8 s9 V6 `; _" [# Cvar currentBallSrc;: i( O0 g4 P0 `- S
var newXDir;
7 G8 u+ P+ Y4 o: f3 gvar newYDir;
4 l: C8 R7 ^7 Q) B$ P& U
# J7 ?" S5 w- I# Q, [2 C, }; Yfunction initializeBall() {
; Z( }) I/ E2 G if (document.all) {
. l6 |7 {3 ?6 P5 H xMax = document.body.clientWidth
4 u$ c+ e4 P3 G$ y yMax = document.body.clientHeight
0 l3 D; |& A7 I) e# S/ x) N document.all("supertext").style.visibility = "visible";
2 L# x# \* v7 k8 l! O! R% L- m contentWidth=supertext.offsetWidth1 t" S. \% M7 N
contentHeight=supertext.offsetHeight% H0 x! `% ?2 v1 O5 M; G
}
" O* e7 r! M# f+ e1 c. _1 W) } else if (document.layers) {2 l) l3 g2 B7 @: d' }* M! A9 z' s; K
xMax = window.innerWidth;( z' c0 n% T+ l1 R, \- @* H" Q
yMax = window.innerHeight;* p0 o" c( O5 q% r
contentWidth=document.supertext.document.width. B2 U& |5 z$ R2 p6 A
contentHeight=document.supertext.document.height
. w+ w& E1 M# m+ R2 d* f# r, | document.layers["supertext"].visibility = "show";5 ^) B, F+ z* D5 Z, f
}
# Q& H8 h- U3 x* T) v- f$ ?/ k setTimeout('moveBall()',400);) D2 ~, v c" R* U h
if (hidetimer!='')
! p' G9 X- q, M' i$ T" a8 O6 P setTimeout("hidetext()",hidetimer)
) m; J& [$ Z9 L G# `3 V }: {9 c7 i+ l) a
1 b+ d; ]3 j! O$ ~% |& V2 J) cfunction moveBall() {& M1 b$ {. o5 k0 Z5 V; o8 ~* Q4 o, i
if (superballRunning == true) {
3 B6 e1 Z1 r5 y1 ` ]- c calculatePosition();- B; a! X( `/ D6 u
if (document.all) {# i3 }% e3 |3 N+ I8 B0 w
document.all("supertext").style.left = xPos + document.body.scrollLeft;" V* \# s/ d0 e! w
document.all("supertext").style.top = yPos + document.body.scrollTop;
: g- I( i- D8 R! }% \5 M }
, j+ N1 @: M6 s+ \! M2 @ else if (document.layers) {
2 V/ U# C( Q# f5 u- c& o document.layers["supertext"].left = xPos + pageXOffset;$ {. o6 b# p+ x; H* }$ @ V
document.layers["supertext"].top = yPos + pageYOffset;. \7 e; ]2 S$ M
}/ W$ [0 h, l$ P' T% M k: H2 Y
animatetext=setTimeout('moveBall()',20);
6 p( p) A. I6 W! m }' I$ S) j! y1 W# f1 V* t
}
" f3 B J$ J( P) B! |
5 {: v6 ^( B" N' s kfunction calculatePosition() {! R( g0 s: o* P2 C
if (xDir == "right") {( ^3 f% H d7 v5 R- N7 K# f
if (xPos > (xMax - contentWidth - BallSpeed)) {
/ h" ^& v6 D, z2 g5 x: W xDir = "left";7 @. L( h. P( u; u; i2 w2 B& ^
}
! L- D, M9 _: y A( \ }7 w3 F1 R% v, g; @3 B: n
else if (xDir == "left") {
( [, j4 y6 t7 h7 ?) _: ]+ I if (xPos < (0 + BallSpeed)) {
2 A9 V" s1 _7 E! l xDir = "right";( x$ ?6 P# J5 u; k0 ^) ~
}
0 @" U- X" f' m) q }3 \7 \! b% A8 T" \3 ^
if (yDir == "down") {$ ^1 t: g; q0 _! a3 J2 [6 Y4 U2 I5 H
if (yPos > (yMax - contentHeight - BallSpeed)) {
' S) W3 r8 g% U- o. C3 S yDir = "up";
1 ^' x: X, B# @( g3 X& q% _& O }
! x$ j( X, m* P& x$ [ }
) C, q6 W7 T* v6 } else if (yDir == "up") {
+ E8 R' ^9 Y" z s1 ?# U if (yPos < (0 + BallSpeed)) {+ B- I6 W$ I* V% w, }
yDir = "down";
% `( c+ T% ~5 @) i/ }% F }
% }( g/ S' P. j. H+ R$ Y8 S" @ }
* N0 _ B% T, I; O* W* t if (xDir == "right") {0 s6 x! |) W1 V+ U) K% J/ E
xPos = xPos + BallSpeed;
$ r0 A* \% h- J5 P }9 N* @1 T* t; ~ h8 k2 \2 m J( G
else if (xDir == "left") {* u% k) ~* u4 r8 B. `5 h
xPos = xPos - BallSpeed;
3 H: [/ p P% ?! }* \5 x- j }. I! e/ U- j. q
else {% _. ]1 W: v: o6 _; W) k7 g- S+ V6 V
xPos = xPos;
' ~$ X* g0 }. o4 Y }
/ W& c" Q* F q' ^! c, P- z if (yDir == "down") {- g2 G! _4 M( ~5 e' ^+ {8 @
yPos = yPos + BallSpeed;
0 J: M l' X* H: F }
" Y4 v# g4 I: H else if (yDir == "up") {8 g' E/ w/ S) y) H! [0 W+ ]6 A
yPos = yPos - BallSpeed;8 m7 i% F& [( k: T0 e* l4 `
}
! u% S3 ], y# o: R2 J2 r% a2 h else {) t$ ~- a4 }1 y1 }: M% u
yPos = yPos;6 @9 V# q/ n& U5 {
}
+ v7 h, ^& _ ]5 ~, U" {7 | }3 E3 ^4 v4 t, Q; d/ X! D# z
, _2 z" q5 ~8 U' B3 P
function hidetext(){3 ]5 [" `, M( ^' `
if (document.all)3 [6 r! h8 @+ d: X' b9 [/ ?2 |0 v
supertext.style.visibility="hidden": w ~( }. H; y7 D0 N" w
else if (document.layers)6 y+ ^0 P* l/ C
document.supertext.visibility="hide"
$ N8 K! F5 | ]+ e k# HclearTimeout(animatetext)
$ M# [1 |3 D0 c, U8 P}- K: W6 ~$ _6 I$ ]' v5 V' \
+ l2 b; Z5 Q1 T% O
if (document.all||document.layers){
0 O$ n e! y: }* v" D' ~document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ b# B6 z3 {4 ]3 z. i9 h) J& J
window.onload = initializeBall;; s& x/ Y2 w* b `- Z' G: Q2 n& [# I0 ~
window.onresize = new Function("window.location.reload()");+ M) E9 ^# c4 C. @' i. p/ T) e
}3 y* M B9 F, e9 d
6 B. t# i! w4 }7 E</script> |
|