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

|
网页之不断弹射的文字-特效
<style type="text/css">
6 n+ M/ _& f: N. u+ b+ H7 b#supertext {5 Q, ~8 Z5 [) D
position:absolute;& I7 j8 `" w) C$ T; H$ k
left:0;* T' `0 f5 z3 L; p
top:0;
' G8 F3 t$ l* @( i. ~2 uvisibility:hide;
; D% N8 l5 u0 g4 m* n7 b/ Evisibility:hidden;1 `4 p$ h/ B7 w+ ^
}$ x( _; B) b8 d/ G6 K' W
</style>
& y+ I! Z4 @2 \<script language="JavaScript1.2">$ p' d3 Q+ I' C9 n$ q6 k
<!-- 改变下的字体的大小。颜色-->4 c l' c, Y* [# C
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
8 y4 Z) L M3 u4 O% i1 p6 cvar hidetimer='';
# q4 e' D9 h* W5 R: z<!-- 改变下的弹跳速度-->
1 W. o3 r6 y% v/ x% |# Lvar BallSpeed = 20;
5 U# N. x- K6 {var contentWidth;
& H) A4 U$ y" ^0 fvar contentHeight;5 Q+ s0 ~7 q# c ~$ L/ e( n- c
var maxBallSpeed = 50;
7 H( h: M6 {0 n3 t) b% I, ], p2 q. j% V& B
. z; e5 q5 T8 \% D( ^- J \) k
var xMax;
3 H0 S3 o, T* g: f$ ~var yMax;* @! M% S' b) q u% n' d. Q* A
var xPos = 0;. |! f! {/ h0 E3 q* Q
var yPos = 0;) {* O" R8 z5 _
var xDir = 'right';3 Q2 h1 X% ~- G/ b
var yDir = 'down';
* P2 }9 Q* q+ S: R9 y1 P* Cvar superballRunning = true;+ B0 V' b7 W1 n5 L& t
var tempBallSpeed;
. N5 ?# S+ n' evar currentBallSrc;
8 [8 g9 D, j7 D nvar newXDir;
1 b N1 O/ j! hvar newYDir;4 p4 r" X f F1 ^" d
" M3 f0 F" |; c2 k2 i
function initializeBall() {
7 O) w4 c5 I7 C+ v A+ ^- Q if (document.all) {$ d% W' ^5 B; z' F; Z% u, G) E
xMax = document.body.clientWidth4 p8 V3 L8 u0 R4 ]
yMax = document.body.clientHeight0 W4 C" q/ E3 s; k3 k
document.all("supertext").style.visibility = "visible";
# ~; Y3 D4 j# Q- k- a& R; l contentWidth=supertext.offsetWidth
7 U9 V. s0 w- }* b6 i9 j9 l contentHeight=supertext.offsetHeight' Y$ L0 u: Q k) z# B4 n5 C
}$ x% p' ]! P/ v. o8 M! f9 ]
else if (document.layers) {) ?; Q9 S: m& U! Q/ k; D
xMax = window.innerWidth;1 q8 x8 H: r2 t6 W% E
yMax = window.innerHeight;
( i* _3 B% B4 F- m$ ~& z; w contentWidth=document.supertext.document.width" v2 x$ o) y, v- ^6 R& j9 O
contentHeight=document.supertext.document.height" q8 P. W' h: _+ d$ _3 `* s/ K
document.layers["supertext"].visibility = "show";
, F$ T$ I2 Y! [$ k% [* X1 B }
+ J1 t' W* \ G& h4 G( `/ y) m setTimeout('moveBall()',400);, k8 A+ B' u; X" c3 C1 b0 M
if (hidetimer!='')& I0 V; P# m c+ r- a; k
setTimeout("hidetext()",hidetimer)
! i) ], d; ?: Q' h" b" h8 i }
v; g$ }/ P2 W: E& H z6 I O; B/ F' t1 c6 ?7 Y9 i p1 y: L
function moveBall() {0 I* X+ _ i" L2 I3 P
if (superballRunning == true) {
" ]1 ?! z8 E0 x- M, C+ c/ ] calculatePosition();3 L- J5 {* S! n/ c. c
if (document.all) {' P+ M# P$ Y. d
document.all("supertext").style.left = xPos + document.body.scrollLeft;7 v1 G- J: P9 V o6 ?8 `7 e
document.all("supertext").style.top = yPos + document.body.scrollTop;
9 Q( r4 ]. _' f; z( n% o5 b }; W D4 u' I9 m# d: h T
else if (document.layers) {- u/ f5 S( n, p# e! g1 _8 P
document.layers["supertext"].left = xPos + pageXOffset;
- X! A+ d" l( Q0 S document.layers["supertext"].top = yPos + pageYOffset;
2 d0 q7 v1 L! ]" Z% ] | }
9 D: `( A, j4 e. {: F animatetext=setTimeout('moveBall()',20);* W- u1 P4 j. `5 w1 r
}/ a f1 D! j- @. n1 {4 ~
}
! S! R- E8 ^0 q( `6 c: y2 \9 k5 H* C3 }: c
function calculatePosition() {
' z" a# M3 E* Q! I! o- r if (xDir == "right") {
( B) t6 r V! a! P2 M if (xPos > (xMax - contentWidth - BallSpeed)) {
0 o0 E& J. s8 x) p S0 u) E xDir = "left";
! Y4 d# ^) l$ Q+ h, d }- W1 I9 H& l+ J8 b
}
$ U3 n# y; P1 l, @2 T0 K else if (xDir == "left") {
0 M; A- L5 y6 l6 d2 U D if (xPos < (0 + BallSpeed)) {
) H+ A2 Q; j: z" I xDir = "right";- D! o, l2 V4 n) f. W. [" V# x
}4 f9 g, v( a$ e# I1 g
}% q1 E5 u+ N; B- Q. y/ P1 e1 _
if (yDir == "down") {
: I5 O7 ^4 D$ v if (yPos > (yMax - contentHeight - BallSpeed)) {9 X. i J% D. F
yDir = "up";
4 v7 G' j+ D; T! `/ E3 ?) P: c* X }2 J+ ^+ p9 S, l& e- i
}; L9 I- w" N8 x5 v4 ]' |3 g( h
else if (yDir == "up") {
* l, Y3 |8 v5 }8 p if (yPos < (0 + BallSpeed)) {
. ?+ i3 A W9 b4 q ]3 P yDir = "down";
( Q! ?4 {4 h) | }
6 Y1 f7 ]' J7 s( Y/ s } \+ T3 W, f U3 K% ]3 J
if (xDir == "right") {: N. e$ }" O+ r8 {, j0 ]
xPos = xPos + BallSpeed;2 K7 E; }: p( t- j) [1 ?6 J
}6 p. Y; z1 M2 I% X
else if (xDir == "left") {+ o5 T4 h1 { U( X$ }' _
xPos = xPos - BallSpeed;8 s" }4 \- R B$ z. N; r
}1 L. V, o2 [+ A' Z4 X3 K) z
else {
8 j1 {9 H9 j1 J7 J9 I8 O xPos = xPos;& e7 W f& z F
}
& g! u) ~; Z. I1 P3 Q* H' b; Z( a& q if (yDir == "down") {
6 X8 N% [5 o0 y yPos = yPos + BallSpeed;- c' t0 K+ y: n7 u
}
: h6 O6 @* G: I5 Q0 C8 G else if (yDir == "up") {
# j8 H2 G% ?* x yPos = yPos - BallSpeed;
5 T& \4 x6 }5 K8 | }
/ } k/ w7 k9 V" S6 C9 W else {
u n9 L. c. ]1 q yPos = yPos;
# R6 L* E! o) n/ N+ ~ }$ M; ?3 [+ d! C3 V/ m+ J+ u
}# K" A# P+ b! H- n
2 V* _( @+ I2 s2 U% Z9 L3 Dfunction hidetext(){. w, p! w8 Z8 G8 z
if (document.all)
9 `4 C7 ^: s6 W: Lsupertext.style.visibility="hidden". w. a; N1 _% {: G% R4 b* p
else if (document.layers)
: Q6 z& f S, X9 i8 p* rdocument.supertext.visibility="hide"+ s# h/ a+ K3 T+ z
clearTimeout(animatetext)
( {& `6 w) F) e. v}
0 }& Q5 x* Z/ `
* T1 u: H9 L- t8 P7 {$ \* tif (document.all||document.layers){% I7 T7 V/ d8 g1 M' ]
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'): r2 V! U8 y" g8 \/ R
window.onload = initializeBall;
, t3 R- Q6 C, C3 C$ l% Zwindow.onresize = new Function("window.location.reload()"); D' C6 O: I, u; b8 @4 d5 o- N
}' l- E2 T* x5 |
7 E9 J' B! L1 Y; ~$ x9 C</script> |
|