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

|
网页之不断弹射的文字-特效
<style type="text/css">
+ j7 W% `/ ?! Z5 [2 S4 [#supertext {% j9 y; C* y- F' |/ G& }
position:absolute;
% c3 m& ~8 @/ ?4 k! ]% Cleft:0;
+ z9 Y$ a5 l1 A; Mtop:0;" l/ ^2 Z$ x3 g" |9 N: U0 k
visibility:hide;
$ p/ s: o# i1 Pvisibility:hidden;& b& \- b( m3 a; |( [6 \
}& c8 F7 Z! A8 T5 |
</style> j5 t$ z7 o6 A: Q
<script language="JavaScript1.2">" n4 g& g# n: t/ h
<!-- 改变下的字体的大小。颜色-->+ y: u2 R/ x# o$ w8 |" P" N
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. q7 p! h! u% u! j, Nvar hidetimer='';
: B" |' I* b1 g" D7 {/ c8 H; b, H<!-- 改变下的弹跳速度-->' X- @ I! w" [. O' B, G; Y
var BallSpeed = 20;) y% k7 y# V) I( o8 S( L B
var contentWidth;
$ q( v+ E5 V; s5 j( t" S" Lvar contentHeight;9 d( @0 A% u' t5 h( T& T: T5 v+ M6 d
var maxBallSpeed = 50;2 P9 Q( `$ X+ }% D+ X: B
5 j+ A2 }2 }: _
! J- S1 U( E5 t, w4 h
var xMax;$ A/ Z1 r" z3 _1 L C* |4 `# E& w
var yMax;8 [1 D6 o- Z( U4 d( C5 r$ @& G+ m. k- ]
var xPos = 0;( x+ \- e4 y3 Q5 h0 u
var yPos = 0;: ~& e" J0 [. c' \* t5 N; [; @' \6 K
var xDir = 'right';# \1 F# x+ l/ a) ~/ ^2 U
var yDir = 'down';
0 Y7 `" k$ c, _) |+ C9 Cvar superballRunning = true;
4 m' V% {% i2 k: z3 Jvar tempBallSpeed;& L) I4 _* r. ~7 w P ~% |+ P: k- h5 }
var currentBallSrc;
, I, P- j; Y T7 y. O2 [: avar newXDir;
& ~ w0 i8 z7 N9 [! E1 O. v5 evar newYDir;
P. F0 {) j7 h3 H
# O) Q* ^. V/ ~9 g. J' ]7 |function initializeBall() {
# o+ m; U% Y" H- j R" o if (document.all) {
$ e8 o n: f/ M! ?. v6 d xMax = document.body.clientWidth* p$ p2 u7 A3 o; O
yMax = document.body.clientHeight
, e, Y4 t) t( `( S% f7 `1 i document.all("supertext").style.visibility = "visible";
8 G& x. }" V4 H/ ^8 f2 B& E contentWidth=supertext.offsetWidth9 _- h' s( q* m
contentHeight=supertext.offsetHeight
. j* {) Y/ u& M }
2 }) J* N* }9 b' k else if (document.layers) {
# H+ _: l' y+ g0 A0 B; n xMax = window.innerWidth;: C0 f0 S) j5 w) ^* T" F
yMax = window.innerHeight;5 P: m. X: c# o. T; S3 ]
contentWidth=document.supertext.document.width# g. U+ o; e1 ?! ?+ `
contentHeight=document.supertext.document.height, C7 P* Z8 S) ~. t2 U7 _) c
document.layers["supertext"].visibility = "show";% x, j3 @9 Z) v& {# D! |
}
" W1 r& V; D6 A/ z' W setTimeout('moveBall()',400);
. X2 ?4 z) K5 n: h8 m if (hidetimer!='')/ z+ O% i, b2 I- u
setTimeout("hidetext()",hidetimer)
+ E; s% O5 M6 m; _; L/ b3 H4 I }
2 [/ D% a" t% S" w& W; d$ h e6 I3 x( X7 I% C6 G+ m' p
function moveBall() {+ B- R9 }. J% W) E A' m. Q2 x/ x4 Q
if (superballRunning == true) {
1 R( T: N2 R( C/ J2 @; G calculatePosition();
T4 l9 \4 ^& f6 L if (document.all) {# D+ U k. A7 r7 u6 H
document.all("supertext").style.left = xPos + document.body.scrollLeft;+ c. o' Q) {0 ^* v
document.all("supertext").style.top = yPos + document.body.scrollTop;
/ z4 b' m: d; P g# i/ r }
0 P; k O& Y# ^+ { else if (document.layers) {
& M: S) q; |- h# c document.layers["supertext"].left = xPos + pageXOffset;
9 N4 }* @7 Q2 V; C' k document.layers["supertext"].top = yPos + pageYOffset;
) [1 ^, m' X8 q# L! W }
9 `0 R0 j3 H6 a- Y8 u% B* ]. |2 T& V animatetext=setTimeout('moveBall()',20);" \9 m+ B# g w
}3 m) o% g. y* |) l9 L' i
}8 G& ` M1 ]( I9 B4 a
* a9 s8 g7 [2 k, v) W) O# s
function calculatePosition() {
" g0 u" z/ ^* o, T$ C6 @ if (xDir == "right") {
- h9 D7 T7 _: C' |. a6 b9 K3 U: j$ w if (xPos > (xMax - contentWidth - BallSpeed)) {
1 ^/ w) r Y" h2 h7 { xDir = "left";
w( u$ V {1 l2 q' M/ A }
# h5 N) M* L$ Q! X1 ?" _! u }6 _' ~% Z* ]( M b
else if (xDir == "left") {/ P! D2 v7 E, T. g9 e$ J
if (xPos < (0 + BallSpeed)) {: l/ a" `/ P/ x( u; c, D8 ~
xDir = "right";
3 a2 {( L0 U2 `. @) a }7 q) b! z' L8 r* l+ a
}
* ~+ _6 @) h& E6 J" _- n1 U! L: x if (yDir == "down") {0 m J5 x* h3 I" C4 [# L
if (yPos > (yMax - contentHeight - BallSpeed)) {: Z2 F( v4 @ O: t4 v4 j# L, e
yDir = "up";6 E; X9 C6 k- T/ L7 j' k3 u( |) ^8 c
}: n0 N- Y9 A. [. T s1 X. c
}3 u. k' R$ ~7 L& a8 i5 R
else if (yDir == "up") {# C* V9 L3 X* k- b9 U; w
if (yPos < (0 + BallSpeed)) {
9 _- t* m0 K0 O z$ m) O yDir = "down";' n1 K6 `9 Z+ [# h- ~' ^3 l
}
: S. p' |2 _7 P* M# H }0 @: ?! w; Y% j- |) w
if (xDir == "right") {
! I% }" T- c! B2 A9 } xPos = xPos + BallSpeed;
; `# ]" ?2 K$ L$ C8 m4 K+ \ }
' h0 Q* n9 E/ e) q' x9 e4 y else if (xDir == "left") {# x) O5 L" T8 j
xPos = xPos - BallSpeed;
0 @. B3 N7 u* }- V# p+ k0 t% n1 q }
- P# Q! K7 @) T/ q+ d8 q ] else {+ S. H9 d# F0 e( e1 y! @( Y6 p9 ?
xPos = xPos;
. J! D4 O( W- O u }: a. N' c2 F- p7 M9 F% [0 u
if (yDir == "down") {
. b, O2 F# @% f- n3 F yPos = yPos + BallSpeed;0 l4 h2 B" {3 u! h6 H8 X
}
& N3 i" e4 _8 g; ] else if (yDir == "up") {
- l, C- \* a+ G+ D8 M X yPos = yPos - BallSpeed;# B6 t6 A2 J$ I5 k4 M
}
# F6 {9 N# f/ }7 J& ]. o- H2 O else {( z' F# y k. ]3 A
yPos = yPos;9 v& C3 e& m! E
}
2 V! i( E# n7 h; j' |' z }
- J6 g, P9 [9 K) c" k8 N
4 o3 R6 A* s% Q' o: Gfunction hidetext(){ P9 o' N7 {0 X5 `4 b; @0 j! Q
if (document.all)( f( d; E# Y3 }; R. ?' L
supertext.style.visibility="hidden"
+ D1 i3 C& @/ ^8 z1 C' c4 a7 ~else if (document.layers): ~' B8 `) Z% J8 }! s8 z
document.supertext.visibility="hide", Q6 F7 z: ?" A7 @$ n( X8 C2 ?8 x& x, G) s
clearTimeout(animatetext)
3 M0 f7 \2 `& I3 E8 y}
( _$ S, B6 V5 i9 @( `! J5 u& ^' Q% M/ @ g
if (document.all||document.layers){" m& @% V* W2 g A7 L E# A
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 l/ X7 C$ A& r' B/ J
window.onload = initializeBall;' p1 R* d7 X9 ]- B) K, E8 c, s _
window.onresize = new Function("window.location.reload()");
2 r' q }* y% t) K" H& J}( c# R/ J. l( ^7 D) V8 K
- a6 O) @% T4 j( X6 c% J `
</script> |
|