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

|
网页之不断弹射的文字-特效
<style type="text/css">4 U0 p* G) ?9 [1 _5 m: N4 s" \
#supertext {7 e. J* i7 x! z" Y/ M6 O3 L
position:absolute;/ q5 k2 z1 J9 x8 G4 U" b2 @/ ]
left:0;3 [0 f6 l: h# @& T# C# ^
top:0;
' K- x/ A4 {! v$ S% gvisibility:hide;, ^$ c* Z: C( S, m
visibility:hidden;
6 ~6 w# g6 P( @( a" g+ k( s}
* I% h2 T/ M; z! j( g</style>
0 k& `5 \8 X. }6 r4 p0 Q<script language="JavaScript1.2">! L* {3 s/ l, `( P3 [7 d& |' }' M
<!-- 改变下的字体的大小。颜色-->- M1 x% _) {3 T. P
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* ?/ k, `# U+ G8 N9 Wvar hidetimer='';
5 Y% Q+ [( j% O, e8 S0 n# c<!-- 改变下的弹跳速度-->, V$ s1 d# C+ s4 A- V+ v
var BallSpeed = 20;
1 E/ a' \; B' Svar contentWidth;. Q* P4 j% ]# V. F u/ \
var contentHeight;
& [6 O& c; s' }; X% ~+ \$ cvar maxBallSpeed = 50;
* r2 f6 }: _3 i: B( P4 h& m2 x* N8 }/ B2 T$ D5 h! W
8 v$ X4 o* v' @( z0 U- _
var xMax;/ ~' _6 d0 x8 M
var yMax;# H. e) b6 S7 Y! E$ Z
var xPos = 0;
' x" k0 d2 l) ?var yPos = 0;- Z& ^- \- a7 p' @* a
var xDir = 'right';4 h5 U! i. t1 M3 f2 e! T3 M
var yDir = 'down';
+ s7 e4 ^& e- |, T" J2 fvar superballRunning = true;9 h# c7 c$ h1 W2 {3 k6 ^
var tempBallSpeed;
) z/ r1 ?! p; L% O. N" Mvar currentBallSrc;
5 L' e9 W' I% e* dvar newXDir;/ o/ \. q* a$ t- J+ x$ k% x. `6 l+ d7 |
var newYDir;( p9 |6 Y# r& v
* C1 n) h- T5 S7 m1 {function initializeBall() {
' O0 h. T( t' y if (document.all) {1 G/ J* [& ?3 h2 L& X/ x
xMax = document.body.clientWidth
/ \0 o% C' j/ ~5 i" S+ j yMax = document.body.clientHeight
: X' ]& h9 G, t8 V7 p7 h. S document.all("supertext").style.visibility = "visible";6 h' [3 l* u @' q# K! Q0 ^
contentWidth=supertext.offsetWidth' `8 k( d6 V3 ~$ \. W+ x" W
contentHeight=supertext.offsetHeight) P8 S, \& a3 U! I* F6 a# N1 `2 a
}3 Q1 A. E |# G) @/ ?1 U6 j
else if (document.layers) {
! o6 u1 }) h8 f. u# @ xMax = window.innerWidth;
+ L. C* D+ ^1 r" ?( y, e2 m4 y1 [ yMax = window.innerHeight;& k+ d$ ] k- j% u
contentWidth=document.supertext.document.width9 X8 l7 \5 e# _, u8 T. m3 h
contentHeight=document.supertext.document.height% g9 A+ D h; z" U( \
document.layers["supertext"].visibility = "show";2 `# Z) J7 C- g+ y# x/ ^! ]* G
}* N3 X1 i, n# y3 E, X/ Z b0 @$ B7 T
setTimeout('moveBall()',400);' j! a8 U' l" w
if (hidetimer!='')- N, M& q0 z" s: _6 K5 [
setTimeout("hidetext()",hidetimer)/ w6 u6 V' d) h+ {/ u& Z* Q
} z7 ?4 ~+ f) d: q3 F0 B! A. t
( b0 B% D, i' f- F, Efunction moveBall() {- D& G; K) c& ^
if (superballRunning == true) {
* l) N+ N d+ l calculatePosition();
# q0 J7 y! _. {! W" G if (document.all) {- U3 t2 Y" @) j, H7 z
document.all("supertext").style.left = xPos + document.body.scrollLeft;
" ?5 ]( d+ Z# E3 A5 |6 I' D) q document.all("supertext").style.top = yPos + document.body.scrollTop;
+ z9 {) w5 z! H }( [% O" K$ `8 O6 X; [7 n9 @/ s
else if (document.layers) {' U- F$ L! c3 r' T$ d9 I
document.layers["supertext"].left = xPos + pageXOffset;6 w6 M& F" ]* g7 Y3 a
document.layers["supertext"].top = yPos + pageYOffset;5 g: S: r, h0 e G9 f4 i7 ^
}# j: [, ?, R0 }9 Q, e
animatetext=setTimeout('moveBall()',20);" P4 T/ @. h( t0 C" N
}- M; o5 s; [# q6 X; u7 K, a1 ?/ I( E
}
& g7 u1 B1 t" I+ \, E+ S2 P, Q1 H4 I" r) `9 {
function calculatePosition() {4 C% G# T( v! b! |3 ^
if (xDir == "right") {
6 r3 S. H& \2 e4 ] if (xPos > (xMax - contentWidth - BallSpeed)) {
% i3 z, A e; B1 y- K9 |5 x xDir = "left";
! b% X5 c# `! p& X4 X% J' P1 i2 @ }9 ?! J. ^( ^6 O4 j
}% Q m( n# I {% a6 P
else if (xDir == "left") {
- a: v4 x, [& [& }/ c) S if (xPos < (0 + BallSpeed)) {$ P" N2 [) R7 h5 H8 u" H% x
xDir = "right";
7 W! `. d4 J8 h0 z }
; u* J# G- b+ G% Y& ]3 z; N }
1 v' B' f- _: Y+ A" E if (yDir == "down") {
3 |0 _ K H8 L if (yPos > (yMax - contentHeight - BallSpeed)) {- {' p7 h8 _; x5 ?; x) W
yDir = "up";( j, O: _+ {6 K, G4 T% G3 g/ F
} M* [0 a, Q3 ?7 q2 z, `* \
}
3 f, Q4 C9 n. G/ T) y else if (yDir == "up") {
9 u2 _6 R- {' _% h7 q5 a7 G v if (yPos < (0 + BallSpeed)) {
. m3 `) i, j* v! P. k2 z& W yDir = "down";( G5 x4 ]; l* O/ _) R) B3 m
}( ~ G- ?3 U) K* ^ ~; V3 i
}* z2 o/ B9 F/ b: C) K; S4 H6 ^
if (xDir == "right") {
! X7 w; R* m2 b t: B# i B2 e1 t xPos = xPos + BallSpeed;
; \1 M. g3 c$ ]6 T; L }4 S7 T/ r1 @! \6 D: z
else if (xDir == "left") {; F) z9 g8 U) V6 w3 p/ U F7 V
xPos = xPos - BallSpeed;
5 F; T, X3 P @$ `" I3 I }
3 V' k- L6 J" s% j( S else {# Z. O8 W: n9 \0 p1 h
xPos = xPos;+ }# }" l& J# k" W2 K
}; B `) o2 s# V) Y, E- o
if (yDir == "down") {
2 j+ v- X% u, X' p9 c yPos = yPos + BallSpeed;
$ m2 ^' m0 \0 x/ v }, h. A. d* U; o. A( u
else if (yDir == "up") {- G) @/ D/ U. y
yPos = yPos - BallSpeed;
4 _/ s& t& z0 q& o9 V$ m( n) A ^ }
0 h$ p2 K: V `) Y& ^ else {
9 J$ S, h& U8 }7 u- w. f yPos = yPos;
. y( i+ a0 J# T7 F" }1 h }
/ h9 P' I7 I7 M# }3 X6 W* o }
: U, n2 s: W2 L5 e
7 _ w& m9 w& S$ S1 I4 W3 W3 P) Hfunction hidetext(){' ]$ \* \2 o4 {# l
if (document.all)
# W$ _8 C, V8 t v0 h. `2 ^9 q# h" Gsupertext.style.visibility="hidden"
# {, j9 l/ I3 y" a! welse if (document.layers)
% e. X; g7 G7 S, d9 o) ldocument.supertext.visibility="hide"
6 Z0 ~& O! I: \2 ?& U1 u dclearTimeout(animatetext)
$ f3 n y6 |3 H) x! P6 J8 f}
; h; Y5 d: `; k {7 ~6 j8 ?5 }* l4 E' ~. o( X! g9 b3 F5 @5 z+ S
if (document.all||document.layers){
! N0 r/ H9 Z5 v1 ndocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')- R$ |- t5 i' S0 q
window.onload = initializeBall;
9 Z; c( p0 i% X1 P. Owindow.onresize = new Function("window.location.reload()");6 t# \+ E/ N, D( m; ?9 p+ X
}7 x2 b5 c" S$ m* V5 S# b0 _
% B3 f3 s9 i7 }) @</script> |
|