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

|
网页之不断弹射的文字-特效
<style type="text/css">
# r# u! a, C& X. A$ M/ c#supertext {
3 B, y9 [) \6 x7 hposition:absolute;7 }# f& B+ Z& t$ h/ g" k% J
left:0;
+ D u3 H( @5 f6 b1 ]. E0 [top:0;% Y/ Z( {; A" T" L5 Z
visibility:hide;) C8 S1 Z: M2 W2 c
visibility:hidden;
1 r3 ~1 H2 d3 }6 ]}
3 s; r6 T V, T4 @7 ]; F2 F* H4 L</style>9 T% D# a0 t* h3 s# o
<script language="JavaScript1.2">" x9 J7 G( p2 z4 S+ y: N. ]) k
<!-- 改变下的字体的大小。颜色-->% M2 M4 U5 l- C: G% Q# k
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'- n# C6 i; m4 g' f
var hidetimer='';/ N, ]9 m0 o: S0 B1 `
<!-- 改变下的弹跳速度-->/ ~* y1 `6 ?) L H9 s: m; l
var BallSpeed = 20;: [3 j, H9 j( B; b1 P4 l! T' U! J- A) l1 ]
var contentWidth;. s6 P1 v+ B; }0 q' }4 s( O
var contentHeight;+ j" C" \/ i" A+ u% C
var maxBallSpeed = 50;
. w% P; a: x( x" B6 f; ^. J F9 K; ?, v) q3 W1 }% N# I8 V" z
# T& T3 v+ I1 M( I$ T# {6 zvar xMax;7 Y7 i% E8 q+ k1 v
var yMax;$ R4 V* D1 Q* k& ?+ |
var xPos = 0;
4 [9 c, j/ Y3 r& tvar yPos = 0;8 g0 Z- c# Y3 D) o6 X) ^
var xDir = 'right';
5 G2 l( ?! V4 svar yDir = 'down';- p& `6 ]9 t( o1 o0 B6 O' r3 l
var superballRunning = true;
, X$ I3 l1 F( c3 m) qvar tempBallSpeed;
; J- F% ^ `. ^# B/ g! w: Vvar currentBallSrc;5 `, g2 z- B6 k6 F A
var newXDir;
* U. q$ I' q# Q* W- g$ Y2 j H, Nvar newYDir;( t1 ?/ e4 I; V! M4 r0 v- ?' l
) {+ N% M0 o xfunction initializeBall() {* S5 y0 e# J- g: w4 `& b
if (document.all) {; s+ D7 F4 Q0 ]) c+ n% C
xMax = document.body.clientWidth- e" z/ }2 t6 H* d0 [
yMax = document.body.clientHeight6 n0 Q5 X8 ?( G$ {; s" [
document.all("supertext").style.visibility = "visible";
' O O+ q* ]9 y% u6 {$ Y contentWidth=supertext.offsetWidth
9 c! O: [ T; k/ F4 ~* V/ s! J: ? contentHeight=supertext.offsetHeight- x8 I; i9 T5 i5 g
}: k: q/ |# z0 |) q7 l/ G
else if (document.layers) {
* C- D$ n" R- Z; r xMax = window.innerWidth;$ C. Q l% N" J' d: r
yMax = window.innerHeight;
# L$ w! P m6 S contentWidth=document.supertext.document.width
% Z; r ?. `) [' k/ E% I contentHeight=document.supertext.document.height
% Z1 `0 d- P) n* L document.layers["supertext"].visibility = "show";
2 r& i* @- J5 U4 C y! n1 i }9 \. n" m1 m5 @* b/ s" N. x
setTimeout('moveBall()',400);
. I( Q% c- l( f3 o. E# G if (hidetimer!='')6 W. [6 y1 b) y7 ]- J
setTimeout("hidetext()",hidetimer)5 w' m% G1 h' K; Q9 I' }6 v8 I
}
0 q0 x( K$ b9 }2 K7 v. j6 L( ^5 e$ w
function moveBall() {
2 H4 |9 E5 @+ m if (superballRunning == true) {& K4 r2 W6 t* C
calculatePosition();" [( ^) `4 x; S# Z, s
if (document.all) {
1 y/ B, ^4 R$ ^- L3 Z* ]$ M document.all("supertext").style.left = xPos + document.body.scrollLeft;+ |" L" o t, B9 a% z0 d( U$ \
document.all("supertext").style.top = yPos + document.body.scrollTop;
6 P: M+ J5 h. ]9 q) R }
# a0 l0 S2 y% S: X9 k else if (document.layers) {
# a) H/ G0 ]& f; D document.layers["supertext"].left = xPos + pageXOffset;9 Y$ C, [2 v% W8 M" e) Q" A8 M
document.layers["supertext"].top = yPos + pageYOffset;" j$ U& v2 q$ V$ s9 C, P
}9 g P( K& @. s
animatetext=setTimeout('moveBall()',20);
1 E* F# ~, {, }4 U7 Z3 b }( ? h5 W/ K4 v# o
}' D# f- `7 K. ~; v8 c
: I& u' z/ [: O" H- ?# ]0 o/ G, Nfunction calculatePosition() {
7 p5 Q# R4 d* q! ]& l Q, k if (xDir == "right") {
& k$ p: x8 c- _ h if (xPos > (xMax - contentWidth - BallSpeed)) {
- ?7 W2 b' h6 K7 G1 Z/ F7 g+ ^ xDir = "left";
6 t6 L6 s \. p: p }
/ _$ z1 t5 _: U+ l6 _# W' g" G @ }
' H, d3 ?6 B: A5 p# L else if (xDir == "left") {! x0 t3 Z) e" {( J8 X* C
if (xPos < (0 + BallSpeed)) {; k. w( }, X" W. s$ n+ F: I
xDir = "right";
1 M& v, v, B- ]1 X& X- Y5 v& Y } }2 w2 z# v3 r# o
}. _7 A" B, E* |
if (yDir == "down") {; H% R. g3 d# B# z
if (yPos > (yMax - contentHeight - BallSpeed)) {! T* {1 c& P# J4 g% C8 Y
yDir = "up";9 |: Z* V5 O7 e/ A% u
}
( m ^3 y0 z9 c% `# S- T3 M0 ]5 k }
1 u- @. y) O K0 B else if (yDir == "up") {1 l9 R2 W! B; b( j$ _9 K
if (yPos < (0 + BallSpeed)) {- s* @; x7 i! t
yDir = "down";4 t3 `% B! `/ s- j3 r0 Z1 C4 Y: Q
}
* z3 r( _+ I! i- U% [# y }
, L* U3 b9 Y, ]5 h/ Z if (xDir == "right") {9 ?; H9 {. w) H
xPos = xPos + BallSpeed;8 i$ @3 C$ l2 j
}
4 n! ~& I: a1 s9 @ else if (xDir == "left") {8 R9 a7 f' n$ s' J9 t$ |
xPos = xPos - BallSpeed;$ t0 \' }4 ?: a8 Y4 F1 R+ \
}
- T- {! a. b* D9 W+ [ else {
2 U% {" o4 n5 l. p' A xPos = xPos;
' P4 z; a0 j' b5 H' a H3 I }* d M k" P2 Z5 i
if (yDir == "down") {
: X0 p3 Z/ O Z! V. E: r' m yPos = yPos + BallSpeed;9 \8 s( Q+ i- M! j$ A
}/ j8 i0 n |( V3 b
else if (yDir == "up") {4 P7 L; W& t" v! R
yPos = yPos - BallSpeed;/ j: i) X; s* ~; g
}/ J# l: m' Y0 y% T T1 {& W# ?! t
else {1 x% H- ~: P5 X8 D! n3 ]- |4 b4 x! O
yPos = yPos;
P( p# r6 M8 ?9 D }) y# S; n8 t0 g. a, g& P& z' i6 M
}
$ r5 {( a7 ^9 W5 i& U% q" r0 ?9 q! H% b* e% o
function hidetext(){6 X m1 o* W" y( Z, \! \, F7 N
if (document.all)# g0 \4 }" h% S0 }' U
supertext.style.visibility="hidden"2 T1 ^1 y6 L4 C, `
else if (document.layers)% ?' w# m& S4 Z3 K4 w
document.supertext.visibility="hide"8 V' w; z+ u; R5 Q
clearTimeout(animatetext)
0 ]; J* E, e2 b/ M}
/ x8 @8 ?) ^* Z: y2 y ~$ I H8 j& F- m7 e
if (document.all||document.layers){" s- W* Q8 H4 b
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ K! N2 C9 X: y0 L% dwindow.onload = initializeBall;5 ]$ P" G# B8 F+ L2 O' F, }$ `
window.onresize = new Function("window.location.reload()");
7 V4 Q' H5 j% t! C+ y}; I+ Q' S3 s& ~
$ f+ ?2 q7 K# f7 k
</script> |
|