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

|
网页之不断弹射的文字-特效
<style type="text/css">5 G4 q: R5 F1 w* j9 W- Q1 s
#supertext {" T( b4 P9 e/ I
position:absolute;
1 U- x1 I/ U3 f- l Aleft:0;
9 B6 n1 d7 P( t5 G) l8 A% \top:0;
* [1 w6 {6 h0 O7 S8 p9 H, e( N* wvisibility:hide;3 f$ Q% L) y/ v, ]8 S. d
visibility:hidden;
4 O2 t N- `7 [}0 J; V2 t' G3 k) K: K! e9 C7 Q
</style>
8 U8 u- C2 M$ Z% p<script language="JavaScript1.2"># d) {% Q# c; U& j! N
<!-- 改变下的字体的大小。颜色-->
% v( w0 D* @$ @% Pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
# `, r, Z) y; {5 T4 `0 d; G9 D) dvar hidetimer='';
9 N$ l# @: [( }<!-- 改变下的弹跳速度-->
7 D! W, B! ~6 M9 ^+ D# tvar BallSpeed = 20;
8 a; e7 S5 b9 {! S; x) Yvar contentWidth;0 @5 ?: G: I) x6 B
var contentHeight;
. R4 y2 J" ~% J( F( uvar maxBallSpeed = 50;: e6 m$ {1 q) z D- O4 r4 _
& k2 b# o" o- |8 Q$ Y& ?+ y" g9 `& [+ n- e0 q
var xMax;2 F* e' u% X5 R. t O1 [
var yMax;
7 @# D- P# o& pvar xPos = 0;
1 C: g _2 }. q& _) f3 f: Cvar yPos = 0;
4 y$ {. i. t: n9 f$ u3 evar xDir = 'right';0 x5 ?* d2 E* ?7 s" i
var yDir = 'down';
: h3 o" B: M" t4 U, Gvar superballRunning = true;2 Y4 m( q1 d% t0 d
var tempBallSpeed;; N) v" ^) u( X% z [
var currentBallSrc;
2 i! a1 n" Z fvar newXDir;& F9 U, l& `/ c% Y7 W" n
var newYDir;
/ G) Q" I2 o& P- {/ z9 q
4 S0 u( I2 u7 rfunction initializeBall() {
/ t+ r7 s4 ~% Q Z. z if (document.all) {
& m# ?8 |6 D, P [) @ xMax = document.body.clientWidth
( D% y* {# z( U+ S4 {/ A# \ yMax = document.body.clientHeight; l4 |6 m F0 g( x- g
document.all("supertext").style.visibility = "visible";" Y `: H( p( |1 T* `
contentWidth=supertext.offsetWidth
$ z4 u3 f% ~" }; w2 b contentHeight=supertext.offsetHeight+ ?( Z# l$ m9 _/ p0 E
}
% i7 ~* S: ]# S) S& _4 U else if (document.layers) {
) F' |% ~+ |4 _+ b. \" K xMax = window.innerWidth;3 {7 ?& P. j/ }- ?. Q: g3 f" _
yMax = window.innerHeight;
3 P: s5 P& O8 ~ G! E6 s- ~9 W2 k contentWidth=document.supertext.document.width9 j: d$ B' @; Y( t# F) }. z
contentHeight=document.supertext.document.height4 u2 F) G% }, H. c
document.layers["supertext"].visibility = "show";
8 z5 N- a/ t' A) y: c }
0 t, `: @; g" P% y" c setTimeout('moveBall()',400);" z$ F0 U5 X+ a5 V' N4 @ d, m
if (hidetimer!='')
) j7 r- D$ Y4 x' k setTimeout("hidetext()",hidetimer)
; M t7 M8 P- S8 q) z1 Y2 U! e }" \6 s8 @6 x3 ^8 x
* s! T6 s2 ?. }. g1 g% N
function moveBall() {' M0 m& S% K( \
if (superballRunning == true) {! j; C T c& n# i* K( n$ I
calculatePosition();
! `9 S4 O8 B5 v7 N if (document.all) {9 h5 p+ k! R0 o' t& F" k
document.all("supertext").style.left = xPos + document.body.scrollLeft;# {5 ]7 ^" Z- u7 q% d
document.all("supertext").style.top = yPos + document.body.scrollTop;/ ]2 V- ?9 g' i' w5 O) G( p
}1 g! E8 Z9 a; b9 L: w+ I7 a1 o
else if (document.layers) {3 f4 D( k) ]" ~( f! U
document.layers["supertext"].left = xPos + pageXOffset;# M8 o% {$ c% N8 D) x0 G6 s
document.layers["supertext"].top = yPos + pageYOffset;
( W* l. ~7 B) N: A) ^" k }
6 y" X! Y4 l8 s5 f5 ~# x" o, F, o animatetext=setTimeout('moveBall()',20);
6 r- [% m# A2 t' H: m }
& u1 B: V: I6 [% A7 a }
3 I) O# V) o( P4 x8 R+ W; v- r" {* F8 Y
function calculatePosition() {+ l% C) V1 L2 R" M+ m
if (xDir == "right") {0 Y6 |9 H+ M O% _7 V+ m. v
if (xPos > (xMax - contentWidth - BallSpeed)) {
# I1 W3 I5 ]6 `2 B, E2 R xDir = "left";1 l/ p9 m; d7 J) W$ V8 f
}
2 _( S8 f5 S/ s7 n C }
* j) C" u) q4 A1 T# ~( s# l3 _ else if (xDir == "left") {
0 f6 a, f2 Z" }1 r if (xPos < (0 + BallSpeed)) {
: J$ E2 |- M$ s% y8 u: m* o xDir = "right";2 z" d) e* y2 N; }, W' P
}
* g$ G5 P0 J% K2 [, x9 a. c! ? }
$ R7 c7 S0 m0 X0 ? if (yDir == "down") {
B3 N3 X" G, Q6 w E. _ if (yPos > (yMax - contentHeight - BallSpeed)) {
/ B" ^6 t3 ~( G. B) Y yDir = "up";
4 f; t s/ i* l }
3 S9 }" S' o0 N) \( m8 m }4 M, N3 t8 K1 g; L/ l5 N: b% p: o5 f/ f
else if (yDir == "up") {! ?0 T, h; h2 J! X7 q4 [0 @- [
if (yPos < (0 + BallSpeed)) {
! b6 ]5 M$ m0 O* h+ H& @8 g; _ yDir = "down";. ~9 v4 L9 }; s) I* _7 K$ \
}2 X0 M0 O z; C
}" ?' _+ z. f: g0 \- Z
if (xDir == "right") {6 T. b2 p' H W# Z9 P
xPos = xPos + BallSpeed;
) P* d& G# u" |( d6 v }
4 E2 N* Z4 j6 ^$ b- E else if (xDir == "left") {% |+ ] _8 Y1 i
xPos = xPos - BallSpeed;+ g+ a- `" D5 ^
}
* B7 K4 ~* F j: \5 n- a, s6 q* [. k else {
$ f' w3 F2 |2 v$ V6 m xPos = xPos;( ? J2 a& _4 {/ J, N- p3 ^
}& o/ K) P0 [( L4 `3 _ P/ w; @
if (yDir == "down") {
# H1 [2 t' R t" T* t! @5 l# T yPos = yPos + BallSpeed;/ U5 w* G" g- M0 Z& k8 o( p
}. S. f% s) j- J: h
else if (yDir == "up") {
1 C- L' H Y" j. V) J4 j yPos = yPos - BallSpeed;
! E& l5 F9 }1 U. S }
Y* A5 ?: l! }/ S; J, d else {$ J8 m$ W: Q2 d% e B% }
yPos = yPos;5 Y1 [) W3 ?4 ^4 R; j* A
}
! S7 P% O: h/ W7 k }
( ]2 ?; O% m, u$ O2 [* ^) B! i8 L3 A( V
function hidetext(){0 d. |, _$ [' z' G0 G. ~' U2 t
if (document.all)
, ^. _: A! f( \5 S) Hsupertext.style.visibility="hidden"
# H& R3 a T0 R5 D. p5 B# kelse if (document.layers)+ |+ u' d+ \2 i" c# @& y4 _
document.supertext.visibility="hide". M4 c- y. N: x* X- r0 d% y( R$ V
clearTimeout(animatetext)5 \8 }# Y4 C* q! J/ ^! q" o) N
}
* K+ s. S2 I" X0 k$ ^
) F/ D9 E+ ^! ~' p1 iif (document.all||document.layers){
% E* N7 A' W8 Rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 M' [5 P. z8 h0 Ewindow.onload = initializeBall;; \! P- I/ [( k0 J! }
window.onresize = new Function("window.location.reload()");5 `) r' D" n0 q% g, ~9 |6 M: o
}4 H7 s; `: `8 w+ h# I
0 f3 P" B9 L8 _% w6 ]8 [+ T/ g</script> |
|