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

|
网页之不断弹射的文字-特效
<style type="text/css">- H& ] E5 }" R1 g8 @' e* [+ I
#supertext {
) O1 a% ]# q9 h, x# Yposition:absolute;, e) m* j% {2 E) h$ p& i) t, R7 ^; _- I& ^
left:0;
! W3 V) U# a4 _- a* htop:0;
2 a0 P, k( x C5 Avisibility:hide;
* O! r, O2 ~ [) o6 Zvisibility:hidden;* v+ g8 B0 f$ s6 b' Y( u
}1 C" W% h o/ k* l% B- _
</style>; ]9 n) |! E3 S2 ^! U* @
<script language="JavaScript1.2">) Q5 }0 I/ C# [2 G1 g9 r; |
<!-- 改变下的字体的大小。颜色-->% n( {' d9 R, ]7 y
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
# @7 r \2 n- ^; E8 ]var hidetimer='';( {$ M/ U9 f8 \6 N) q
<!-- 改变下的弹跳速度-->3 c8 l2 |7 i" {9 m9 G# t
var BallSpeed = 20;
G; _8 \/ U6 l+ y) u0 wvar contentWidth;2 V/ H# I, u8 ]2 f W' \3 i
var contentHeight;
4 E1 B: P. S9 D3 jvar maxBallSpeed = 50;
. x4 W% J* O" K3 r8 T3 l3 F
+ y0 L- k, Z7 o. ]0 [# V& V7 J. L) B1 @, Z* u
var xMax;& v* p" v4 T& C& G4 K
var yMax;" c ~% R& B. }: U$ v$ {" G
var xPos = 0;
5 I9 O- M1 s) I% m; [8 w+ zvar yPos = 0;" E. K& y% t/ t w
var xDir = 'right';
0 `; Y; O6 u5 R# U" G% lvar yDir = 'down';
& y/ Y/ D, F( {% U6 ]( j( F+ J1 {. y! Yvar superballRunning = true;' t3 n0 Z9 e b
var tempBallSpeed;
2 D) h, N1 P+ y+ Y Ivar currentBallSrc;# l+ I- r) b9 d7 X
var newXDir;# d6 C4 x7 ]* Z4 _9 S
var newYDir;
F$ T+ W: n( m; ?& ]9 d6 D
7 c( ?% u+ g) M7 K* ]6 a# K7 efunction initializeBall() {, B% _: z$ ^- ]$ g: d j% r% b
if (document.all) {% S7 E4 G! H1 T; f3 r2 F8 X% w
xMax = document.body.clientWidth, z( G! C5 F! d
yMax = document.body.clientHeight
7 _( }/ `( g I# t5 C document.all("supertext").style.visibility = "visible";; |: f- G! x( ?0 x1 h! ~: ?; n
contentWidth=supertext.offsetWidth
2 T A6 Q, p6 S, `8 j contentHeight=supertext.offsetHeight
+ C" J% F! J D9 W. } }
+ d7 b/ f0 w! N+ \, G# N" D else if (document.layers) {: Z" `2 u1 s1 ~& j2 z
xMax = window.innerWidth;' T; F$ k. y! Z$ V; G3 O. k! P
yMax = window.innerHeight;6 Y( k- ]+ l; J1 H+ r y
contentWidth=document.supertext.document.width
Q+ w. }; r6 N7 s/ h contentHeight=document.supertext.document.height
' h! M( \4 V0 d# L) {$ L/ o! V document.layers["supertext"].visibility = "show";( `* Y2 q) ~' ?! Y
}7 e8 w, K. a2 Q
setTimeout('moveBall()',400);$ Q+ d( Q# T+ p
if (hidetimer!='')* s+ z3 j) p2 C+ _0 O* H" y
setTimeout("hidetext()",hidetimer)2 q, N2 F, U! ]/ G5 R6 F# p
}
: ^+ ?8 h) b F3 K2 [! R" ?" M2 |6 F) e- |
function moveBall() {7 J9 p1 P# s+ q0 O. x+ W
if (superballRunning == true) {
& [7 ~: |& s+ r2 V1 K: E calculatePosition();
) }" y) ]+ I8 o1 j/ { if (document.all) {
3 I/ z8 I0 G# ?, O6 i4 I/ F" z6 o document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ _' n: L* l+ y1 v3 i0 \& q document.all("supertext").style.top = yPos + document.body.scrollTop;
& j& `( W5 n/ V. H$ \" T }
9 Y5 w. ^" C g8 W- d2 n else if (document.layers) {) ?0 ~. w8 t/ S
document.layers["supertext"].left = xPos + pageXOffset;
+ s, r+ [, i4 ]# v2 v, I document.layers["supertext"].top = yPos + pageYOffset;
5 p7 f" y: ^. e, F. @9 f. s4 ]0 z2 e }
4 C8 B) W5 B: F" E5 J- {! E animatetext=setTimeout('moveBall()',20);
) n3 t3 y3 ~8 j% g, o }
! Q4 e/ G, {$ X' F: Y1 u" F$ q4 n } W& M$ _$ N/ V5 [6 v* ^3 n
4 z! z2 C( d( |0 J6 Q& ~+ v! ffunction calculatePosition() {9 _; f$ R/ s& K+ r/ B
if (xDir == "right") {
; R% ]3 [2 H1 F/ @+ O( ?' w if (xPos > (xMax - contentWidth - BallSpeed)) {7 Y9 T: {* f9 d. J1 o8 Z' _
xDir = "left";1 S' L5 z9 r2 u+ C
}0 y) ^6 X9 I V! m3 p. w
}: o0 g% f- d. K0 h" [. H
else if (xDir == "left") {7 ~% x' I) [+ b! A# G F1 Y9 N
if (xPos < (0 + BallSpeed)) {' K* i4 r( U* V4 z8 ^/ Q
xDir = "right";4 c! \7 `% P4 A3 H# f! x# \
}
: U+ m6 F+ R0 ?4 t }
( x) p& A, a7 [! K if (yDir == "down") {: k b N8 F& ]' J. ]
if (yPos > (yMax - contentHeight - BallSpeed)) {/ C& M P5 k8 K% U/ H. ~
yDir = "up";
( j# C I" S: Q: P, z }, |* G9 @% f# x$ p% I; E0 R7 q3 q
}# z" f; L* c* i1 d) K
else if (yDir == "up") {
& F8 F. t+ t" y) D7 j if (yPos < (0 + BallSpeed)) {
+ Y& X1 W( J' V3 D& i+ M/ v' h0 d yDir = "down";
) u2 A% h& h; Z2 I( Z9 D0 Z" }- P }
! n$ T8 v3 ^+ e7 N }
3 S7 e$ }* f+ U+ I) Y9 m, }3 k+ q if (xDir == "right") {
# m! o5 B. ?* A xPos = xPos + BallSpeed;0 P O/ J# E# n: c& N4 V
}4 @2 ~( Y& V8 c
else if (xDir == "left") {
" g r) ?8 d; E7 j9 ^1 x; A xPos = xPos - BallSpeed;, d& H3 T3 @% Z5 T l5 t, Z
}8 N9 k0 l4 E8 z, d: b( M# m7 q
else {
& ?% t4 i' {& R- @1 d4 y xPos = xPos;
& u l; z m* U }
) @8 |+ x$ [; d& R4 l O; x4 I if (yDir == "down") {
+ I0 s7 u9 |# D2 _( g, H! i+ y% L yPos = yPos + BallSpeed;
8 E y* C0 F e }% c5 v% t# m4 v
else if (yDir == "up") {# g. E. c3 \- \8 i \
yPos = yPos - BallSpeed;. N/ C3 u( ?; C3 W1 w" R6 N; T3 A: U8 c
}$ H1 v+ I. t7 g1 X; N! g
else {
% M6 \2 }4 [9 @8 z* n: Y$ _( V yPos = yPos;; u- n e" u7 D! r
}$ O1 ^( [) @( Z, @
}
S8 d& x, \; F3 l
& K1 w( P3 r5 [3 y6 A; e* ?8 [2 Zfunction hidetext(){7 I2 Q! b/ S% U ]9 l
if (document.all)$ V5 j0 u" h2 U; _; P8 s
supertext.style.visibility="hidden"
4 k' O# n6 `3 n* i telse if (document.layers)
- x# S/ F i0 Ydocument.supertext.visibility="hide"
: {0 [/ _) B8 }9 a; hclearTimeout(animatetext)
0 r5 R5 k4 M7 ^/ q# J! M, s; C}
# M0 d2 G! s3 A7 n; d' z1 `
9 e; a9 w* K9 ]6 G6 \3 v& q+ tif (document.all||document.layers){
1 ^, X6 d* q' P1 kdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ H( W+ m: R, f. l, E6 Fwindow.onload = initializeBall;
2 I/ e. `2 B G) y% gwindow.onresize = new Function("window.location.reload()");1 w$ U% I0 V9 n; @' s6 \& R4 a
}
2 b/ l+ _8 V- b
: M' ]0 b4 h4 e8 }! I</script> |
|