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

|
网页之不断弹射的文字-特效
<style type="text/css">; T9 l8 y# c- v; a! M5 G
#supertext {
5 {% s6 p! @7 ~1 n2 gposition:absolute;
% C, i5 w' C/ ]/ m% _left:0;
0 Z: m0 s2 H* S- btop:0;7 I$ o% W; P0 Y4 _
visibility:hide;# w1 o5 O- r% G* U. E6 ?. G
visibility:hidden;+ G% f. Q* p. s& p0 p
}- a" J) ~1 b- _' g" U2 e
</style>
$ ?+ z$ V$ T- X" n' b0 J/ P% \; X/ h<script language="JavaScript1.2">
8 _' i7 }/ q8 K4 @$ i& R<!-- 改变下的字体的大小。颜色-->
2 h: v& C5 @: Ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
! T0 l( P4 Z" f8 jvar hidetimer='';; {' w' ~! x6 t0 F1 y
<!-- 改变下的弹跳速度-->: g" `/ w6 j" `' p9 K3 d
var BallSpeed = 20;
/ R/ F6 p, ~3 d: t" @* ?var contentWidth;
3 E9 {- Q) P& l. Jvar contentHeight;5 M+ u- J# ~4 X" t. }
var maxBallSpeed = 50;
; A! P, \0 n# E8 X7 I8 r3 a# C7 h; p; i$ p, d
# r) B: R* X1 L: u3 \var xMax;, }# C) V% o Z; ]
var yMax;
0 D7 d8 _) o2 Evar xPos = 0;) M% F8 r' s( R. U
var yPos = 0;+ o6 e+ h0 `$ u
var xDir = 'right';7 L9 q0 V# c, v) x8 Y
var yDir = 'down';
/ f/ l( Q; u- U# fvar superballRunning = true;, N& s) k! p k3 K4 M
var tempBallSpeed;( S9 o) W' b' x# J
var currentBallSrc;$ U* b: S2 m6 E- w2 v8 ]
var newXDir;
! e7 k- U) G/ h' H) ^( |1 k& avar newYDir;
/ ^0 S. ]" p E( z4 K% z7 ^( `5 i. D0 ?* k3 K& q- E% a1 Y- H
function initializeBall() {, I, f; a& T, T
if (document.all) {% p9 X4 k8 \6 ? o' I' q X
xMax = document.body.clientWidth
( ]' I9 X7 \7 O6 ^& A! v yMax = document.body.clientHeight) b r5 Q3 G+ w
document.all("supertext").style.visibility = "visible";
, r2 O+ j* e) g7 e contentWidth=supertext.offsetWidth
) }' U0 b T- |8 [ contentHeight=supertext.offsetHeight
3 @; D3 k+ D. k3 F( N Q# G9 A }! E& Y3 p) D3 a9 N4 r7 P
else if (document.layers) {
" `: T/ G9 E* l+ w xMax = window.innerWidth;# S- g! R8 F" G
yMax = window.innerHeight;! d4 F" U; B8 o6 z
contentWidth=document.supertext.document.width0 ~& o9 O& I1 S- T# d
contentHeight=document.supertext.document.height5 O" ^; S9 h% n- f7 W. m4 \
document.layers["supertext"].visibility = "show";
( M' @% x3 C0 ^* C P. D }
% M$ C4 o! g7 E5 ` setTimeout('moveBall()',400);
4 ^2 c# l$ t+ h3 q8 r' G if (hidetimer!='')
. d- _: K3 O% i1 ?7 w1 F/ s setTimeout("hidetext()",hidetimer)
' U( E2 c) ?* N }
2 x* M! v8 \, H, n
* R9 F# B8 T6 gfunction moveBall() {
4 n7 a+ T7 ^3 I* U& U9 l if (superballRunning == true) {
6 f6 O) p7 D6 n8 i# s2 Q. Y& u calculatePosition();) S, S( ~( t8 W" @! c2 `/ k5 ]# S
if (document.all) {
% w* ^1 `9 H" ^ document.all("supertext").style.left = xPos + document.body.scrollLeft;$ i' B% h: S9 @1 A. X
document.all("supertext").style.top = yPos + document.body.scrollTop;+ I+ r; B" J; [% U
}
- d6 }7 n/ b `1 H else if (document.layers) {- M0 t0 H+ e; B' }* |
document.layers["supertext"].left = xPos + pageXOffset;
* Q+ @% g8 |- c) w" W+ ~ document.layers["supertext"].top = yPos + pageYOffset;
6 P7 \+ N4 @" W3 G }1 X9 |& i2 ?! V @ e- Z+ _
animatetext=setTimeout('moveBall()',20);
6 ^* A+ s r3 x& g' S4 ~ z }5 g- z, m; u( Y& Z# y9 e
}
7 i8 q2 k) ]/ |1 l
0 k, w1 Z3 L' I% n6 c8 r, ~8 z& e. xfunction calculatePosition() {
& @' X8 j% k% m% E3 c+ W* w if (xDir == "right") {
1 W. J+ Z4 D# X9 b' Q+ P6 y6 _ if (xPos > (xMax - contentWidth - BallSpeed)) {
- D# a$ G, e2 y xDir = "left";( H, _0 C. V" x% }9 f8 Z) t
}
; L. A4 c! I9 u$ v; f2 ` }" |% m7 W, }# y. `
else if (xDir == "left") {& T5 R# q6 B0 ^
if (xPos < (0 + BallSpeed)) {
6 n! z1 ]8 B2 S5 [$ n9 l; G% J xDir = "right";
" h3 K- o" P+ j1 k3 M! | }
: E1 A) f5 \" w, k$ @7 V }$ E0 B7 o& q3 E! m4 `+ K
if (yDir == "down") {
% {5 E/ y+ W, G( h3 p' D if (yPos > (yMax - contentHeight - BallSpeed)) {9 f. `" V. ^7 q8 q' }1 Y# y
yDir = "up";- N }! j% O- z/ \ r. {
}
/ Y3 e; D2 K* C# a } V1 P4 i# ~& S9 }
else if (yDir == "up") {: J ?! E) M: E6 }3 S% o
if (yPos < (0 + BallSpeed)) {3 m+ {" v' j2 W- F" v
yDir = "down";
" R$ J7 D1 `6 E3 E, x: B2 x- g }9 t; v+ Y; s2 r3 ^- {' T/ N
}" ~) V X0 c; e7 ~+ u
if (xDir == "right") {
+ x5 y) V# U2 x) ?% v! [* S xPos = xPos + BallSpeed;. C& B4 {) B/ p7 f# o4 K
}
" v1 @6 S5 s; m4 S/ M# v else if (xDir == "left") {
3 Z* N- y6 y: r' _ xPos = xPos - BallSpeed;; @) t# I2 d8 J+ L' V, ?
}/ }5 u2 x$ ^) ^
else {3 ^ `# `+ y' Q5 `
xPos = xPos;6 J* d9 e! J' s
}
1 E1 {0 Z- c: V4 b3 p if (yDir == "down") {
- [0 p9 q9 f9 r yPos = yPos + BallSpeed;6 ?% d% g( b1 u5 c
}
( k9 G6 P9 f, M9 R. ?; { else if (yDir == "up") {/ }% ?; E* W6 c7 h5 z! O/ O
yPos = yPos - BallSpeed;
: P- v( g8 q7 S }0 n- }6 o0 ?! n; A% V- a4 I; d m
else {; ]+ R, W6 }: S& s8 H9 Y: c9 u' r3 R) m% R
yPos = yPos;
! h' i, @( X; n }7 L) N$ [' R+ j& W5 ^
}
1 V: R7 n$ x5 Y5 T, y, M% ^( R; w6 \3 b M
function hidetext(){
4 w( R: _2 j. S+ Wif (document.all); C" Q, \+ Q& j4 z Z+ U9 h0 c
supertext.style.visibility="hidden"( D- F# S9 w* } D$ _# X; Y
else if (document.layers)
" k" w5 E8 T! C$ S( m$ Idocument.supertext.visibility="hide"
F$ R6 A) H4 y6 f+ j! }; |/ P5 c- VclearTimeout(animatetext)
+ D' h6 D: ]5 B% r! @6 U+ y1 B* h( C. c}
# ]% w4 x! Z$ R& h% y% n& j; B& M1 j3 h: n$ T h
if (document.all||document.layers){
, ?( p1 ?0 [5 J ?/ ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')6 S& [2 ]8 \5 L* w, l
window.onload = initializeBall;
3 S# N9 d/ k' I6 `window.onresize = new Function("window.location.reload()");
5 H5 H0 a" S- a3 y. h}
3 q+ S# K4 i. G& v8 C* n/ K! Q1 K$ l, t& `) p" ^" a o
</script> |
|