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

|
网页之不断弹射的文字-特效
<style type="text/css">" R6 f* D- a( }6 D+ U: z4 {. f
#supertext {2 ]; }, Q8 P% R8 @+ V% V
position:absolute;% f3 w! W- C5 i. I" Z
left:0;0 g' m) o# w% h) _4 G' a
top:0;" L3 S$ t' s; s& I K3 q
visibility:hide;& [) f9 g; ^8 Q1 {! i
visibility:hidden;
& v/ W8 H* e# x* s, C9 W/ N' X}
( y7 q1 C# _# O. T! d. X0 _' k</style># S: c- Z1 f5 V) g# y
<script language="JavaScript1.2">
( Y# [' R) I) v' [. B- L. d<!-- 改变下的字体的大小。颜色--># o4 r+ D3 B1 t ?: R3 x
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' [- K7 A1 L* h" l4 ~% }var hidetimer='';
) ?& I. A- U2 h1 x<!-- 改变下的弹跳速度-->8 V0 m) R _9 S: e' Y/ t
var BallSpeed = 20;9 G$ K% J7 D# s- f' k
var contentWidth;- m& y/ |" ^ j: A7 K% [
var contentHeight;0 A+ b4 f5 i; b }
var maxBallSpeed = 50;0 v$ k. F. a, I: z6 a0 s Q) Q
* N( J+ ?0 _$ T2 G9 ~6 r$ C) G
4 b9 {( s# M6 Y) _6 ?. l7 M$ cvar xMax;) s+ t( V5 V0 W$ ^$ @6 F% R
var yMax;6 _" W5 ?3 f! J/ `6 k
var xPos = 0;
" t8 Q* O5 W% V0 ~. yvar yPos = 0;1 h6 Q: h/ X( ?4 h
var xDir = 'right';
( v+ d: v L; I3 gvar yDir = 'down';) A" Z8 c, z, r# m$ X) y# B
var superballRunning = true;
8 a! \4 X. K+ @var tempBallSpeed; Q4 a: ^, _, e; H, g0 C" \- ]
var currentBallSrc;- e4 T% V; ]$ e8 ^ u
var newXDir;0 z! d( R! f& m
var newYDir;" a# t) ?. g Z6 _# j/ O1 X
3 l& ]( S, n8 d2 W6 r* _, tfunction initializeBall() { U- I( x+ l6 F! \* G
if (document.all) {
% h. [/ i% ^& J6 J- X xMax = document.body.clientWidth1 T" a! X; B4 Q
yMax = document.body.clientHeight
x0 _7 {& T/ o$ E' Z document.all("supertext").style.visibility = "visible";
6 m6 p& r$ s' u% B9 P, ^# h/ n ` contentWidth=supertext.offsetWidth. F5 r: G" ]2 x J
contentHeight=supertext.offsetHeight
/ z8 \7 X$ ?5 e% }9 s9 O }
# v% U" J3 D. |6 c f" |( R else if (document.layers) {
0 U" v: v1 f |2 T! a) G xMax = window.innerWidth;# ]% y! w8 D2 T3 F# a
yMax = window.innerHeight;
0 R5 r% g( U9 n2 |, F contentWidth=document.supertext.document.width
T) R$ N! e' w! d- [ contentHeight=document.supertext.document.height2 e# L# o3 h, q1 S: _% K, j2 G
document.layers["supertext"].visibility = "show";
/ D- C: M7 V' e9 x0 J }
, p# S9 U* M! g0 H' M( R setTimeout('moveBall()',400);( i1 X" O) v( Q" a7 i( F
if (hidetimer!='')1 e G4 R! K3 b, \" `8 a/ |8 `8 {
setTimeout("hidetext()",hidetimer). e9 d! F9 f+ Z2 Q9 D
}
% x* P) y( I3 m8 J
0 S1 f) p" |: ~& Cfunction moveBall() {: Q# ^0 B3 }8 ], @
if (superballRunning == true) {: M( v' x$ |: o6 j8 V. w
calculatePosition();! j4 ]1 N6 f# Y
if (document.all) {
9 U2 j$ i* R5 F; h+ `, R document.all("supertext").style.left = xPos + document.body.scrollLeft;
' f) |8 C8 X3 B6 C+ E& \+ e document.all("supertext").style.top = yPos + document.body.scrollTop;/ ~# R& G( B3 j, n) m+ z2 e
}
: A! Y% C" i9 E1 I else if (document.layers) {
0 s" g$ n. v. y9 J$ r document.layers["supertext"].left = xPos + pageXOffset;4 I g6 V4 I, `* V) g5 A4 d$ N
document.layers["supertext"].top = yPos + pageYOffset;
- w; l3 M+ u$ X; x- Z }5 V1 |- {$ ^4 K5 u' g' f B- M
animatetext=setTimeout('moveBall()',20);
# z% {% K: i: Z1 W% b% ]" ] }! p s1 T: r8 L) P5 B, I1 x
}. C0 Q9 D* b% R+ m0 j6 v7 I
* N" N- M l' N1 I8 D; W
function calculatePosition() {
+ N5 K5 Q: m+ p P if (xDir == "right") {
9 `) }# |0 h& y0 L1 J if (xPos > (xMax - contentWidth - BallSpeed)) {# b3 ]% z- E4 V
xDir = "left";
1 c+ d7 y8 K- y' c+ V, J8 ^7 E }
2 T% ^4 b! [- ~( B; _ }- o, K- |/ a6 u5 h1 X1 e
else if (xDir == "left") {
0 }6 O- c6 q4 u. x# F: J if (xPos < (0 + BallSpeed)) {
+ S- X1 C* J @ e+ [ xDir = "right";0 }6 I/ M; [. x; @
}
2 {/ j. E# R+ ?7 e }
; k2 ^ x8 _: ]2 n8 A if (yDir == "down") {
' L/ K0 i/ q( P if (yPos > (yMax - contentHeight - BallSpeed)) {" Z, z2 ^+ k( T9 L8 H$ Z" K
yDir = "up";* Q% `8 E0 q- l( l) w h- C# j
}
+ {! Y) q- B& t; t }5 l9 o- J$ {! N. m s- A
else if (yDir == "up") {
" G# H1 K( [& N- } if (yPos < (0 + BallSpeed)) {
/ x4 J4 w* ~! h- E9 R yDir = "down";* ^7 T. \* u, @7 t2 a q1 R
}; V5 N2 g* ^! ]; q0 b) B
}
/ H7 |1 h# p9 W+ r. x9 g. q if (xDir == "right") {
/ P# } D4 t/ n+ }. ] xPos = xPos + BallSpeed;
3 I+ f* T( c1 n5 O }
7 `2 x" @6 \; P& K4 r5 ]; I else if (xDir == "left") {
2 y( K' A6 v; X) s" Y* }& O5 g- q xPos = xPos - BallSpeed;0 n4 b6 C6 r/ s
}* Z: p6 z. `% [. ^8 \* J- P
else {/ F8 y8 q9 J' N7 P1 T+ H* \5 _5 u( Z
xPos = xPos;
6 L3 u( J+ Z6 u1 R }
0 d$ l- k8 i: B3 j& T l. y if (yDir == "down") {! K( H: p. x" @! q' Q; Z* _
yPos = yPos + BallSpeed;8 m- s2 u- d8 \
}
; D R, t2 j. Z& K' y else if (yDir == "up") {
9 M1 c' N; D \4 ~ yPos = yPos - BallSpeed;
( N. v' }" [$ A+ P6 y% ^ }( D7 r# z* l+ N, z$ q; @5 x7 R
else {
: e$ X. V0 [3 B/ y, g yPos = yPos;( [1 f2 q, ^$ P8 L( d( H4 i" }. X
}# ^2 y. j+ K6 H O5 }5 [" Q
}
$ z1 u* x6 P5 @: M
4 o+ e8 s/ ]+ T# `# x0 B& }function hidetext(){" `. J! g* Z3 }0 W0 }1 j" h( S
if (document.all)
2 N- n! g2 i4 E- V& Osupertext.style.visibility="hidden"
8 s1 g0 n. T) {else if (document.layers)$ p, d/ x1 ?8 N+ h8 H
document.supertext.visibility="hide"3 y. s- f+ Q: [7 s0 {0 @
clearTimeout(animatetext)
; h. _& m1 V& ^! {}
9 W& K) X* _' u
) _1 ?& M1 d3 ^# cif (document.all||document.layers){
+ [5 ]7 ?4 }" N# D adocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), c$ D9 M5 W0 u, ]) D$ ~ c5 I! |
window.onload = initializeBall;
8 E1 ^* Y* m s/ Vwindow.onresize = new Function("window.location.reload()");9 b4 [+ P/ G6 Z3 ~. o9 o5 m1 ~) l4 l
}
+ X5 i0 x# s: X1 W/ J
3 \( V+ u$ Z- j</script> |
|