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

|
网页之不断弹射的文字-特效
<style type="text/css">
* z( ~* S5 V' w- M: q3 u+ j#supertext {
4 b6 o; W6 B# E7 [, f; kposition:absolute;/ Q5 T0 r: l7 Y/ x
left:0;! ~9 k- H: m$ `7 a0 s
top:0;* N2 w; {0 Z8 |! Q
visibility:hide;, v0 D4 |) a8 h: e4 h9 C% r
visibility:hidden;" z6 C0 `" m/ e* C* d
}
% _5 h# p& R( X</style>2 K3 |* k# q' _5 O
<script language="JavaScript1.2">7 k3 ^& j6 [5 n
<!-- 改变下的字体的大小。颜色-->
; ^8 Q- v% C3 D3 N% s. R9 _var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
# X$ @' O6 x4 q5 S8 dvar hidetimer='';1 O, U( `# ]' L! @
<!-- 改变下的弹跳速度-->6 Z% I7 r" C/ k/ T+ p5 ^ @+ y
var BallSpeed = 20;
. K f. y, E1 ?& m* E: Qvar contentWidth;, x4 p6 S/ R {) e, M3 X7 S
var contentHeight;/ d5 I4 S7 c2 y# ]( n% P ?
var maxBallSpeed = 50;
, \6 ~ O! o$ R1 K. B, q% ?& Z' {/ ~' L9 b# I
4 @! o' L& K; @. w$ h9 w+ t( H
var xMax;# N8 g$ \# O, P
var yMax;; [- O- R; q5 z. N# B$ b% [
var xPos = 0;
4 D f( ^- r9 q2 o: n( Uvar yPos = 0;
3 |% ^' Z) d& b' V2 X' yvar xDir = 'right';
$ Q" |- C0 o% e+ e& lvar yDir = 'down';
9 t" h1 y9 F8 [( ~0 Uvar superballRunning = true;4 h3 {( o: q' e5 Y0 ~- V$ m' z* A
var tempBallSpeed; r8 [7 o; y% a, o; f
var currentBallSrc;
( o' h" d' c s* G8 Pvar newXDir;
" v6 @# U& y0 F2 F V1 rvar newYDir;
0 r! d+ Y" s- C& a& T& O( f
7 B2 V w5 N1 k" V7 T6 ~function initializeBall() {, s; N; P( G0 {4 v. y/ ?" T3 l( e
if (document.all) {
5 W" i7 w6 S; U c" ~! j' x* U xMax = document.body.clientWidth
3 L' l+ Q2 @" x) g7 a yMax = document.body.clientHeight; h! Z! k% n- C/ N% o9 Q
document.all("supertext").style.visibility = "visible";
! \4 X* ]& l/ L* o6 J8 U contentWidth=supertext.offsetWidth
5 ~0 P& d& H3 Z1 l4 s contentHeight=supertext.offsetHeight
$ K) v; i8 c! g3 c. X7 ?' F }$ \# u- \. O7 Z* p
else if (document.layers) {' z9 ?/ v Q; H1 R+ v# ]+ l: Y
xMax = window.innerWidth;
! @( L) l& v) }, V/ h yMax = window.innerHeight;
6 n2 G) X1 @7 F) k% ?1 n% I$ A8 [5 g2 A contentWidth=document.supertext.document.width% Y) [. G) _' q/ J6 p1 J- f* R
contentHeight=document.supertext.document.height) Y2 h5 |4 Z! I, p6 P
document.layers["supertext"].visibility = "show";
' S! d! |; K5 B }! Z! T; M( \) N7 Z8 j, l
setTimeout('moveBall()',400);; R+ M$ ~; {! i! w& B
if (hidetimer!='')
# U5 a; P! R5 M0 w, c3 l setTimeout("hidetext()",hidetimer)
! b$ D% Z2 D) g, M' _, q }
- J! E3 ^1 _4 L) d9 b- M! T! p3 g* S3 {1 U
function moveBall() {, K, I" s0 {0 |$ d
if (superballRunning == true) {- R' W; p& V/ J; H) {" l
calculatePosition();
0 W v* V' y4 l if (document.all) {
1 _* z* ~8 v& m; [7 C document.all("supertext").style.left = xPos + document.body.scrollLeft;
8 }( x* q* a+ B! C! ]. A document.all("supertext").style.top = yPos + document.body.scrollTop;
; T1 q8 v4 O# p$ M3 Y/ b+ Y }
2 Q/ L; b; C& d m else if (document.layers) {
4 ~4 P; O& d" ^& ?8 ] document.layers["supertext"].left = xPos + pageXOffset;: T# W% Y: F4 c9 |& G
document.layers["supertext"].top = yPos + pageYOffset;
, x+ ?2 L1 ~4 T! Q }9 S" ~" v2 u- E
animatetext=setTimeout('moveBall()',20);
8 m% ?: M$ Q) u }
" k5 D& v m) P }
+ u7 B9 |6 v+ [7 \5 t2 h
8 A; Y- t1 l- gfunction calculatePosition() {1 ^9 ~( x; C# s' u; Q5 q- L
if (xDir == "right") {
. i2 v" ~5 O) w if (xPos > (xMax - contentWidth - BallSpeed)) {. z" o* P: @: x; Z9 A3 S% A5 L+ v9 ~* T
xDir = "left";9 z% ?! j3 Z% _
}
9 P( y, ] v4 [8 [9 I }
' Z+ l) i3 s1 N' h' f- e! ]* v( j else if (xDir == "left") {* |- F& M6 T( I: @
if (xPos < (0 + BallSpeed)) {
w. p- v+ P9 V& \( A e xDir = "right";7 s' e" i7 d& C3 s
}
) Z# }" p! c: i) I }3 k- z+ r0 F2 B/ `2 l
if (yDir == "down") {
1 D6 ^1 d. l R! O6 B; Y2 h7 ~ if (yPos > (yMax - contentHeight - BallSpeed)) {
4 h" J: ^$ ~. g( V9 C9 s yDir = "up";; m/ T$ o1 b0 `" l/ W
}4 m+ \. `- |1 |1 I! T2 m" K
}8 p4 a. g! ]) i, i. U" N; _9 p
else if (yDir == "up") {# J0 q( G* O2 d2 o
if (yPos < (0 + BallSpeed)) {
8 h" N3 h" C. f yDir = "down";
6 ^9 \* l$ d7 w }
; z1 q+ `" }8 k c }' E0 k7 ~+ Q. c2 d
if (xDir == "right") {4 N! I( g3 o6 \5 ~( _; ^
xPos = xPos + BallSpeed;; s9 m( ^: U' ?% J$ e
}
' t6 @1 C: Y8 j; ^( l else if (xDir == "left") {" f5 C: M$ q: l3 w/ T \) o
xPos = xPos - BallSpeed;& F& L; l' g3 s! |5 L
}9 l2 b) g# h; K+ n. ?. N8 A
else {
" h: C* L2 p+ k xPos = xPos;
W$ P, b6 A2 z I+ G }2 O m3 ]. S# m+ d1 n9 m' D% Y
if (yDir == "down") {
5 t+ f2 P& i, ^* ?! ^ yPos = yPos + BallSpeed;2 g1 `) ]6 V' K5 t" P; @
} f& G7 H u$ T$ n+ Y( R ~
else if (yDir == "up") {
/ j8 W( O J3 ~5 I, P1 A7 z yPos = yPos - BallSpeed;& _' P6 Y# }+ m a+ D$ t
}$ A1 V# |( G" U% u- c8 ?! C
else {
' _) P6 B/ M5 x9 T yPos = yPos;
* |; z, e/ q- l' S, n }
: O2 B5 n2 S6 k" q' d# ~ }1 F4 B/ v4 T Y; y# i8 n& @
# c. h: ?4 G8 Y+ Afunction hidetext(){8 o; o% k5 r& V+ T9 ~% j
if (document.all)
5 Y" }# `5 v! L. e# s' C* B) `supertext.style.visibility="hidden"
+ x. ~1 r5 k5 O# Eelse if (document.layers)
& t$ O+ y( H+ Fdocument.supertext.visibility="hide"
9 v; q/ y& S! R/ Y( U# YclearTimeout(animatetext)0 s- x' w1 w9 Q" g8 E3 p$ {8 _( _
}4 p4 A. c* G# h1 I" q1 Q8 Y1 }( n1 a2 t7 C
( e1 i4 \) T# V. n& p$ Yif (document.all||document.layers){# y8 c2 A& ]0 ` }( K9 u4 Y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 i+ n, B, @ h5 Y+ e5 @ d
window.onload = initializeBall;. A3 f& a& p! q. b; }6 `
window.onresize = new Function("window.location.reload()");3 U% S" {2 |) c+ |* G2 e R
}% o& ]( D, f5 X2 q' [
% V$ Y& c I9 e# ]</script> |
|