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

|
网页之不断弹射的文字-特效
<style type="text/css">3 F, ] B. i+ j/ c" w
#supertext {
0 r! ]; q6 }3 c1 r |position:absolute;5 i5 l3 B& ^/ g; W( a$ F# P
left:0;0 _; Z" B- Q0 J+ w0 Q- R7 R: X
top:0;
- V D# B/ T0 A; Z gvisibility:hide;
# e6 {. k& M) K/ {6 T6 O! zvisibility:hidden;
7 O' P* l# a' h" }}% A B0 V. Y$ u7 d9 ?
</style>( o- B; t' ? V) o1 o! w
<script language="JavaScript1.2">6 L$ S, d" ]0 m8 E6 C* L ?
<!-- 改变下的字体的大小。颜色-->, ?' n7 z1 @! T. M N- |8 q
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'( f7 J/ }6 e2 J
var hidetimer='';1 E& ]; S+ d2 o7 Q& z9 C
<!-- 改变下的弹跳速度-->
' d5 V. K" ^! ]# V; kvar BallSpeed = 20;
1 F; p; d0 v, W& V8 U5 Y# p l) r! {var contentWidth;
) A: R6 d4 A! I' T! g# ]var contentHeight;
- K+ K3 S. u0 t `" T5 P1 Mvar maxBallSpeed = 50;
7 P9 J' \! v. m9 i6 ~
; w9 Z0 w9 }; u2 m1 v4 j6 P* o6 |( a. f
var xMax;
% A; C2 N! [8 V8 H- B& ^8 uvar yMax;
% c1 \$ S/ i& D9 x' @var xPos = 0;, V+ W6 D' m" }$ y1 P* a
var yPos = 0;* A, l$ O: c- K. I- G. t
var xDir = 'right';1 a5 ~6 @* m% g3 H% |! M+ y- Y
var yDir = 'down';
4 X2 i2 j# L( w" y6 U1 M7 qvar superballRunning = true;
+ E2 V2 d6 p* d; ivar tempBallSpeed;. O+ i8 b% T8 Q- C
var currentBallSrc;2 O/ \+ F4 V5 k1 G* \9 E" E
var newXDir;
. [4 [$ U& X3 W9 h5 a. Y$ L! Lvar newYDir;
- K: Z k6 A3 I4 W2 o" M0 Q
5 O8 {& v# e+ F5 T2 wfunction initializeBall() {$ m, g$ I$ h& W7 f) c& y
if (document.all) {
: t: A/ l- w1 v7 ]! S4 Q; v# w& a. B xMax = document.body.clientWidth
" o* X4 f7 Z. F2 L, n5 o yMax = document.body.clientHeight$ n& e' d8 X% r- g" l1 J3 |
document.all("supertext").style.visibility = "visible";
0 @# Q5 j# c! x' Q. E contentWidth=supertext.offsetWidth
' |( a/ f5 O" ?9 A1 {8 d contentHeight=supertext.offsetHeight
: v' q8 j) c0 r0 h' u5 M }. O& ?3 Y" J3 B b
else if (document.layers) {2 f' ~* D) j$ g3 W3 D7 ^! A
xMax = window.innerWidth;! `. r7 n5 N( }; i, C
yMax = window.innerHeight;1 C- E+ Y) D" n, k! r# | C9 v
contentWidth=document.supertext.document.width' E' O) | Y0 U5 Q; X. {4 e$ E
contentHeight=document.supertext.document.height' N" {7 `6 U1 m" z
document.layers["supertext"].visibility = "show";7 N `1 k; l2 \5 l) \6 A. O
}) X8 P* |# I! s" f7 K: ^
setTimeout('moveBall()',400);
4 H# q4 O; f) M" S if (hidetimer!='')
" x1 [" S, i& o( G setTimeout("hidetext()",hidetimer)
9 x& ~% v, M* K9 V9 c) l9 V; Q }$ l$ I% c' n2 O4 A5 ~ N' {
2 F3 |" K( x# l7 Xfunction moveBall() {
1 S5 ~; q$ H, h& y, Y if (superballRunning == true) {
) ~& b/ a) V; ^: W9 e" O; E: j calculatePosition();
# C( e, R8 J7 J6 k/ n' E( T if (document.all) {
f# {: F& a' F3 u: C; w document.all("supertext").style.left = xPos + document.body.scrollLeft;
7 q7 y6 M/ S& h* B6 U& ^: B document.all("supertext").style.top = yPos + document.body.scrollTop;
: e1 U9 {" _" y0 D1 A! m4 g }
2 u2 W* O6 n" A else if (document.layers) {
' G2 C1 @7 }' r U0 a3 V document.layers["supertext"].left = xPos + pageXOffset;3 k1 \; U; `1 \" y1 W( d$ n
document.layers["supertext"].top = yPos + pageYOffset;
4 U t# d1 ]5 M& J) U5 x }
; }! }! Q3 ~" D7 l, r6 @) B1 K, c animatetext=setTimeout('moveBall()',20);
1 n, p d( N0 j6 @ @! u }" V3 }7 {+ o! f4 v" l$ \
}. p- ]9 X) i# M; g' h
4 x0 x& x* C) G: V+ w8 e( q) Ffunction calculatePosition() {
# d, [2 p( A9 M- f4 J: }! \ if (xDir == "right") {
A. {4 }- f% W G% @& h @ if (xPos > (xMax - contentWidth - BallSpeed)) {8 s x9 ^! k" l
xDir = "left";
4 `! q6 y2 a& d }, c6 D1 V$ @: \' e d9 {- |
}
& p3 K3 g: g# O6 U; C1 M else if (xDir == "left") {0 z) g6 `: s, X4 s R+ F2 E" `" u
if (xPos < (0 + BallSpeed)) {1 r$ H( H V/ ?5 V. @% ^
xDir = "right";
3 R$ d8 E* q0 S5 y' r4 S }
3 ?6 J6 r" N* P; d }1 C4 @( `% j, \; i0 b* v- y" a
if (yDir == "down") {: q# T. p6 w3 R& Q6 S
if (yPos > (yMax - contentHeight - BallSpeed)) {; m7 z+ f8 [ y! l% P) ^
yDir = "up";1 [2 N0 r5 s, O* U) G M
}1 _2 [( E/ P# X! d* Z; d: X
}) l F! I9 X3 ?+ ?# I# V+ r
else if (yDir == "up") {
/ h5 R4 Q( g; r6 i# S) @ M, J. E1 m if (yPos < (0 + BallSpeed)) {! M* w b W# l( M5 D% P
yDir = "down";' g4 g; k. i3 V/ T4 f
}
: E `# ~" \& N" O: S& C" b }, H4 a3 F3 q9 H# W# g( N. y9 H: w
if (xDir == "right") {
; ~- h! V& o, G( ~% b2 T2 r xPos = xPos + BallSpeed;
R' i h4 g: T# `% L# a% u }+ Y" \* Z7 f- P9 m+ Q& h7 u9 H
else if (xDir == "left") {
0 \! S- w& ?- P& b* J! I7 c8 \ xPos = xPos - BallSpeed;
" J4 A0 R/ @. l }' x8 d2 w- J6 _
else {
& I5 e5 d" M0 O, r8 B, m0 J xPos = xPos;/ K' P& A9 l' f
}
: q. @% {: i+ \3 a7 u' k8 E7 u if (yDir == "down") {
- d) a4 s" T; y: u: u yPos = yPos + BallSpeed;
# G- z2 \1 F' b' h5 V4 e$ w/ O8 b, o }/ P2 Z9 P. s2 P. P; x$ A
else if (yDir == "up") {
1 X. g' y7 D7 p9 R* H yPos = yPos - BallSpeed;+ c& j, n. ]" I
}
1 H" f6 H2 H1 Q, A4 I8 b" R5 z else {
$ H' s+ F/ O, }/ F yPos = yPos;, j; w( L+ K5 B' G# y3 V% N* I
}
8 O# U6 v! D0 K. p; a0 ? }" f+ l4 Z4 `6 w8 X( i! y
! U' e+ K6 U+ ]. O* T6 C, D! Qfunction hidetext(){
; B: U0 B7 B5 R r" O" {$ ^ ~% j- jif (document.all)
l$ @. v5 S$ O7 Osupertext.style.visibility="hidden"2 |+ l: y0 M1 M# X. s
else if (document.layers)
. P8 I+ n! w- f* S# M, zdocument.supertext.visibility="hide"3 H7 W- H8 Q4 ]: P9 K! G- F
clearTimeout(animatetext)
/ Z) V. W6 ?' o7 z}' p3 z: x! F' r
2 V; j, `7 f% T X, c, |
if (document.all||document.layers){
$ |# \6 V) J n( K3 O5 t! Ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& z: ^# O9 u* Q5 c2 t0 }
window.onload = initializeBall;) D! ]! c6 o& P. p; ]3 `
window.onresize = new Function("window.location.reload()");
/ @4 }4 g4 G- m}
0 d# D" P3 i5 A4 k+ c5 p
/ d- N. X. f" r% _/ j# W4 ~: G2 D</script> |
|