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

|
网页之不断弹射的文字-特效
<style type="text/css"># u! {& g9 n" q
#supertext {1 R4 o0 u5 b( L8 ^' V# s' j, n- l
position:absolute;
7 o0 Y) ~( E4 D, Qleft:0;
7 g7 k8 y' G1 O" ?1 w" v2 f5 e$ ftop:0;
4 [7 V# i; F q7 T5 m* m3 cvisibility:hide;, s+ r. G. O: N0 ^. U; r) y. v6 ]
visibility:hidden;
7 J% ~6 f' t% I" |) k5 R' P}
- ?, p C8 y1 z/ C: p% e2 k6 T</style>
5 Y# V6 V0 _7 @& y$ V2 D% g<script language="JavaScript1.2">
5 ]3 j1 f* x! Q5 W1 j<!-- 改变下的字体的大小。颜色-->$ ], p4 l0 R6 @3 |1 m
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', I( F# t$ G" B9 q: Z2 T; _
var hidetimer='';
5 y. s) q$ ?0 G<!-- 改变下的弹跳速度-->$ K, _& x% J# a# B# u( l( i
var BallSpeed = 20;) O1 K9 b% G0 G1 l
var contentWidth;% | x, @" C L( N4 L4 c
var contentHeight;3 s/ J5 A4 F+ f$ y, {
var maxBallSpeed = 50;
- X+ l# A- V, e9 o- H. T8 I# T: ~# z4 e' G2 p! g
: E5 O W1 F4 e; S) Mvar xMax;+ K' z2 ?9 H8 z" j7 f6 A
var yMax;# a! Q# f1 r( T( q8 W; R
var xPos = 0;
: ?; X( D+ S6 q" @3 ]# k# h2 e+ J: _% wvar yPos = 0;
4 x1 b+ i: B( y' S$ n" S* g9 M9 zvar xDir = 'right';$ J4 m8 g( \4 N2 J; h
var yDir = 'down';0 P; _" l/ B1 O+ ^& R. e
var superballRunning = true;1 K8 a1 e) C2 x0 k i% ~' D
var tempBallSpeed;0 [& C- X, i- f; l) M5 B/ C8 g
var currentBallSrc;
% L. u6 r J. p3 @* p+ Wvar newXDir;
* ^! G% u5 c: xvar newYDir;
6 p5 t) l" s1 O, P
- g/ _5 L; Y. w, k4 ^. I* }function initializeBall() {
) j3 Y q* E y if (document.all) {
1 A+ T0 `( n8 D- V. Q1 ^ xMax = document.body.clientWidth! T4 f3 v% u0 M
yMax = document.body.clientHeight
& h! j6 y" i; l0 e2 l2 w document.all("supertext").style.visibility = "visible";* S, ~ Q6 d! r
contentWidth=supertext.offsetWidth- t9 z% s6 L1 e O5 x4 X
contentHeight=supertext.offsetHeight# m9 A; N2 X. A% ^3 o! s
}3 z7 x9 x9 n" [. y9 a* s
else if (document.layers) {. j# u9 \2 z b% J) z# r3 Z
xMax = window.innerWidth;$ \( p+ p; l: p
yMax = window.innerHeight;
% B+ M/ ]* |+ |7 F! n; N) c contentWidth=document.supertext.document.width1 q1 L! d+ {- R7 h0 {* R. o5 w: H
contentHeight=document.supertext.document.height5 U* X" m6 |8 A. k+ z
document.layers["supertext"].visibility = "show";
e6 U3 q8 p0 X7 P; c. K6 t$ R% _7 E }8 \ y C W `& Z: t, G# N* w' b
setTimeout('moveBall()',400);
3 I3 p. h" E5 ?( U0 r! V( L" n if (hidetimer!='')
/ I- U5 G5 K( N2 J. z setTimeout("hidetext()",hidetimer)
6 H' @" _0 M* Y& ~$ q }
}' D- b) k! ~5 o' _* f
, F4 Y7 Q. Q( s. s& |$ [4 u5 cfunction moveBall() {) d" ?( s2 O2 q) m6 i0 H7 P' U
if (superballRunning == true) {1 g1 [0 w# e. j- d5 c" J+ o1 q& K
calculatePosition();
$ G8 q1 h! e6 |% H8 E if (document.all) {
5 C) r% e7 f* k& Q- x document.all("supertext").style.left = xPos + document.body.scrollLeft;# d7 {( e, Q- _7 N, P) D- a. \3 i
document.all("supertext").style.top = yPos + document.body.scrollTop;
' `; H: K( P) p }
4 N$ q; V% x3 N8 Y: d( ? else if (document.layers) {$ F) T( I% k" G* D, P$ q
document.layers["supertext"].left = xPos + pageXOffset;
) @' ]% d. N/ h; y* v7 V document.layers["supertext"].top = yPos + pageYOffset;
0 V" i( g$ V" A( Z/ b5 j1 I( | }
( l' A$ A& [5 B+ V4 n animatetext=setTimeout('moveBall()',20);
9 q3 V( V" j2 i5 ]4 ]9 l }
& ]9 z/ J3 u: K* ]& l, ^( Z2 O }
% k/ Q* _4 F; |6 A6 |7 Q9 L; R9 h: F/ a% ?: ~
function calculatePosition() {
3 S1 B3 r4 V% t- L' C5 e: s% X if (xDir == "right") {
# N0 l* `+ p6 @' D if (xPos > (xMax - contentWidth - BallSpeed)) {
2 O: J3 D" l6 f/ U xDir = "left";
, S6 {+ j/ H/ l. N }% V& E( W! O4 u
}9 Q- N* A% u9 ~1 h# I' P- Z
else if (xDir == "left") {( g; \) {9 I1 @ g. Y" ]! {
if (xPos < (0 + BallSpeed)) {
( e) p* b8 K# m1 J8 b' e' W xDir = "right";+ O3 A- N: o5 G G8 U
}
8 r) D4 O. I% I f% _% z9 ? }
! e* C& @8 j0 R# n/ I: a if (yDir == "down") {
4 g, y6 o6 D/ C/ n0 q if (yPos > (yMax - contentHeight - BallSpeed)) {
: }2 S2 k- V( K, v yDir = "up";
( { s( Q$ \! ]# U4 W! i }4 ^# D) I3 W! s8 y/ Y; N; J- r& A
}
. r- F! ?$ S, Z9 e4 B else if (yDir == "up") {1 a7 q$ M1 S2 w6 r5 x
if (yPos < (0 + BallSpeed)) {
H: x" T B$ b+ ? d% D- t yDir = "down";3 F K$ }6 N+ \6 q
}2 C3 b. R, d2 G: Q; f" `( P
}& E5 w) T! m' x/ ^0 c1 A
if (xDir == "right") {
[/ ~6 H: [2 @, s+ e4 d4 m xPos = xPos + BallSpeed;
( i& N' K% ]) e7 E ]- F }" u) ~4 b- y. w
else if (xDir == "left") {/ s0 b" t9 k# R n d% h
xPos = xPos - BallSpeed;
^: E" h1 k, C V }
/ b0 k& c; o& ~# ^" f1 A0 ^2 e else {
) f3 M+ M1 V% W' m; | xPos = xPos;
% \/ O( T( @# B3 v; L% g }
$ k' q. ^9 K. G$ i# g+ a if (yDir == "down") {
% `' }' j+ W/ K7 o N0 y yPos = yPos + BallSpeed;
% T) @! ~ [' H r }! S, H9 V& B) h/ r0 Q/ e- }8 j
else if (yDir == "up") {; i' [7 z/ S, _+ c
yPos = yPos - BallSpeed;+ ?- F2 W4 y- z% _& U& z- _
}
, G# i2 _0 P% o+ e else {
& ~+ S7 K# O0 J2 w: E( D yPos = yPos;, H( U, z# [3 z7 v5 \8 u
}$ G' o% u* D+ J% o n
}
! m$ @' p+ r" ?( t8 a* X1 P! r6 Z5 H! b% e0 {
function hidetext(){
- f2 r, P7 {8 z! |. |2 W) y0 b" rif (document.all)
1 d2 T, S: k, S; p+ l: E2 v& vsupertext.style.visibility="hidden"1 j' ^( w) V/ ?. S" F4 k- O5 z
else if (document.layers)
" d8 |$ b6 j& o- C8 y1 ]document.supertext.visibility="hide"* _4 S/ C6 t' A( F: Y. q
clearTimeout(animatetext)
* M0 y- T( Q. ?" n4 {- {& W' ~}& _8 s3 C1 l/ p1 |# C% n6 \
& i, Q5 n W9 R+ ^- U9 j! O* kif (document.all||document.layers){1 n. h$ c, j: K% g
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 [# u+ e# X. f+ g" m# }5 n9 a2 iwindow.onload = initializeBall;8 h" O6 N0 Y: m
window.onresize = new Function("window.location.reload()");1 D7 @& a! c% L: ~9 ^/ V+ ]8 _1 K
}
) E+ r7 D0 G2 a- |* U; j# S
9 E9 `6 \3 U) X Z& `* h7 f</script> |
|