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

|
网页之不断弹射的文字-特效
<style type="text/css">* X6 w3 |& ` }) C) T. Y
#supertext {- e5 R8 d4 \; w2 G4 X x
position:absolute;
8 x/ F( W; q0 T5 N3 q0 k7 b% ^! Qleft:0;
5 ~1 y' m/ [% j# S( H: S4 L1 ]top:0;
, Y8 e5 w4 u, m+ z% Ovisibility:hide;
& r6 t4 J* s$ \- B% I$ \- evisibility:hidden;
: r: c; C N. z}7 N* F+ t5 k2 e
</style>
4 F2 Q) w2 s( |<script language="JavaScript1.2">
0 V3 g- C+ U% w8 I$ \' g' ~ D* g1 q- j<!-- 改变下的字体的大小。颜色-->4 D( ^/ ^6 T' T
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 b$ y: g: i4 f) ^- B
var hidetimer='';+ C7 w. s& N6 i/ w
<!-- 改变下的弹跳速度-->% W7 j3 R% e, {
var BallSpeed = 20;
* r2 [/ U7 _: M- dvar contentWidth;9 n. G" O" L6 P$ o$ }
var contentHeight;
* @# J8 h1 o* \1 ~2 c+ s9 U9 ~var maxBallSpeed = 50;. I% L3 ]: R9 b8 s- ^0 Q- P
; ?- f5 ~% t5 `6 U! \$ C! E. z+ b3 r# x# O) b" A
var xMax;
% A3 a8 M& H* G" U6 evar yMax;
) B& h- `# }: ovar xPos = 0;3 t V1 E: a* t# j w. W
var yPos = 0;& S! m& P, M1 d y8 X. U6 ^
var xDir = 'right';* m+ u) \" L! I: P8 v& s
var yDir = 'down';2 j- a: p& g5 n: x- F* d& q: _
var superballRunning = true;7 ?5 S' Q" j, ^ E
var tempBallSpeed;) c' u: c' v1 A- Q' _% k# p- O
var currentBallSrc;
# C `- I* o) ?2 }+ yvar newXDir;7 a3 }4 U. i0 H, v- R! s4 _
var newYDir;
$ F/ b% i7 Z0 W8 a- ~& o
$ r2 ^# C, z. x, V: wfunction initializeBall() {8 v( c: P0 Q. v# m: c$ J p6 s
if (document.all) {" O$ T7 e( Y9 n, g7 d& n$ e
xMax = document.body.clientWidth0 L1 j; E. J1 A" q4 w$ H1 \
yMax = document.body.clientHeight8 X* ^8 {# R2 ^
document.all("supertext").style.visibility = "visible";) G- V% q8 V) S
contentWidth=supertext.offsetWidth7 s9 X( u) P+ `% L, i& u
contentHeight=supertext.offsetHeight
* Z; K# I- M9 i6 o; I( T/ a3 K H }7 \, d& ]: M# C$ Z2 b) J# h$ P& }$ N
else if (document.layers) {
* K( z/ P8 W" g4 d2 | xMax = window.innerWidth;$ S4 \! X5 v. [% ~- j
yMax = window.innerHeight;
: l1 _. g% I/ P, g( Z- a( v: B6 `9 R+ ` contentWidth=document.supertext.document.width& s$ ?9 i5 f# t/ G1 \
contentHeight=document.supertext.document.height
" m8 C( r4 t3 A1 u/ [1 g& M document.layers["supertext"].visibility = "show";5 f3 s5 d$ x* e3 |% u" ^4 x
}
1 l5 `! I2 a, T7 }3 w, L6 h. q- e1 z setTimeout('moveBall()',400);& Z5 b5 N. o$ e& |6 C* m5 F( B
if (hidetimer!='')8 w4 P/ T2 p" a* n2 j
setTimeout("hidetext()",hidetimer)
: }# e8 i& q, h/ m }7 s" [, \) u# d8 F1 W Z
! g- ?! ~1 R) |! I" V
function moveBall() {
% r0 f/ u+ A8 x' b. f if (superballRunning == true) {
3 q! a5 Y- D2 \* u' x4 I# R calculatePosition();
( C: n9 c/ l# D* ?1 {9 g7 U5 d if (document.all) {
3 p- Y+ f1 H1 D1 g. M( h4 e% H7 R2 X document.all("supertext").style.left = xPos + document.body.scrollLeft;
% T7 f+ e& H) o; ?' C- u document.all("supertext").style.top = yPos + document.body.scrollTop; Q( E, L' X* c: m) k1 H% H
}
, @# p a: ?4 H1 U/ Q/ k else if (document.layers) {
6 A" `! [( `& J# }4 t6 s+ h document.layers["supertext"].left = xPos + pageXOffset;7 P% W8 x/ J7 p+ L u8 ?! |
document.layers["supertext"].top = yPos + pageYOffset;& A# g( q. y6 _" c2 v; Q4 U$ h7 {
}+ v d' \% I9 y6 u- N
animatetext=setTimeout('moveBall()',20);" g3 t1 f0 o' c k+ E6 @7 e- ]
}, j( k& e) b* v8 k8 r4 ^
}, C$ W% h/ S& P" G( f: N2 H
7 Y% C, `! ?& \6 ~% _; a( Kfunction calculatePosition() {$ Y( J- n2 r; c O% D7 u3 C6 E/ l1 `
if (xDir == "right") {
/ j7 p( C& M! N9 K: p if (xPos > (xMax - contentWidth - BallSpeed)) {4 z' H5 b3 b# Z* G1 }
xDir = "left";# o. N4 D* t! I. Q
}2 m# C: i8 L' w, _0 U. Z, e; r
}9 W! \" S# Y& M8 f
else if (xDir == "left") {
0 t/ t$ N; B7 o+ b" z if (xPos < (0 + BallSpeed)) {
3 e# L! v& n9 E* f xDir = "right";
: H$ s' {! _" Q: K: C: l( Y }' x$ m, @5 T0 [7 X
}+ @! Y! x" y3 s' d, Z* g
if (yDir == "down") {2 o# b7 K% i4 m5 P) c
if (yPos > (yMax - contentHeight - BallSpeed)) {
2 M3 J2 E# P" M @ yDir = "up";7 l7 W- k2 w1 E% G
}# f9 i9 q0 z1 e4 E
}
6 C" F. V2 U% A# ` else if (yDir == "up") {: T* S2 N. K& v& t0 S" q
if (yPos < (0 + BallSpeed)) {
' p& j& T0 q0 m6 r/ c6 Q) a3 Q yDir = "down";% l& l- Q) ~. o! N1 D# W3 M+ m
}
9 f* g) R9 C. o* r6 D }
9 D# X0 @' _ ` if (xDir == "right") {* \6 L* C+ I, z6 m# h- [: B
xPos = xPos + BallSpeed;3 ]" E- M: O, D
}
5 T5 r1 m } Z' ] else if (xDir == "left") {2 V/ Q S. ^9 U6 I
xPos = xPos - BallSpeed;
) ^+ s# ~, N& I6 W4 Y0 p# y; A# ^ }+ `& |# p; j* [/ D- Z; O
else {" {& F6 ~- Z: f6 H9 a/ w; l
xPos = xPos;1 @ p4 B3 t; v; u4 ~
}0 E" {+ D) M$ l5 V' _- v% `" N% k9 A
if (yDir == "down") {' d8 T& K" @8 O* W; f- B4 E
yPos = yPos + BallSpeed;# q1 [/ Y* Y8 v" I* L X' _8 O$ x8 o
} [, x5 @- g1 s+ J
else if (yDir == "up") {2 z2 \3 P" N' u
yPos = yPos - BallSpeed;1 B5 p3 o5 Y9 [% O$ B$ y
}
. a7 ?- }9 G# W' U/ { else {
' n- L+ T. H( \$ _2 a1 F! { yPos = yPos;9 F& g% [1 O8 w/ V* K$ U
}; ~/ t3 k0 e- V# M6 A
}* y( m9 Q# L; j; G' u% |
|" ^; p% r9 w6 Y1 E5 nfunction hidetext(){
- O' K- [2 w' @2 \8 {if (document.all)2 r) f4 ] A1 s' r. |0 P
supertext.style.visibility="hidden"
! y, ]% y. P( @3 pelse if (document.layers)8 |1 H: D. o, F, K0 V! z+ r
document.supertext.visibility="hide"+ Y) ?8 q$ h/ ^0 G1 a8 _0 [8 d. ^
clearTimeout(animatetext)
; m5 ?# T* W; o}
1 \5 V+ k$ l: B/ r' c& | |( U7 J/ @9 k! o5 s- J' R* F) G* h/ K
if (document.all||document.layers){
5 C" W% L6 C% }" S1 K3 C; H: Edocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
& f; y) b1 E6 ywindow.onload = initializeBall;4 G G9 |5 p0 C! j6 g4 \
window.onresize = new Function("window.location.reload()");) d z+ o2 |! m5 c
}
* {7 h, _8 e% u- _9 u5 g3 {3 z8 Y/ y; E! z9 z, ~: n; Y
</script> |
|