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

|
网页之不断弹射的文字-特效
<style type="text/css">- L1 }: z t9 c& e5 x. ?
#supertext {
% u. ]6 B' Y% m6 Bposition:absolute;; V& |) J2 H- a- D% T3 P& L
left:0;+ j% ]8 y0 T3 @5 x z4 ~/ }% n4 c
top:0;
) P4 H5 i% t: j* g9 x/ `/ p& ovisibility:hide;% E$ `2 w* Q. T2 F+ y* K7 P
visibility:hidden;, M# J4 `& y0 Y% k
}+ u! [& q, G# Q
</style>
7 J- L R& y9 T) ]- y# w4 Q<script language="JavaScript1.2">
9 m% z# N% k) }9 E<!-- 改变下的字体的大小。颜色-->4 V i3 k& p& p' m. o, e, ^
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 I' o+ v$ h) Z" ]3 Q) ovar hidetimer='';7 x1 `4 d( _$ [! v1 Z8 T. e& l7 ?1 N
<!-- 改变下的弹跳速度-->
$ l0 |" j" i, avar BallSpeed = 20;
: j/ \$ E H! X9 ~var contentWidth;
% J1 R3 W6 P9 Yvar contentHeight;! b! H; S# [3 { f, B3 z% {9 G# N: B
var maxBallSpeed = 50;
7 S' m8 M) V5 K. s% {6 @6 h
0 T7 a2 _/ M9 Q7 g/ E
2 D! F0 O6 V) g* bvar xMax;
1 t, i3 P% H, e& V! Qvar yMax;
' [# R) d2 u$ g2 }0 }# L) svar xPos = 0;
: F$ v% {5 j1 N* r0 L+ R1 o* ?var yPos = 0;- M/ {5 T+ h, W8 P( Z+ @7 C! \- A
var xDir = 'right';7 k1 b7 l9 ~* c
var yDir = 'down';/ s9 ^2 S& U) z2 M/ b- ^
var superballRunning = true;' T2 H u& L- d
var tempBallSpeed; u f6 T5 t8 ]$ x* x, R. t
var currentBallSrc;' }% j( F8 D- y* S
var newXDir;
, D( H6 X5 C5 lvar newYDir;
# D: U7 L: l- H4 H7 [' G2 R# n! N4 G% \0 e
function initializeBall() {
0 {3 Q' j' ?/ U8 U if (document.all) {0 d$ l/ @9 I2 T. _# _4 W/ z* g: S
xMax = document.body.clientWidth
, v! r) v. o y. T* ^3 ^7 u6 f yMax = document.body.clientHeight
l% [6 [4 y8 V& g4 [ document.all("supertext").style.visibility = "visible";
) w8 v# p8 M' L4 j. ? contentWidth=supertext.offsetWidth+ B# C7 c5 b- h8 w- j3 N: z- V* |
contentHeight=supertext.offsetHeight* R# d+ m, d3 q
}$ j* d5 |* X% ^0 q0 |2 m9 V* ?" u, z! p
else if (document.layers) {
& V# P8 }8 l& ~. ~ xMax = window.innerWidth;3 R4 i" G0 ]- P+ |
yMax = window.innerHeight;
+ y8 ?) Y! u3 K O+ U contentWidth=document.supertext.document.width
3 M- Z6 [% F# U contentHeight=document.supertext.document.height
7 a3 B+ |, \- F document.layers["supertext"].visibility = "show";! M' M0 |5 g8 ]; H M
}
I9 q. ?0 C' z3 M setTimeout('moveBall()',400);
* V2 m r0 ]3 Y! Q9 k- v if (hidetimer!='')
! M" m# P; I* S! i1 y) a" S setTimeout("hidetext()",hidetimer)# S' t1 w$ H8 o1 `* {: _
}
1 p7 ~: Z# n# R! {5 f1 U, Z+ q3 A) L1 {3 q. u
function moveBall() {/ P# p6 P+ P% ?. j7 F" n
if (superballRunning == true) {0 ^- N0 o( K7 Q" ?9 G
calculatePosition();! V+ R. a5 d5 \. f3 V
if (document.all) {9 q# H( _: u1 T
document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 w; K# d, H O* \4 E+ q s document.all("supertext").style.top = yPos + document.body.scrollTop;
9 p+ h$ ~- R6 T }
9 |! m* ? ~6 v. O8 h else if (document.layers) {. s2 \2 b |! Z% \- x# S) g& E
document.layers["supertext"].left = xPos + pageXOffset;
% b4 O% X. o9 l5 ` document.layers["supertext"].top = yPos + pageYOffset;
. a% S1 Z+ E8 b- D7 q# y( N: V }
5 I; S1 x! a+ ^7 m# R0 i animatetext=setTimeout('moveBall()',20);- n; m: B0 ^ b, |& V
}' w( A% @# a$ i9 l6 ]% L) b1 t
}
' x; w' o7 u7 Q) U4 Y8 L& E8 A. I0 q2 O9 l5 @3 w: d
function calculatePosition() {
' m+ M8 r" j2 c! o if (xDir == "right") {/ a, f ~" b/ S1 }1 z& A
if (xPos > (xMax - contentWidth - BallSpeed)) {% [3 ?; R4 h" Y/ L$ x
xDir = "left";+ q, k ~# d) o
}2 }- B# t* _5 R8 Z( j) Q8 c$ N
}
! X3 g- a. i) c7 s( [ else if (xDir == "left") {
, ]: N4 v! Q( l- y, D& Y5 C; k if (xPos < (0 + BallSpeed)) {$ A. Y# m, i5 n6 z& f2 b
xDir = "right";
9 Q3 x7 K9 J( E$ d8 i3 J- K# k6 y }
, H5 ], d, L1 P& t$ n a }$ U* c# i) b5 w5 b' P
if (yDir == "down") {; y3 ^" h H1 K% N- H6 a4 e
if (yPos > (yMax - contentHeight - BallSpeed)) {+ P5 z$ g7 T6 k
yDir = "up";
* S8 q, L$ i* h( F } e. w% e% C' x/ Z& S
}
$ ]) w# Q6 S8 d1 O+ v3 ?1 u3 ~ else if (yDir == "up") {
% [5 C; H0 m# R" y0 N2 B+ E8 q if (yPos < (0 + BallSpeed)) {
8 B5 v/ ?1 p7 A1 C; W/ z yDir = "down";
1 w& y3 s- k# e2 w0 K$ R ~ }
0 ~- k. ^7 ~5 ~$ {* S }
% f' L, Z; F( t' x0 W5 E5 X if (xDir == "right") {
9 m8 R# A6 {, f: I) o/ I xPos = xPos + BallSpeed;
( H8 {9 s2 |% ~ }
+ K% t' P( k5 h) W else if (xDir == "left") {
+ x: B1 w; F: f( s4 G$ n% T xPos = xPos - BallSpeed;: W/ y9 p# x- M% x" V8 m* c
}8 \. O9 _' E' {; o; H" ]
else {8 W+ H! f& b2 ]3 ^2 V9 a
xPos = xPos;
* `8 x' Z. q- s9 }- K2 m) R }9 E/ N2 p9 p2 [( I4 O7 a2 M* F
if (yDir == "down") {2 x# R% W' ^5 p9 a2 `5 U9 U: d6 L
yPos = yPos + BallSpeed;* w4 c9 b6 g7 I% B; ^7 C
}
7 {9 G& r1 Z, U! E else if (yDir == "up") {
$ t% J4 a" [0 _( V5 D; W6 u yPos = yPos - BallSpeed;
$ ?! N9 T. \5 ?% {3 l }
* [ r( W0 O, x; A1 S+ ?5 m+ ]+ | else {
% P7 X V% Z; W( A, T+ u yPos = yPos;
1 g: ~" Y2 p+ d/ B% O } }
, k( Z, V e4 [ }
1 Y6 x7 t& y3 u7 I7 u8 |* ^
; I# C+ l+ |/ ?' l5 b6 ^1 Ifunction hidetext(){
+ C9 m; Y2 } z% T7 n1 m% Pif (document.all)1 t& L, D7 ^/ b: w
supertext.style.visibility="hidden"; \* r% u$ h% X* ^1 P
else if (document.layers)' g5 S$ n, Q3 c8 q
document.supertext.visibility="hide"2 i# L9 G# {. u3 v8 k
clearTimeout(animatetext)6 c& D/ P5 O+ ~$ l' T
}3 d7 w' u+ J( e& M2 l7 v" K
. i) I6 s4 P4 j6 F% X: `
if (document.all||document.layers){
& i' ~0 p! Q6 P1 S. t7 U' T# \6 idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
4 t3 |' b! x/ T) owindow.onload = initializeBall;
, L6 l5 F. M3 N- l% Lwindow.onresize = new Function("window.location.reload()");& L/ s+ P& q' |% B! p2 W5 k
}
) H$ F" p& R, R8 i4 [9 P7 x. {4 b$ D. a0 s& j
</script> |
|