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

|
网页之不断弹射的文字-特效
<style type="text/css">
' L- |3 s ^0 ~* G+ ^9 G) N( c3 J#supertext {& H) w. j+ |6 d+ z; Q
position:absolute;5 X5 [6 G7 B9 r" Y6 n0 W, g' S
left:0;4 q. P) w$ v$ l2 H4 B
top:0;+ i2 B |$ O! c; I
visibility:hide;7 h+ i: A0 Y s$ i: Q- u3 A
visibility:hidden;. G% p* }0 L. [, e. v: c- Z
}
$ W7 F) w2 h, M! w* H8 z3 N</style>
7 S* c' N: Z( f5 ]1 |<script language="JavaScript1.2">
7 M+ b9 Y' {2 ?# J& h, w' K<!-- 改变下的字体的大小。颜色-->
) N! m5 ]$ P1 M7 Rvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
+ r# s8 [0 h- k! c1 Rvar hidetimer='';
( T! v, r7 d8 J" O<!-- 改变下的弹跳速度-->2 i# i# x! ]5 S$ @' |! z
var BallSpeed = 20;
q( s5 _ O! `1 Vvar contentWidth;
; R3 J. |0 \5 v2 ?( Ovar contentHeight;9 c+ e/ M- }! [. k- x! |5 s
var maxBallSpeed = 50;% L& Z- E. N, H6 d2 S1 x
4 S+ j) l- |# W% b: L/ f2 |7 k4 Z- E% y9 w, u! O( G* U, z
var xMax;5 G. j) K# G6 g$ R7 t- ?& m
var yMax;- }- b; M) P7 y) Y% m1 |
var xPos = 0;- T3 ?0 V( t: m2 M
var yPos = 0;! F/ u! G" T# R, f" Y. a
var xDir = 'right';1 ?3 E f2 ~- l2 L1 H
var yDir = 'down';
& I$ ^" T3 \6 b% V" wvar superballRunning = true;
" _# G0 d& K. Z! Qvar tempBallSpeed;
* |! x: b, j" X1 _# G5 vvar currentBallSrc;; t& `5 W6 ]6 B! P8 X
var newXDir;' r3 c) a @. X3 g% f1 d8 f
var newYDir;
2 K# f" G% r/ K& T, R- r. ` \9 s6 q! O: P5 {* h# O9 S
function initializeBall() {" W9 Q4 b f- Y S* w# \1 g* E
if (document.all) {
+ w' q4 K/ j2 y) M; k xMax = document.body.clientWidth* m* q9 Q$ g( g3 N S
yMax = document.body.clientHeight8 g: {9 [2 }8 }1 G1 g
document.all("supertext").style.visibility = "visible";
6 ^" R0 ?0 k8 _/ y2 g6 W contentWidth=supertext.offsetWidth5 u z% D3 q5 g" _
contentHeight=supertext.offsetHeight
+ M2 X1 O2 j2 K5 z }5 o3 ?2 S+ H4 e
else if (document.layers) {
: Z8 x7 h- P$ T3 {# |6 H/ t/ m$ x/ S* F xMax = window.innerWidth;
$ n6 i9 {9 o( A$ G) W1 ] s yMax = window.innerHeight;% C& k0 J+ O2 A1 @( ~. O
contentWidth=document.supertext.document.width5 H# Q; k+ k. w" p. Q
contentHeight=document.supertext.document.height# s9 n! E1 R5 G7 {
document.layers["supertext"].visibility = "show";
' E, K# ^1 Y- ? }& P( d! |4 |& ~$ B$ c
setTimeout('moveBall()',400);
. H2 w$ g n9 W if (hidetimer!='')6 [5 X' v3 ?/ o, B r
setTimeout("hidetext()",hidetimer)5 |2 r9 {/ o h- u1 H+ o) o: }
}
/ h5 U/ `% V. S- R' y1 k
+ h1 ` W) h. z6 H4 ?" ^- v$ {function moveBall() {% M$ T" ?: n; _8 j
if (superballRunning == true) {
3 i, \+ l4 ^' z) H$ L: V6 _ calculatePosition();: ~1 c* k1 u4 H+ r- \
if (document.all) {& u2 D; [0 X! @" P. f% `1 R. ~$ k; j
document.all("supertext").style.left = xPos + document.body.scrollLeft;
+ H$ s+ @0 }2 k# C. f document.all("supertext").style.top = yPos + document.body.scrollTop;
$ h- V0 r) u. X1 t2 A/ b6 T }
1 Q) m9 N% y$ B& n, U else if (document.layers) {; K9 j# |; v# K; c9 H" T" ~
document.layers["supertext"].left = xPos + pageXOffset;
- P& [- ]! ^+ f; A, D document.layers["supertext"].top = yPos + pageYOffset;
8 N+ A" b. S/ w% n# p$ N }
1 U# R' h# u2 l5 S5 P& }' \2 Z8 {6 Z animatetext=setTimeout('moveBall()',20);: Z6 D9 {) v) g: _
}
6 L1 l& L# K9 m. J( P }
8 s7 ~1 T9 \( u z7 C( ?7 T: Q
. q/ f, B# H& q0 \function calculatePosition() {5 X; C9 k% L& }5 i# Y# s" v5 {$ B
if (xDir == "right") {
* ?( S# \6 Y/ {2 b1 g3 |; B$ V if (xPos > (xMax - contentWidth - BallSpeed)) {
3 T5 e0 I, V O7 ^% N$ P& M xDir = "left";
. Y6 M; Z: q+ S2 D4 R1 w }& C1 j6 |( E [8 m% r& Z% n- \
}: m- s% ^9 @1 d: `; C
else if (xDir == "left") {
w! _, e6 e) i; H: H if (xPos < (0 + BallSpeed)) {
4 y3 d; K: u, y0 e, u6 Z7 c xDir = "right";
* t3 r& g/ U! k5 |: J8 Z7 [& D }
1 Y! c! t$ c* V$ b6 T; J* f0 ] } c: w# e, O9 F+ ^
if (yDir == "down") {# W3 N; O7 S; m
if (yPos > (yMax - contentHeight - BallSpeed)) {
$ J$ o, U v5 h yDir = "up";4 K9 V# O' |( C) A9 s
}
& [/ m, u! |6 U% B& \6 F2 w" n }: t9 w) z' T! y1 U
else if (yDir == "up") {
! o6 a/ V8 {3 n# B2 j% I- l if (yPos < (0 + BallSpeed)) {
7 a. y1 R( ?7 J5 T! ^+ c( k yDir = "down";% o5 n4 ?5 {* [* U9 A" C* ^) G1 q
}
$ T6 W. X& Q+ l) A }2 y3 N- g$ ?/ F" u: i
if (xDir == "right") {
/ L7 C" ?9 L( { xPos = xPos + BallSpeed;
2 s. {# i4 Z7 t } I* C J) ], I9 X$ N+ k9 f
else if (xDir == "left") {1 b- V) R! n# v e
xPos = xPos - BallSpeed;
9 j, O9 \$ D* `. J }! u7 \0 _& i8 b* b. m6 l/ H
else {
; e1 g% ]) _: s) D/ I' | xPos = xPos;( v( P: y5 N- N6 u) p' L$ k
}
; M( J9 ?) Q& @+ s if (yDir == "down") {
/ G% l9 K3 [8 b0 K/ t yPos = yPos + BallSpeed;1 U& F. e0 K5 M% u% N" V
}
) e' ?0 G# X- n. t2 C C9 t else if (yDir == "up") {! V. {+ t( g7 Q3 B l
yPos = yPos - BallSpeed;+ Y& u0 W# m7 ~' O
}8 P2 L: V4 d- f- G; h4 a
else {
( \7 C7 D" a( y' ]4 j, C yPos = yPos;
& F, a1 |4 L0 j0 D$ g% I }/ A& G) J u. B1 q S
}
8 t+ l" z3 R- U4 V( j! I; `- M2 S/ E3 }" d* Z0 E6 t
function hidetext(){
7 `, Y# R9 u5 G hif (document.all)
' @. ?7 ]% _+ `8 xsupertext.style.visibility="hidden"
8 F; K1 l1 R5 V$ g3 x$ D1 belse if (document.layers)* A& h9 Q3 S8 L
document.supertext.visibility="hide"4 \! K! c! n8 \+ t. ~1 L4 S! n, s$ i
clearTimeout(animatetext)8 _4 t( M D1 X' U, r
}: W) K e: z; y& q' A S8 o
) s4 }6 {- V: U! q0 u( n7 J
if (document.all||document.layers){
8 R6 e" V: [, u& }/ ` e! E. [: p- Wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
& J: f1 V, F! N9 F, s4 vwindow.onload = initializeBall;
4 ~0 h7 @ `+ U* v9 d' `+ h) T9 Swindow.onresize = new Function("window.location.reload()");3 M1 a) V8 N& V3 _9 v7 S( W
}( o8 V9 O+ H- `0 h g
8 `5 e' a5 Q7 z- }" F
</script> |
|