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

|
网页之不断弹射的文字-特效
<style type="text/css">2 u. |' k3 H. j+ U
#supertext {
+ w7 r: Y/ e: p }1 Eposition:absolute;
, `0 X" B* R' ?' N: ]left:0;. e9 `* f7 n2 { T+ g9 ?
top:0;
& `7 Z% B- X" W Fvisibility:hide; J- c7 V& t: e' E1 s
visibility:hidden;/ j! F7 g$ Z$ e; k+ T
}; B+ Z7 R3 b; x3 G; Z
</style>( p! l% ]2 q: u5 n4 @# A% e2 P
<script language="JavaScript1.2">
5 s; A6 b0 K! E9 d% s) ^7 Z5 p* ~<!-- 改变下的字体的大小。颜色-->
. Q( I1 N- z) Z( O/ K$ j+ w# N2 jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" q0 I/ l/ z6 g: gvar hidetimer='';
9 [5 f& C9 O# `3 G# n$ ]4 z<!-- 改变下的弹跳速度-->
2 o& H' J% o1 u( Rvar BallSpeed = 20;. r) r- m( N) U: { A. N
var contentWidth;
4 L. B2 s* j o2 E! Avar contentHeight;
) j( [* c1 v- gvar maxBallSpeed = 50;
% [; D0 I1 G& q6 x6 ?1 ~" g* |# m6 h" u, ^' P: J
4 G* a, ^9 Q$ S, t" {4 G5 p8 i/ W
var xMax;
/ f) C! M$ E, O8 Y; O3 ~, Tvar yMax;
3 g& t, k" l" v! u* Qvar xPos = 0;/ q: V" G* |$ p5 t5 t4 X4 O3 U* x
var yPos = 0;8 A" ?. R h; ?
var xDir = 'right';
0 X9 m: X; D( |+ h9 hvar yDir = 'down';
0 t& X; s9 n- B7 Pvar superballRunning = true;
4 K* j5 @ \% ]) t/ jvar tempBallSpeed;
( g" H" A" \" }' T1 ]" |6 W4 D& ]var currentBallSrc;
) V4 w2 u! u0 x% @1 J! F% `, U' yvar newXDir;! I4 @) F, r8 H+ M& r1 K9 P
var newYDir;. ~! `) I" {+ }1 {& `& X
& P3 R" Y! `3 V% e$ f. ~3 M" l
function initializeBall() {
2 Y0 P- E" T0 \% z) o) d( e" U* T if (document.all) {
2 c7 Y' c! `/ b- m+ H# x xMax = document.body.clientWidth
4 H* h, D8 {2 B# {" O# G0 K yMax = document.body.clientHeight
7 ?) p$ R$ c; n6 |8 ?$ c$ ^ document.all("supertext").style.visibility = "visible";
! X: P/ K2 I( J; `7 G# Z contentWidth=supertext.offsetWidth
3 S7 Q t6 E- F' E! d4 J4 ^* F contentHeight=supertext.offsetHeight) v# `% h J1 N) M! t) T# z4 F
} U7 P- F8 d a7 g) J2 u2 X6 ^
else if (document.layers) {/ J! Y3 a: H( n- I! `, L, [' N3 G0 X
xMax = window.innerWidth;/ R, a+ j5 U: G1 i/ J+ x- j
yMax = window.innerHeight;" N9 [7 ]7 o: v' F' s
contentWidth=document.supertext.document.width; g2 u) u5 t4 j3 |! O, T
contentHeight=document.supertext.document.height
: o, c; F$ Q+ P3 ` Q1 z/ R document.layers["supertext"].visibility = "show";& F2 H5 K) H4 D5 `8 B
}7 l9 j" `0 s4 `
setTimeout('moveBall()',400);
3 `5 O# R4 S: b if (hidetimer!='')$ |& ~* R. {+ I: f: F- s9 u$ m; G
setTimeout("hidetext()",hidetimer)/ g7 u5 R3 M0 [0 U9 X% E) K
}
2 s; I _; A% t9 p/ ^3 ^( R$ m' X
: x+ b$ r- u# \5 n# k6 kfunction moveBall() {
9 }6 h! _, x+ L- l if (superballRunning == true) {
9 p3 s2 _+ U$ y) Z calculatePosition();
: `; s: B1 w G! G2 B9 i- p if (document.all) {
. s! ?6 C+ l; K' H document.all("supertext").style.left = xPos + document.body.scrollLeft;, n. V: m! D) p. G" v+ f b" z
document.all("supertext").style.top = yPos + document.body.scrollTop;
" |1 l6 _* d8 {3 W3 V! @ }
. Q" z4 x4 u `# X: @% H q0 H else if (document.layers) {" F5 E. w- _+ O
document.layers["supertext"].left = xPos + pageXOffset;5 a4 _6 E" x7 A3 D# S ]
document.layers["supertext"].top = yPos + pageYOffset;
# [: M* W. s1 F }8 {/ t c1 s3 m# Z; \
animatetext=setTimeout('moveBall()',20);/ i4 @6 k+ k) L+ ^
}
3 u. f) `5 R+ w }
. N) w8 z6 z& K+ m" n* V( k- m. P+ H# |
function calculatePosition() {
$ Y/ j; u: L5 v( N1 {+ G6 u, K" T if (xDir == "right") {* I9 T2 V0 b( a+ P8 ?+ Z
if (xPos > (xMax - contentWidth - BallSpeed)) {
6 h: U1 ]+ C( A2 }5 E xDir = "left";6 w* z a0 K; V0 I
}
9 Q% w6 v- J1 i3 D% s m7 E }
O2 P% V& [! | else if (xDir == "left") {0 V5 U: f& z4 b7 i5 w
if (xPos < (0 + BallSpeed)) {
. r* ? z. r! [ D xDir = "right";+ v1 f9 y( C$ `, e# J
}: i1 r" G6 {. f, K. |) l; X+ F
}9 t. W7 @ {0 x3 e( V3 O% r
if (yDir == "down") {) N: }% E. H( R' V) L+ U
if (yPos > (yMax - contentHeight - BallSpeed)) {4 F/ [! q/ ^5 U' P2 R3 q5 ]
yDir = "up";
1 w2 _: @3 L5 i2 E: d& t }
. X# o2 L2 p; A1 P/ J# J8 R5 E" k8 C }
/ A& { e0 G' j+ g# w1 L6 C2 C else if (yDir == "up") {7 x. z4 Q4 u8 T
if (yPos < (0 + BallSpeed)) {
q- ~! ]' S2 p. I6 L yDir = "down";% {+ [' P) G2 [4 L7 N: d
}
. `4 e) u1 f4 Y }% a( E/ x/ O& H. x; _0 t) c
if (xDir == "right") {
" W2 ` N) Y# \1 P: `8 W xPos = xPos + BallSpeed;( o5 K4 @4 s6 X8 `7 D
}5 F* Q5 N' h2 e& S+ d% l+ X9 h
else if (xDir == "left") {
. `- p6 Z9 R& f, M) D xPos = xPos - BallSpeed;
( [5 r2 b" t0 p/ u% U/ I }9 N7 Q! L! C0 y
else {
9 ~7 o, ?9 U! N5 w3 { xPos = xPos;) ^2 i' L! B2 r
}
8 a0 S7 r: `8 C! _! m, Y' S6 V, a if (yDir == "down") {
! A" q2 S, [7 P+ S yPos = yPos + BallSpeed;
: s' W& W, z* v- x K# \) ` }2 r/ }2 f7 v0 a1 A. {" `4 q5 v4 A
else if (yDir == "up") {
2 _/ a7 V7 B' @' V yPos = yPos - BallSpeed; C* N, K: f* w- @6 ^
}0 S4 E- ^$ Q( J1 }. ^' R- o, f
else {
8 ^% P; _8 A# E; p" k% I4 O8 X7 p yPos = yPos;# j: R& a9 t9 n; E
}, o/ E6 z. H8 |+ F; [* h F! e
}7 C" P a8 @, D0 q# D; x. d
2 m ?! H9 C ifunction hidetext(){! s' n. E. D: v# P
if (document.all)
( M& d& ]3 L" ?! s4 B! Ksupertext.style.visibility="hidden"
* S* y& W% \& Nelse if (document.layers)9 I9 y$ M5 G' y! N" {' W* P, |
document.supertext.visibility="hide"
6 M% C7 [8 e/ |4 D# h% M) EclearTimeout(animatetext)
5 E3 p" A+ h; v8 W}
_( G" E7 h9 e) F) X
) ^8 P+ D7 Q* o/ Gif (document.all||document.layers){, O R* u% B, a0 M$ ]+ ?6 E
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; B1 l% }, d1 Nwindow.onload = initializeBall;
+ L" d: W) ^! k) C+ v+ d( f& N' s6 awindow.onresize = new Function("window.location.reload()");
2 k: i' L- ~3 ^" k- w0 U}$ o$ S% V0 _9 _" r1 B3 M% E
& L6 \( N$ B* u</script> |
|