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

|
网页之不断弹射的文字-特效
<style type="text/css">! `/ [6 V* Q$ r2 C
#supertext {% y! Q7 i" `4 {5 P1 r
position:absolute;3 T: z* t N- V' j/ k* j/ `# E
left:0;
* ?3 a1 A K7 ?6 K$ A, Ttop:0;
) W; C1 @8 B1 k) Y2 l m+ qvisibility:hide;$ c' c b" O6 c3 g( {& G
visibility:hidden;
, l" D; O* `( u# E8 l1 D6 k}, @- B1 Z. D1 o, G, T: W: {6 E: J
</style>0 {% m) j2 C4 H! X9 H
<script language="JavaScript1.2">
1 w" p, e* v$ K# G<!-- 改变下的字体的大小。颜色-->9 c( N" }) T; m! A$ l
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# ^) U# r; a6 ?: L4 `1 G# q
var hidetimer='';
7 y8 f. Q( y; T( y0 q<!-- 改变下的弹跳速度-->
5 I! J6 U0 v' Ivar BallSpeed = 20;
* c6 R3 Z) l! e: }- Q4 @3 zvar contentWidth;, q3 q; \, r- c4 @3 Y
var contentHeight;5 \, h; [+ S& |) Y
var maxBallSpeed = 50;
& Q4 g1 J- h9 i( Q0 g
' H7 x4 e! u8 \2 E! h( x7 o6 O# {9 e, C
var xMax;' D( O$ b" n N# ?1 Z
var yMax;( L1 o0 q0 @. x/ P2 e. [
var xPos = 0;+ Q% I+ s3 O- Z# v+ R) M
var yPos = 0;
6 `) W6 U m+ K# Avar xDir = 'right';
3 {) [. V. `7 t; X4 T8 Ivar yDir = 'down';8 ^8 G; H$ l- P4 T) V
var superballRunning = true;9 v |1 D4 L: W6 o$ }8 E8 }0 r ^% n4 Q
var tempBallSpeed;
; _$ V m6 c1 x+ z% ^var currentBallSrc;
( e- Y) e' a2 r/ }var newXDir;
# O% U( l* e# n9 I$ B3 D8 nvar newYDir;
$ {. @9 g0 l9 m& s4 S) l( P
7 L6 e4 f }) Y$ Zfunction initializeBall() {
" }% B* R: b$ L: x$ T0 b$ z if (document.all) {1 S @9 U: q) C% V5 \ S
xMax = document.body.clientWidth' F$ ?* A L" r; a0 C
yMax = document.body.clientHeight! c4 B& l$ [% f6 _* E9 {2 x# r/ `
document.all("supertext").style.visibility = "visible";
: W* i6 { o+ E+ F6 r7 [ contentWidth=supertext.offsetWidth, N7 r! O$ l/ s
contentHeight=supertext.offsetHeight
7 g6 U. t6 s' t/ a, I* W }1 |8 ]" i& [- F0 d
else if (document.layers) {
( z1 d) p7 Y2 u( @ xMax = window.innerWidth;
2 C* i+ T% A& S. p# ] W' N! N4 Z yMax = window.innerHeight;9 W. M' S. m4 X2 T0 h
contentWidth=document.supertext.document.width
/ R% P. I% F: i- p+ k& Q8 J contentHeight=document.supertext.document.height
! y7 D5 s# w6 w: b- t3 I document.layers["supertext"].visibility = "show";' a8 t: N! c( q$ ^$ r; r) z
}
- F. O+ B ^( e% X k5 l% n setTimeout('moveBall()',400);- I2 V7 S0 K+ l
if (hidetimer!='')0 {4 [' r8 L# {
setTimeout("hidetext()",hidetimer)1 I, Z5 a- _" c' I
}
" [6 P# ^ m, z: M, a( |) ^
1 l5 x$ p: a& X' k. R% @function moveBall() {
, a: j9 j% C: ?6 s% _ E if (superballRunning == true) {" Y4 {; j \' z% W
calculatePosition();8 P9 x4 d5 ~0 S. h
if (document.all) {
9 c, a2 y4 K( j2 ? document.all("supertext").style.left = xPos + document.body.scrollLeft;
) U1 {, h1 a2 [; J9 y document.all("supertext").style.top = yPos + document.body.scrollTop;: {% p. N. x- q
}
* w% \6 Y7 k8 o- \& ] else if (document.layers) {
, Q. I/ }) T! E1 K( `* e. N document.layers["supertext"].left = xPos + pageXOffset;
2 ~8 \+ O7 D, _5 _% y3 u document.layers["supertext"].top = yPos + pageYOffset;
& g& t* Y! U! q3 a9 J$ S7 I }( r4 d8 E- D) m
animatetext=setTimeout('moveBall()',20);
( Z: M$ a0 T/ u3 [0 y$ @9 `9 J& V' Q }
4 j+ G3 ^3 C; V/ r/ a9 ? E. G }7 a! K8 n e0 v( M( T% M
x8 R4 W s' G- r* {- |4 W; qfunction calculatePosition() {
6 W9 p* o. s( T% O8 g. o if (xDir == "right") {( e9 Z5 r( K& N; ~4 H6 Z" m1 ~
if (xPos > (xMax - contentWidth - BallSpeed)) {
. z7 E6 M3 C% Q; ~/ i5 |/ G; l xDir = "left";# b8 X' J3 N+ r* B# P$ L) N0 }
}" o7 T% w3 z' B9 H& ~
}& r" E; R! ?9 @
else if (xDir == "left") {) d4 X& F* ~5 e
if (xPos < (0 + BallSpeed)) {: ~3 t+ t: _% }$ b& m3 p9 V- K
xDir = "right";( ^0 w' \2 I% {
}$ B t% q4 o( o4 h: [. _+ S7 k ?
}
' `! {% Q! W3 z6 p C if (yDir == "down") {$ T6 A S1 @4 j D1 s
if (yPos > (yMax - contentHeight - BallSpeed)) {
4 S. b( R. G7 m# _ yDir = "up";, R& f7 D- H- u* V2 ]
}$ y w( g7 G0 M; j: H& H3 \6 C
}
& U. R6 g; r3 Y( Z+ |) { else if (yDir == "up") {+ n( j" f& H ~7 B& U& Z9 n
if (yPos < (0 + BallSpeed)) {7 I3 D6 I& n4 P# N& Y9 T& g
yDir = "down";
. F6 e5 I; A) s1 X O }
1 K- G/ j. f, y! s }+ Q2 g! H8 P1 F! Y
if (xDir == "right") {3 q( `0 S; K9 U. I' {, W& w
xPos = xPos + BallSpeed;8 q) _) M# C6 t( Q7 I( ^" t
}
% [; b* d2 Y" K+ g, X m else if (xDir == "left") {* x* I. t& Z2 ~7 I# ^8 i
xPos = xPos - BallSpeed;9 d: z2 j& V, o& G
}
3 m8 N6 G1 F! y. M else {
3 h$ @9 k: Q+ h+ O: K: N3 Q# @$ ~ xPos = xPos;3 {7 a$ b6 P( x' L. k: o+ \7 ?
}# k0 h) V; _6 x/ i' w
if (yDir == "down") {
, e: _8 }6 }0 T' d2 z yPos = yPos + BallSpeed;/ P( ~* m7 D' O. k, f% a& ^" v
}
2 b. d! B ^: V else if (yDir == "up") { ]! q- Q( p/ A9 H& r6 E! L
yPos = yPos - BallSpeed;/ o" V7 [- G) r+ M$ k9 c, J+ u7 v
}
" p E. p. A1 C) [5 h j' k else {& f3 d: H; l8 ]% m+ ]+ `
yPos = yPos; ? m& u6 T& u6 t) s3 ?- `, W8 B* b
}
9 p$ Z( _' b4 {1 {( Y% ~ }
1 r/ N5 C2 b$ g
+ b6 Q" f. @$ r: [- ifunction hidetext(){
! m1 y, G, V/ w8 D0 nif (document.all) `& [1 X1 d# Q
supertext.style.visibility="hidden"
, c. k/ x1 B- T8 o! b. Q% Lelse if (document.layers)' n/ o7 U. \0 f( ^" Q! N: a- ~
document.supertext.visibility="hide"8 v3 R$ ]* A$ ~$ {2 U3 ]- c+ U3 n
clearTimeout(animatetext)( \ d: \1 ^4 K, ]: D5 T1 s
}" c V ^+ I, a
* e/ [6 \7 B8 V- B* l
if (document.all||document.layers){ m* T: f. C3 X5 ?, `
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ N w" Y, Q& g) Jwindow.onload = initializeBall;
6 ]) A& @0 f4 y u: ~window.onresize = new Function("window.location.reload()");
X5 {) W! v0 k4 J( v2 \3 H}
" N- v) O' o- j' n4 V
# d# F% _. _& F5 j4 \</script> |
|