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

|
网页之不断弹射的文字-特效
<style type="text/css">
. n) s- a8 P+ ^) ^$ v0 G( K: ^! x#supertext {4 N; j1 ~. y& z$ [0 U3 {- t% u
position:absolute;
. h2 e2 `4 E1 s6 l) q+ H/ sleft:0;
f/ M3 T; i" ~! q+ ^2 B& c- }top:0;- E b, N# @4 T) C
visibility:hide;0 B2 k% \$ q- d% t
visibility:hidden;
+ e7 \, z( I5 g3 k) X}
' ]/ Y* @0 S6 r</style>
8 i' j* B: e* F1 m' |! ?<script language="JavaScript1.2">. ~1 f* q9 _/ x7 R8 C
<!-- 改变下的字体的大小。颜色-->
5 Y" z; `/ {- q* Uvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': l- V$ Y$ x5 ^( {: h6 d/ d( a p
var hidetimer='';& Z" Q3 T C) ^$ s/ Y" D
<!-- 改变下的弹跳速度-->
! A1 T# ^/ r! b4 W% r# _, Pvar BallSpeed = 20;
$ K# G3 H( Y! Q! w! [# dvar contentWidth;
: m1 h- ? k9 j) ?: g' h% kvar contentHeight;3 a9 e) X- h% O3 K) B
var maxBallSpeed = 50; c$ n- {& m) t9 Z
) ?9 M8 _2 t; e! E7 F
6 ~4 X. a) R, T1 avar xMax;) b+ H t. q( |/ j
var yMax;
1 B) `" V% E' T F6 M, [0 R- d L" _var xPos = 0;, T/ q, v# Q5 `$ ?) ^: G/ i
var yPos = 0;
1 Y, O: S, M9 U# }% @var xDir = 'right';" I; t- b6 B& Q
var yDir = 'down';3 Q, f7 d* ~# D0 x% i
var superballRunning = true;7 x7 {3 V- Y: U a
var tempBallSpeed;
0 I/ t( Y% m; R* m3 o5 i9 j$ [var currentBallSrc;
1 m9 D. |+ `+ ?) S. w. A, s6 `var newXDir;' i6 R: i5 m* h' s
var newYDir;/ V N, v R. o; ?7 C. g! a' h
- E' A k6 i4 w! n% M7 P/ v4 \- j/ F& ]function initializeBall() {/ s7 Y: P- ?7 p% z# D$ F! s# C
if (document.all) {4 }% [; c% y& E/ s" L; k' W
xMax = document.body.clientWidth$ t& C. D) A4 H0 p" O* I; |# h
yMax = document.body.clientHeight6 C8 M% d n% q) i
document.all("supertext").style.visibility = "visible";& f% Y$ Z: |0 D
contentWidth=supertext.offsetWidth+ C7 R, u. z5 V
contentHeight=supertext.offsetHeight' z+ l: q, q+ G; C5 E0 Z
}
* K* A: N0 }! d! Y8 C6 c& J else if (document.layers) {
+ V* {- f* S4 N$ f- g xMax = window.innerWidth;0 ^3 ~0 k; t6 Q* J/ L1 l: H) Z- R
yMax = window.innerHeight;
8 Z5 j! ^/ M3 k4 a3 d contentWidth=document.supertext.document.width% L2 b2 Z @( d, B( S# n8 _1 e
contentHeight=document.supertext.document.height8 Z4 W: r( g% K# @: x
document.layers["supertext"].visibility = "show";
! u+ ` T" _' S4 B }
5 d2 b$ J( o7 b Y6 v# i( k setTimeout('moveBall()',400);& b. ^0 Z2 ~* G' x! M0 H ^) A8 \
if (hidetimer!='')/ n; S2 b# P% F( ^* h6 V# b
setTimeout("hidetext()",hidetimer) I8 g( Q6 C# b
}! ~: y w7 Q S5 \( ~: a5 H6 _
; w6 n8 c; ~" I" K. S
function moveBall() {% u$ M$ c9 `4 X. F
if (superballRunning == true) {' k! ^! \0 c/ ?5 T: g! G! |$ N
calculatePosition();7 \3 ?- U) c4 V: s
if (document.all) {
7 p% }6 g( E- [) h& T document.all("supertext").style.left = xPos + document.body.scrollLeft;" R9 Z) r4 B. F# V4 h
document.all("supertext").style.top = yPos + document.body.scrollTop;
5 v4 z" ]- X! \# y, E& \! }& O }4 _! }3 N9 U1 W
else if (document.layers) {/ S+ ~0 C8 j2 r2 H3 w/ ^
document.layers["supertext"].left = xPos + pageXOffset;* N# [, {5 C7 N# a
document.layers["supertext"].top = yPos + pageYOffset;# F$ ^, x2 S4 A# _& u: E, r9 h: N
} `+ k! Y6 O i, M; ?
animatetext=setTimeout('moveBall()',20);- _( e. C8 b, \% u7 S0 \, X
}
7 |5 L; `6 [3 F6 L1 N }7 x3 d+ E) G6 b
/ O. V* S4 d+ n6 O
function calculatePosition() {3 R* A m1 W0 k& [& V9 h3 T6 H
if (xDir == "right") {0 s1 T: l7 D% v$ K
if (xPos > (xMax - contentWidth - BallSpeed)) {
1 H2 s T1 ~8 J# W xDir = "left";
% L( v+ I( [& I! y5 ` }
4 ~( a& m& U! d9 h- N }
. N! X- c7 I9 X( }" k; G. _ else if (xDir == "left") {9 {8 L: e _- C1 _/ j: l) G
if (xPos < (0 + BallSpeed)) {
/ w5 s4 x) H) ]$ A3 F! G xDir = "right";
?& k& l9 S c. U/ T# O }5 B, i& U, e; O" B
}
2 w8 Z+ Q5 l" {& U if (yDir == "down") {* h6 o/ {; W5 Y# x- }
if (yPos > (yMax - contentHeight - BallSpeed)) {
+ r, O) K7 M, v- N3 u yDir = "up";
$ |0 m0 z( t9 @$ W }
/ k* E& Y* T2 Y p }
@- g' a4 c9 B: t$ ^" P$ Y" H else if (yDir == "up") {
8 c; [# P* k4 k3 G5 k if (yPos < (0 + BallSpeed)) {
' z$ y3 P o# D4 g yDir = "down";& K6 B7 W2 j2 l# y0 \8 @3 M
}
* _' \1 y- \2 s }
, T; X, k* v2 b& P if (xDir == "right") {: W; p" b4 G1 y5 {
xPos = xPos + BallSpeed;
( U8 `) q5 x+ m1 M" S( ?* h }! ]# ~8 p7 y& |' Z8 c
else if (xDir == "left") {( p2 p" x) O8 i! x, D
xPos = xPos - BallSpeed;+ S! Y6 R7 P# n, m
}# L" d; }' U" H# K' m
else {
) z+ Z3 e. K& R4 m. @6 G xPos = xPos;4 ~4 g3 z- a# b: \ n& @6 S U
}
5 D% Z, b. F2 x if (yDir == "down") {9 U2 u# I7 b: p5 U$ A+ M R8 {1 T
yPos = yPos + BallSpeed;
$ x3 j6 V6 S7 k7 C* T- x, d+ | }9 [4 A# I8 i9 `# U2 T* G. J/ M
else if (yDir == "up") {5 X7 q9 V i* y, h. ]
yPos = yPos - BallSpeed;
# L/ h( @& b9 F, m5 E% C }5 e" X- j4 e1 b# |6 d) r
else {( Z2 b ]5 z/ }
yPos = yPos;
! N$ p9 Q v% B, c* h3 H; B7 q! } }
2 g1 f7 w {" j5 J" K }
& _$ `+ v8 H# q6 A7 h
0 s4 z" K% B/ M5 K' \function hidetext(){. P1 C- N/ O ], `$ N
if (document.all)
2 L+ F4 z" A$ k1 M2 R" w, Y3 ]supertext.style.visibility="hidden"
( D* m7 c( s$ V; Uelse if (document.layers), U5 J0 p, D/ G1 G
document.supertext.visibility="hide"
" g) r# p+ T: S) `clearTimeout(animatetext)
1 Z# T" Z( V0 g: z}- |7 j5 i! ?( f& y" X
9 E$ |2 m% `0 u5 X1 e- x( D
if (document.all||document.layers){
8 w% D! x' V3 l2 ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
2 ~6 v m, u/ B% ]) Hwindow.onload = initializeBall;1 U3 t0 Z5 X# G g) ?8 l
window.onresize = new Function("window.location.reload()");% g0 _# Q7 ]! k1 C+ j2 E: }
}
* d* M6 M. y' f" x0 d6 ]* M: Y- L$ t4 h2 L. {
</script> |
|