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

|
网页之不断弹射的文字-特效
<style type="text/css">
$ N5 P( N7 p4 s8 ?: a* r$ c* Q#supertext {
5 n6 E$ W# q. u: A9 w7 I6 X8 oposition:absolute;
: U' G3 Z7 D. e0 Bleft:0;6 U! P6 O$ E2 W
top:0;( G* N3 F3 E" l! ~% L, ]0 g
visibility:hide;) W! [. p" g9 R9 f' T+ R
visibility:hidden;3 p+ }7 _& H4 j8 w5 i
}) u; l- i$ @ Z& _
</style>
: r0 \. n/ V$ o' ]6 ?$ Y4 Q. h1 ?<script language="JavaScript1.2">
; F( w" c6 o# q U<!-- 改变下的字体的大小。颜色-->
, f- [: O9 Z7 nvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% [" k( g3 l; \$ c+ X L/ z' r
var hidetimer='';9 L/ A6 C# ^. o5 Y9 V: M
<!-- 改变下的弹跳速度-->9 I# Y# N. P! K$ x
var BallSpeed = 20;$ a4 E9 G& `5 c2 L2 I7 i# g. Z
var contentWidth;
4 @1 p$ w. b, ~1 Lvar contentHeight;
2 `' _! u2 m9 kvar maxBallSpeed = 50;0 b/ Z: P: M8 L5 ]9 T7 x
" o' R; e' h1 \: y, f% c& p
9 e( M( o- ^0 b( L' C' ^& S
var xMax;
2 W* T. c" t+ \- d2 G7 ^var yMax;
t4 ?2 R. C6 v2 |7 y9 W: Kvar xPos = 0;1 ?8 A2 K: E8 {' d( }
var yPos = 0; C, R# h1 W- v: D9 C
var xDir = 'right';
; [8 P9 w0 j' U$ D" uvar yDir = 'down';
+ o, y1 p Q) m1 D7 |var superballRunning = true;
( ]8 z5 E0 I* X* j3 e, v5 L" U" f rvar tempBallSpeed;6 ^& J8 p7 e: x, u
var currentBallSrc;
/ B, ^, a2 ~7 Q; @5 a, Y; D/ ^( Rvar newXDir;5 C; W/ b" o5 t6 M: F+ e5 V
var newYDir;# }# I! S0 R+ Z" P _
! E @* W& P4 C0 j+ R N. p
function initializeBall() {4 d' y( o5 W) v+ L" F
if (document.all) {9 U. `, a0 C" b( z* a! n
xMax = document.body.clientWidth
. H. h: V; B8 X/ p# o, } yMax = document.body.clientHeight
/ C$ I6 {% u* @& Y+ T8 ~ document.all("supertext").style.visibility = "visible";
7 i# D+ u# F; f- t% r6 U6 `- g# v contentWidth=supertext.offsetWidth J8 ~ B! S$ L0 I/ K0 a
contentHeight=supertext.offsetHeight* {# m- e$ I' X. ^: U; m
}
9 d6 c$ x5 X. Y2 D' b+ f/ l4 |1 Q& W else if (document.layers) {
0 V6 G O4 ?* m! Y( z2 G1 ~ xMax = window.innerWidth;
. h6 S) [& D* B j1 @ yMax = window.innerHeight;
5 z6 T. O' { G8 N+ H* M contentWidth=document.supertext.document.width$ Z$ w; ?9 n2 e' d) b# X9 w
contentHeight=document.supertext.document.height5 j, T% c1 o2 r$ s3 ~
document.layers["supertext"].visibility = "show";% [7 i% }7 h' G. m" G$ d J$ Y
}3 t! Y1 ]! J) c+ w
setTimeout('moveBall()',400);
+ @5 ?, J# b2 K2 y4 l0 T if (hidetimer!='')* n) { ], a3 }5 |
setTimeout("hidetext()",hidetimer)
^: Z5 K/ T4 q4 E/ O }' [% ^% }$ b1 _
7 y; P% h+ u) X' x: z6 e& y$ gfunction moveBall() {& Q: D0 x7 g: k1 b
if (superballRunning == true) {
( S6 |) o @ P _2 [( @ calculatePosition();& I! F% x9 i% F* M$ b0 z# K% }
if (document.all) {
7 D$ f M& ~& O- `1 G$ j document.all("supertext").style.left = xPos + document.body.scrollLeft;
, `" [# K- p: ?. g3 R7 r document.all("supertext").style.top = yPos + document.body.scrollTop;. j, Z: |4 E1 d0 _; U6 r9 L
}
# L4 k% @5 g8 f8 M- w else if (document.layers) {5 E$ @0 ~3 j, x3 i
document.layers["supertext"].left = xPos + pageXOffset;
- n" Q, X, i" R7 O document.layers["supertext"].top = yPos + pageYOffset;
! m9 H! e4 d1 Q% ]5 | }
/ B. H1 q1 i) I, J. s: P3 A# r8 ]+ l animatetext=setTimeout('moveBall()',20);4 U& H$ f- q2 h; r5 v
}
* [- e" d# T# L; S }! W4 |6 G) M4 o" o% x( `" P
4 O% S1 N5 V; [
function calculatePosition() {
6 B0 i5 @+ m6 u: f if (xDir == "right") {
- b" P: L* \. L if (xPos > (xMax - contentWidth - BallSpeed)) {% A% P4 S" x0 s6 j& v0 [. V
xDir = "left"; b. y, Q" M& @( S: o# v4 Y9 W
}
2 Q% D+ D2 p5 O }
4 x5 g% P/ p- G2 q4 D else if (xDir == "left") {2 ]4 U& e, V" t) S/ g: ~# H3 k
if (xPos < (0 + BallSpeed)) {/ N% A& V9 d- g
xDir = "right";( H" M) o+ J$ c. p! _" N
}
3 W- h7 N! z: W }' i# R7 X( v- u/ G. t; m' n
if (yDir == "down") {
9 H! K+ z1 K* ]8 |9 g& h0 i if (yPos > (yMax - contentHeight - BallSpeed)) {+ [2 A8 ` e8 s
yDir = "up";/ J8 Z \$ L+ E- y
}
5 _) v4 V3 u% z3 H! E* k0 E }* x5 y6 P. a" M# f
else if (yDir == "up") {' B- q% U2 z9 U l: l& d! @
if (yPos < (0 + BallSpeed)) {
& v- w1 j [/ n5 U5 P- ~* V yDir = "down";9 Z/ ? e: X4 B
}8 Y0 ]$ ~- o% U0 A2 \
}
, F' [$ U- @( V9 H4 \ K if (xDir == "right") {
& }& S" s* E: P xPos = xPos + BallSpeed;
3 X" Y; s. N1 i5 g }6 k& g: ]' D$ p, E* R
else if (xDir == "left") {
6 @2 H- q! S$ C xPos = xPos - BallSpeed;" F* T) j/ V0 |' q- N$ a2 t
}5 J0 _7 @' F0 t6 r: ^% n
else {' Z4 S: P% d: v7 v/ B' W+ Z: g
xPos = xPos;
, [0 A7 l" d/ p0 ~ }
' x: D" S( m; C: q6 Z1 i if (yDir == "down") {! |4 o, s+ q; M$ z
yPos = yPos + BallSpeed; L% @$ A9 i$ O5 a+ F
}( ?& I1 \; }& @. g# L6 {6 a% r
else if (yDir == "up") {( l) P% K9 b# }! ^$ A
yPos = yPos - BallSpeed;# E" E: a2 `4 e" m
}
. C: M# t r0 M4 l# w1 I9 t2 M else {- x' F. k8 C- D& k* f
yPos = yPos;. V8 ~0 g1 _/ K% l% @) K, }) l
}; @8 v; x' L2 I
}
% p% C) y. `: g0 h& C+ C
# M1 w) r# K: V% u$ P# ~function hidetext(){# Y) ^) E ~; u4 i4 X* m
if (document.all)3 h- d0 T8 g/ [7 M$ F% g2 [5 T7 o
supertext.style.visibility="hidden"2 }! {1 l3 j3 J8 K) A% Y# A
else if (document.layers)
8 d* `8 \/ u! l X, H) z b4 x) Pdocument.supertext.visibility="hide"% q8 r0 P% w# B" w' d# a
clearTimeout(animatetext)7 Y/ k/ K8 Y/ b4 a9 |# j2 n! g9 |" {1 E
}- ^5 T4 _; n( G/ p" G7 L
: v, y! c+ H5 u# H: B3 W/ e2 n7 O+ y! ~if (document.all||document.layers){- R6 j: |0 E: W* m2 w
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')$ o) Y) O5 w( x/ t4 u8 P5 B+ n
window.onload = initializeBall;
8 P j4 V0 \: u" Iwindow.onresize = new Function("window.location.reload()");! s: t- M5 f5 K, g: B' f- {
}
& @" |- J% K) V0 k F( z! ~
% D' O9 N2 J$ f r</script> |
|