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

|
网页之不断弹射的文字-特效
<style type="text/css">, }" O8 T; {: T* P8 x6 G5 n {
#supertext {
+ N. z4 Q! B N; h9 Iposition:absolute;
9 N4 k" P7 l4 P- K' R# I7 c) cleft:0;
9 R- Z. J) F' ?& l8 i" Ztop:0;
" i# e) w+ ` ivisibility:hide;# V. x/ ^3 m- L, W( e( X
visibility:hidden;
! @- d$ O, ]( ?/ T- L}
5 p! N: G0 ~3 f) C5 W) S</style>
V/ t. W" |- |' \7 g+ g$ A+ `/ q1 Z: V<script language="JavaScript1.2">
2 f1 y: b4 P4 y9 L- D- c<!-- 改变下的字体的大小。颜色-->
$ e7 o1 @3 {# h) L: ]- {; X6 Xvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
; H3 Y0 _* G3 y* M7 r" \var hidetimer='';
+ q9 e6 C n$ H5 @6 A<!-- 改变下的弹跳速度-->
6 e/ N1 c9 x8 Q& C5 Svar BallSpeed = 20;8 h+ T& W+ h: T( J9 g
var contentWidth;
, y- a$ s' k$ ~, r% L& U2 F7 `- kvar contentHeight;# f, u3 l1 V# w
var maxBallSpeed = 50;5 D& d/ Z% q5 y9 Y5 j9 ~
c) } G7 Z+ j6 H: k3 m8 S# {
/ u' L/ b! A e
var xMax;' r4 c+ E- _( a" h. Z0 x
var yMax;
" l( X) j- Q4 h) C9 P; j9 mvar xPos = 0;8 i! c6 N& ^0 V5 a
var yPos = 0;: O2 Z- k6 g0 C; L$ u& K: U
var xDir = 'right';
5 i# \ f2 ^7 B t+ w3 l/ Avar yDir = 'down';
4 G: J. d" S( e9 C U h! M+ p# w' svar superballRunning = true;
$ Z! u, ^4 K" h \" tvar tempBallSpeed;
0 c8 k' O+ d9 y3 e' r& f& Vvar currentBallSrc;
9 ^* P! e T8 s% Vvar newXDir;
2 i6 B( q0 Y9 C, q5 Cvar newYDir;4 N' q( r7 z) Q4 L0 X: L) ]
6 [' W. o+ l; K4 P& q# ~0 A4 afunction initializeBall() {2 B/ C/ E$ {! l9 \, f3 P
if (document.all) {! p, [9 j5 W6 k& C4 r* o2 K. U6 d
xMax = document.body.clientWidth/ ^6 t; ^0 a1 N, t+ ^5 \% Q9 u% k H
yMax = document.body.clientHeight; \& w. @5 l; `5 b: G
document.all("supertext").style.visibility = "visible";
1 F$ {0 S3 G2 `. P4 O8 F( R contentWidth=supertext.offsetWidth0 L+ X( X2 t& x4 L
contentHeight=supertext.offsetHeight; K9 ~7 y. W% n8 e/ w* `+ k
}
9 o, a6 \4 [' J+ ~5 w- r I/ `9 x else if (document.layers) {% \. a) N/ X0 @ W9 V
xMax = window.innerWidth;
) `0 ^; \7 A1 }- J* C5 k yMax = window.innerHeight;9 y3 P+ o1 k, u9 L( ?) ]# u) B
contentWidth=document.supertext.document.width% b- `- f* q, K- K: H, @
contentHeight=document.supertext.document.height& G" p d0 s& s2 y2 h1 t) v3 v
document.layers["supertext"].visibility = "show";; N: L& E8 i1 v1 Z! V
}
1 F5 G# ~9 `$ \# e- I/ E setTimeout('moveBall()',400);
/ [1 v. G9 @) K# r* |! i- W6 a q if (hidetimer!='')4 r' T# I$ n) W9 ^
setTimeout("hidetext()",hidetimer)
2 k$ O* g2 i' G }
9 X. n) p+ S; m6 f% e) u
/ S3 f' k: [5 K) V! i, Mfunction moveBall() {" J% ^' i' n9 G, j1 B/ s; j
if (superballRunning == true) {
: `& T- R% B3 U3 E calculatePosition();
4 w* g: I& S0 C7 _% Q/ O4 z if (document.all) {6 G: m6 J9 |- O
document.all("supertext").style.left = xPos + document.body.scrollLeft;$ r" g1 Z: S8 |- \) m& W
document.all("supertext").style.top = yPos + document.body.scrollTop;! r& H& E" H0 O9 U
}9 _- v1 c! L# ]6 g# w, b
else if (document.layers) {8 [& U# w2 v% L
document.layers["supertext"].left = xPos + pageXOffset;
% z) C* }; ~, \! A, [$ p document.layers["supertext"].top = yPos + pageYOffset;3 r/ X& Y( ~) ]3 W7 k! V
}1 F) k6 D* R4 P$ s
animatetext=setTimeout('moveBall()',20);
1 p) c: b0 s& Q! h( L }) x' x3 d: Q- K2 d0 n$ }4 ]: {& U
}3 _$ s: t$ {/ d* q5 j
! ?! w% r5 t, }
function calculatePosition() {1 B+ b$ k2 h8 A
if (xDir == "right") {
& ]4 S8 e/ }! {3 A1 E/ [" d if (xPos > (xMax - contentWidth - BallSpeed)) {
' X; ^6 l/ E& |2 n! K xDir = "left";+ {5 T1 B# H- W
}8 Q3 R# L' g- g7 L7 y- L
}* s( L+ w% M2 d. ]
else if (xDir == "left") {
0 k8 V3 {8 t* A! T1 y if (xPos < (0 + BallSpeed)) {2 H. g/ C3 d7 C5 v/ A! B
xDir = "right";
) @& n, c9 n! t5 d8 ?5 V }
/ V$ w9 @4 A' V6 [ d5 G }
) j- u1 _0 D% } if (yDir == "down") {+ _9 I$ j/ J& ^- E) n
if (yPos > (yMax - contentHeight - BallSpeed)) {
j( z4 C5 } x+ A7 u! f yDir = "up";
' n1 A2 Q' j7 y, m }5 K* D) ~: q! f4 q
}9 o" I6 z, r+ A; g+ E0 R
else if (yDir == "up") {
: i: z \$ |8 n5 N if (yPos < (0 + BallSpeed)) {
+ }( Y! B" i2 l6 }, f$ h. u yDir = "down";
5 o' c8 n: E" E ^ }
( ~& R1 n3 Y3 B& x: Q# k" O }; X' I A+ ?1 G8 W: i% @
if (xDir == "right") {! `8 p* E1 J/ [' N( G7 Q2 ~6 N
xPos = xPos + BallSpeed;: ~5 ^! z0 Y% q% Z% p- X
}
* W" h9 A: Y4 P) e else if (xDir == "left") {7 @% ]9 t8 a( K% d
xPos = xPos - BallSpeed;
9 a/ s" d4 m; f- k" u' K. c6 u }* m& P$ S$ F# z* Z
else {" _/ [& O0 t2 N- k) T/ ]! s
xPos = xPos;
: r/ X* y+ i6 R$ j4 s) I6 | }
; e7 ?# b- R+ Z1 f1 |2 o( A1 j if (yDir == "down") {1 }9 }* _: V7 o$ d* |: v( ]
yPos = yPos + BallSpeed;
5 @! }9 ?' _5 |* V6 [ }
) O6 @ o$ e3 R2 e/ H6 d else if (yDir == "up") {
9 I4 S: }' ^" a yPos = yPos - BallSpeed;: ]! L* j5 E1 W; C
}4 L$ V; w+ ?2 F& `
else {
7 K" n. ]1 A9 B+ ?# j1 Q- ` yPos = yPos;( |+ ~: @% Y. D" ]
}# c+ d6 R7 k# Q7 {
}2 o6 O; K4 Y+ ?' R. b4 S; s! @5 W- l3 |
4 l j! x5 j: xfunction hidetext(){' I6 K9 x4 S7 i
if (document.all)
& D" S2 Y! O- k) p. h+ jsupertext.style.visibility="hidden"
' U M$ l4 H5 Qelse if (document.layers)& ^5 Z' r+ h4 c
document.supertext.visibility="hide"
5 O' M0 ?/ _, F: A0 JclearTimeout(animatetext)2 c% i: c# ?" ^2 P# s1 R' }
}0 y$ U& @. U6 N- z
: H1 I" V2 z% }- A
if (document.all||document.layers){' g: f3 N @) M3 c" ]
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')8 O1 Q, Q$ q% Z0 o# D9 l1 n
window.onload = initializeBall;/ ~) E& ?- a: o. V* [3 X4 Y' E
window.onresize = new Function("window.location.reload()");
' C' |6 N( j- a' O$ H! H}/ m/ }& d4 i# T" Z. \3 J
, z1 U6 C; _: B7 {7 J</script> |
|