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

|
网页之不断弹射的文字-特效
<style type="text/css">' s: H- D6 B$ z* K
#supertext {
' c8 a6 U8 K5 D; j* iposition:absolute;
1 T- I) S' Z& Lleft:0;
5 u% T) k. m8 B; j3 mtop:0;
0 Q5 J: u3 e7 b7 A0 Gvisibility:hide;( ~! Y, w) k }; g* j2 k [: R$ G2 B
visibility:hidden;
" K% S6 c' z. F! G. Q}1 [! m8 k4 O+ x! Z6 d
</style>; W; h* [1 }# z4 s0 \- }/ r: I( `# a; z
<script language="JavaScript1.2">
, ?0 u9 I) f) t1 C) H* C' Z<!-- 改变下的字体的大小。颜色-->6 r% ` x0 j# |; y1 D- c7 Q2 r9 a
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'4 S9 I7 n- N5 o1 y
var hidetimer='';
# O8 S" M* J1 e9 |6 K/ h0 C, B<!-- 改变下的弹跳速度-->
. J. R7 Y2 q: Fvar BallSpeed = 20;+ ~0 H1 N8 A [: J% m
var contentWidth;
' k* @0 C. g) f2 C tvar contentHeight;6 u, v1 z0 y, m
var maxBallSpeed = 50;- v/ w1 S$ e6 K% p
) m3 I3 | r: t C: b6 E
6 x* L3 y& w% W* q5 Evar xMax;5 F7 J8 G) k6 r( L1 U$ z
var yMax;
, J* d3 g' K0 q3 evar xPos = 0;" q4 f+ q" Q* r4 c B [( S- v7 |
var yPos = 0;; w( z7 w( z4 F4 j+ v$ [# t3 q
var xDir = 'right'; F7 v8 G% i4 M4 M/ V3 g
var yDir = 'down';7 ]& ~7 I9 _2 @$ G6 Z( }+ U
var superballRunning = true;) A0 `8 u& ^! e d# ?
var tempBallSpeed;5 D% a1 f# g3 j
var currentBallSrc;
1 G5 X' N( m9 t$ a. k! ovar newXDir;2 s+ q/ q) P2 @ q. o
var newYDir;
: f- ^% O' B! c( l f1 O
% i( y7 v( W+ C" x/ v' |function initializeBall() {
6 Z6 {1 [* x- j0 e0 S if (document.all) {
5 q6 N8 ^5 ?' o xMax = document.body.clientWidth& _& \8 H% ~2 Q- z( W
yMax = document.body.clientHeight
* e8 ?8 q1 a/ i" o- G document.all("supertext").style.visibility = "visible";) r8 T$ m# N! O6 N; y! u; h
contentWidth=supertext.offsetWidth
6 A& d- k# ^( n0 c contentHeight=supertext.offsetHeight* Y4 `/ _! R e, e, o. C0 Y
}# _* `" A7 ?: _* h8 I% \- C
else if (document.layers) {. }0 {5 y( q8 X) M# @( m# |3 _
xMax = window.innerWidth;
* ]$ Z' \8 h$ U2 A yMax = window.innerHeight;: Z8 E, N( T2 @3 Y! Y) y
contentWidth=document.supertext.document.width
1 }# p' _" F( X% J contentHeight=document.supertext.document.height
5 c5 M, l3 w) X4 K* c8 R document.layers["supertext"].visibility = "show";' K* d* S5 T$ a' e! b9 `0 t+ w k
}
" Y( _' X- u- I* c8 f( @/ C setTimeout('moveBall()',400);0 N) {2 A6 b" n, Z
if (hidetimer!='')) P. R2 H6 H6 I+ I, A0 _
setTimeout("hidetext()",hidetimer)2 e9 z, e" Q" \* r' h& B
} a) F1 t( `7 j5 L
6 H! R. H, c1 Ufunction moveBall() { K A6 D: }. K3 I) T/ l0 m
if (superballRunning == true) {
% b8 x7 V+ _$ a/ R* k calculatePosition();
9 @4 b! e* d' U# a& I" r; }& M if (document.all) {" [& Q3 u! F# r1 q
document.all("supertext").style.left = xPos + document.body.scrollLeft;
# n- M) \1 q. h9 S3 S9 E document.all("supertext").style.top = yPos + document.body.scrollTop;
* n% w. U3 @+ _3 r( y }. l7 W$ R* O+ c5 e9 Y: q3 ~
else if (document.layers) {
0 n1 k# \, ~$ b" }4 _8 B/ f8 v document.layers["supertext"].left = xPos + pageXOffset;
9 R8 P, D/ o9 I; Q document.layers["supertext"].top = yPos + pageYOffset;0 F5 t3 ?! Y: d# U# Z. t
}
6 `" s0 ]! _3 X, c' @- C& j6 l0 x8 v/ d animatetext=setTimeout('moveBall()',20);5 Q' B' X w/ f, R' S2 c
}3 n3 n6 C+ X% u7 ^& Q
}* u% w% M2 }6 I# T2 ?# _
3 w( W! V, J; c+ {6 @function calculatePosition() {0 p/ D! B) `2 v. v( O" e$ D
if (xDir == "right") {
* D7 g! t! \% Z if (xPos > (xMax - contentWidth - BallSpeed)) {( @: M: ~" t: J# i$ c( M6 |
xDir = "left";6 o; V) ]2 _" ^ e" G& Y+ z, d
}
( v0 Y( Q! A5 e- j1 `5 D% u0 O }
) n3 \4 d0 l2 C2 R else if (xDir == "left") {& X0 P& g E q/ u
if (xPos < (0 + BallSpeed)) {
$ [9 F2 D. M' Z xDir = "right";
' x' ~: p2 N# Y) R }
" Q0 j: s R4 H! v% d }; n$ q) j5 R7 } \% s: e
if (yDir == "down") {! \& x8 R* L* @, N6 ~# X6 u2 E
if (yPos > (yMax - contentHeight - BallSpeed)) {
H# X/ j0 b# y! M yDir = "up";. |4 j( a! m1 A, X" [4 c# Q3 c! s
}
% Q; X( x; ]# x5 b }
; O0 k' B: b T$ e+ d& B/ W else if (yDir == "up") {
* z" A! P2 X- g* N8 ^* Z if (yPos < (0 + BallSpeed)) {* a5 U3 E& H- v4 s0 r1 L
yDir = "down";# W b0 n+ P% H# r
}
8 H2 f3 l: f* A4 p/ e2 u; z }
6 g8 Z- ^/ U; A7 \+ i6 V8 L' g if (xDir == "right") {
% e% D0 X- E4 {! |1 R* g. ~4 _ xPos = xPos + BallSpeed;
+ Y0 o* N) C F# V% Y }
0 D! c# t5 @4 c* ^$ f else if (xDir == "left") {& e7 I+ t5 ^8 f/ I4 q# h3 T c+ U
xPos = xPos - BallSpeed;1 e# W& f3 r7 J, m) s
}
) u9 {# L' ^3 E+ X else {( i7 y3 G+ P$ h# i5 h2 v6 e; c
xPos = xPos;7 w4 g# w* p. n2 e& L. ?
}4 n. d3 Y) H, s5 S2 H4 ?5 x
if (yDir == "down") {/ i6 C/ I. p y, k
yPos = yPos + BallSpeed;+ w/ a6 T; F8 r3 g, ?
}
: W$ c# W0 D$ i else if (yDir == "up") {& V; g! V6 k- ?( Q' x0 M2 x
yPos = yPos - BallSpeed;
. l( h/ R+ @. v& ^+ r% F+ K4 s }
+ S2 y6 G. q8 y1 V5 _ else {- c: ], e! z- _9 c" \
yPos = yPos;
% }0 m, i& v( Z, U. k! \' c. g* w }
- G7 @. o( i& B0 [# v: M* g }
9 F; e6 V1 _0 x, j* c4 ~* w `
& e- d7 t) J! j F5 E: vfunction hidetext(){* \3 o8 _: }& s: f
if (document.all)
- D/ \" i$ k! l. i8 D( L$ Ssupertext.style.visibility="hidden"
9 H; n, r# d5 y' |else if (document.layers)1 E/ ^9 q6 H9 x% y$ @9 d4 q
document.supertext.visibility="hide"$ ?) d1 u1 [$ r5 [
clearTimeout(animatetext)
6 }" {2 P0 I2 T% W: R% ~* \3 |; z+ |}
8 u) r* \' Z2 Y {. P
# d* B1 C$ Q' G4 ]( Zif (document.all||document.layers){
7 s. c/ x) E2 c$ C9 E+ Q' h7 ]document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
+ u8 q! n7 g8 w' F" C. D# @& S0 ~window.onload = initializeBall;
! M7 A2 ?9 h! s9 T$ V9 c5 C7 ywindow.onresize = new Function("window.location.reload()");
. y& m) o; f( a6 t; m" r+ U}- v1 T* k/ T* }& T% O! ^0 l2 O8 h
0 b; J2 ~. |) [</script> |
|