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

|
网页之不断弹射的文字-特效
<style type="text/css">
( @6 D! x ^* b+ R9 I#supertext {
! u! {, _* d' E1 r6 o/ |7 zposition:absolute;' c& M$ Q% V0 E1 ?4 s& G9 s
left:0;6 u0 a/ n- L4 ?+ R8 F4 D
top:0;: F# S. S1 _+ m1 {5 J3 \5 v2 G4 t# D4 B% q
visibility:hide;* j% v2 y; q8 o9 _. {
visibility:hidden;
( A/ r3 R; a% @& h8 j7 Y. E' i}8 {% w+ H5 A" n8 l& z q
</style>
+ k) B% s( K# l. _* _1 m<script language="JavaScript1.2">, S" Y3 U+ M [( ?( C
<!-- 改变下的字体的大小。颜色-->
5 u- O3 M' J) Zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'0 m, |+ D Y# ^/ v# s; q
var hidetimer='';
% B$ y7 q# ?: g<!-- 改变下的弹跳速度-->! A( D3 L9 R2 L( {) A( [( t; Z5 R# Z( H
var BallSpeed = 20;+ P/ k' j' \$ Z" T1 M( q7 _! U
var contentWidth;
; Q& y1 v' e/ K5 ?var contentHeight;
. O, l2 C# J4 f3 P2 a! svar maxBallSpeed = 50;
' w# N0 J. B6 q& o: l2 r# y; X% e9 M7 G& i- Z
) v& @& K) C+ v: ^' a
var xMax;
( _; D+ \6 c/ n( |, P) l/ `0 U+ ~8 \0 F6 Uvar yMax;! L( I6 M1 z6 Y5 C, Y
var xPos = 0; e6 @% c8 A$ `1 b3 @/ P) f
var yPos = 0;
/ k) T8 F" B0 j, P6 h4 h, lvar xDir = 'right';
$ {& H1 t) Y" s8 Ivar yDir = 'down';
% n) b* e, T2 l2 Q; `4 t$ Evar superballRunning = true;$ B0 K; I% e T1 Y Z. c+ U9 {
var tempBallSpeed;! K2 {: ~8 m3 g5 T5 z, _
var currentBallSrc;
* m& ^1 z) Q3 i/ zvar newXDir;2 ^* t2 D& O! K, U* m9 b6 G
var newYDir;, X' J5 k7 l* K7 ~7 m
" R0 Y& r8 A# h+ \
function initializeBall() {
! E9 J" u) X* l6 }8 u# |! u if (document.all) {3 j, _& v5 l# y6 F8 I
xMax = document.body.clientWidth$ P H0 n% p2 T, r% @% x& M
yMax = document.body.clientHeight
+ r J* [* P, |+ I( T. j$ h( Z document.all("supertext").style.visibility = "visible";, a& g6 S- o- H% H' N( w6 m# K
contentWidth=supertext.offsetWidth
+ ]8 k2 _* F$ ^, | contentHeight=supertext.offsetHeight. F& n1 o2 N3 p r
}- m0 _; l7 x' b* k
else if (document.layers) {8 h. Q- z" d8 @, y$ p* U* Z' N) }
xMax = window.innerWidth;5 E) A2 j& l9 i# h/ t
yMax = window.innerHeight;2 x" r" P% e/ N, N& o
contentWidth=document.supertext.document.width
" z2 I# E2 `; u2 K! h1 n/ e' p contentHeight=document.supertext.document.height
# g0 @6 T+ ?- B0 ? document.layers["supertext"].visibility = "show";
3 K/ D! d/ Y2 V4 V' \& f1 w9 v }& M/ B7 J" o7 s6 a
setTimeout('moveBall()',400);1 w9 x# {: W/ ^& M) D# f0 s
if (hidetimer!=''): `& l3 |4 G2 J* s& S
setTimeout("hidetext()",hidetimer)
& L& v% K& f) T- f) X }! n* t! n4 s, n
5 H6 C! X) O% kfunction moveBall() {6 F) A( p/ I6 k- I9 c5 s
if (superballRunning == true) {' e. L) w; |& ?( X( g
calculatePosition();; i, |, s6 X4 x3 c; ~! p" o
if (document.all) {
5 q& x* L$ J: N8 c. Q document.all("supertext").style.left = xPos + document.body.scrollLeft;/ _8 T7 x+ `. b4 T
document.all("supertext").style.top = yPos + document.body.scrollTop;
7 @) k; H' C" h }7 r% ~+ C- ]7 w4 ]3 e* H: D
else if (document.layers) {
" H% ]" v4 }+ | q/ Y6 a document.layers["supertext"].left = xPos + pageXOffset;$ I6 K" K0 p6 n# b$ D, I* N
document.layers["supertext"].top = yPos + pageYOffset;
. ~, @9 g+ x& h8 k }
4 H" b; f: Y/ m* [ animatetext=setTimeout('moveBall()',20);
8 S' N' \* h/ u0 T& E8 C% K }
) w7 X7 C$ z- p }
/ t- r, ?. J/ p8 _* P. T& C6 }7 p9 I) ~$ R# N
function calculatePosition() {3 S T( d) s. o1 ~) w
if (xDir == "right") {1 T2 t/ [+ {' a! O/ c' w
if (xPos > (xMax - contentWidth - BallSpeed)) {
4 D0 T4 Z& S; x+ X# G xDir = "left";
3 G- H+ x8 u$ {2 z, k }! i q( c/ \% ~, [. @0 F
}2 T, Q! O% }( @; b$ _! Q: l3 g. n
else if (xDir == "left") {, n$ _3 U# l8 e% k4 M
if (xPos < (0 + BallSpeed)) {6 k. l/ L- _" k l! \
xDir = "right";
9 A) ]6 c6 z$ L5 y6 y' ~% y }5 [- b1 ^: ]4 E6 c! ^% G
}* J# S5 _0 l5 k0 p* g. a y
if (yDir == "down") {
* {" g4 k( G# c if (yPos > (yMax - contentHeight - BallSpeed)) {
7 a+ B9 I+ c \* h yDir = "up";: @4 Z# L/ M" T+ E, i3 M! Q
}
, w5 _& B. u# N( U3 _5 A8 e' K7 p }
: h. P s+ V$ E! u& a0 z2 X else if (yDir == "up") {5 p! J) ]4 L6 l
if (yPos < (0 + BallSpeed)) {
# I! H* U. _1 ~; f7 Y8 q yDir = "down";
9 h" l% p% \6 `' _2 C& D3 } }' b$ k3 o% ^; U) _1 H
}
0 B$ l! Z, v% j) I6 w. H if (xDir == "right") {. L y4 y/ a2 \
xPos = xPos + BallSpeed;
" Y" C5 g* b) H8 x7 O* F }+ F) O( ]5 S+ w$ I( h {" @0 B
else if (xDir == "left") {* ]( h6 [' i. z0 B% e
xPos = xPos - BallSpeed;
9 [1 D! A s* w# T# Z; O V }6 r8 p- T8 N+ l, z( @# O8 I; S: D
else {) ]9 Y2 d* D l5 [
xPos = xPos;
* s2 Z( L3 B+ Q5 v' i }: k0 v7 h% Z+ F" p7 J2 F8 l
if (yDir == "down") {6 W% P- I, R* \ z
yPos = yPos + BallSpeed;
9 X$ c% C/ j2 J: K8 w u" ^ }, f: U1 v7 c$ m! X$ ^6 z0 H
else if (yDir == "up") {
' A4 d4 o% a; X C. t yPos = yPos - BallSpeed;
1 t: a) t; k# w J8 J" m }/ r# d3 }+ A" V% R! I& L
else {
* l. a3 p( f( L; v+ Z9 u; k yPos = yPos;
8 i( |# C0 V/ t# @+ t. \ }
5 B& I. h# [/ E4 d }
) d- \) r" c" j# R! h9 |! \) d- G, A" n& P
function hidetext(){% U! Q" W* I0 M' k4 v
if (document.all)
5 E q: G: t1 @( X2 rsupertext.style.visibility="hidden"
/ ]5 V: Y) e6 I T- L; h3 Pelse if (document.layers)( W. L/ v' G8 z; K/ U* w1 _
document.supertext.visibility="hide"
4 f* B7 R$ k8 A0 S8 H# eclearTimeout(animatetext)! |3 u% O8 K) ^1 o+ L
}
! _. r( Q" F. D0 E0 O0 j8 P
2 t, K& o3 d3 y# \if (document.all||document.layers){; k; G2 k+ B! ?4 r8 s' I/ t) n0 K
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
& V: f4 q" a* Q' u" b* C* kwindow.onload = initializeBall;% |9 ^- l- m2 l& t2 [; t! ^
window.onresize = new Function("window.location.reload()");1 J2 B8 T8 K! j
}( f7 ^! J& d V7 \- _% _2 ]* k
; k5 |- e, P# R6 z6 y% a" A ~) _
</script> |
|