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

|
网页之不断弹射的文字-特效
<style type="text/css">8 h9 p. C4 {- [% M' {: Z
#supertext {
8 S3 b5 d# u: a6 S3 x. ?position:absolute;, S6 a: ^, L( o9 g
left:0;; |$ M+ f. Y: `$ T/ G
top:0;: B9 h, p* z! q! F4 h
visibility:hide;
8 [* a9 L) W3 { R) {! u1 o5 yvisibility:hidden;
4 K+ m5 Q# L" ~. t1 [ d+ y% K}
9 A6 [5 v5 j/ V5 ?# G3 f" b</style># R8 j% y. m; D! N
<script language="JavaScript1.2">
# c+ R3 d+ G9 h/ T) g<!-- 改变下的字体的大小。颜色-->1 ?! g R8 p: P
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 |! W& |: J; q6 r# b4 Bvar hidetimer='';
3 j* b+ [1 P! `<!-- 改变下的弹跳速度-->
& a( M: \5 K9 C; jvar BallSpeed = 20;
# P9 \1 j. y! T5 kvar contentWidth;
6 [5 c4 t2 ?6 G% f; Gvar contentHeight;
@( N, d/ J" H3 W& B8 dvar maxBallSpeed = 50;' |6 k/ K/ ~0 j; A+ P& C
6 u6 ]8 P L0 _1 N# L. x A
4 M$ B2 Y. f# \, Z% Q' nvar xMax;$ n2 j9 E0 N- E
var yMax;
' v7 i8 E) g6 wvar xPos = 0;: G& p% e# \' [: d
var yPos = 0;2 J9 c$ R8 z1 e1 U
var xDir = 'right';
+ G9 A( {0 K5 B' _var yDir = 'down';
; |, m- j% K" [2 T( h8 L+ G* kvar superballRunning = true;
: a( _0 l7 e. x) I7 [( rvar tempBallSpeed;2 R. I- j/ O8 ^4 H9 a
var currentBallSrc;
7 U1 E: E) R7 z- Avar newXDir;% E5 m8 y! u" f
var newYDir;! ~6 }9 ?) v5 \
: N7 L" d4 C1 ~. F* f2 U2 rfunction initializeBall() {0 s( `' c: X2 }4 u
if (document.all) {
( o1 K! X/ V+ X. q" O xMax = document.body.clientWidth7 q6 L* Q% l( E- y- D
yMax = document.body.clientHeight
1 e: C) v* O8 U1 R c document.all("supertext").style.visibility = "visible";3 y. D2 W! X. t3 I/ X) {' j2 L1 H
contentWidth=supertext.offsetWidth# e# i- a9 Z; l2 y ]: s" M
contentHeight=supertext.offsetHeight
- {8 z: Y3 O1 V( E" O, Q3 L }% N! [! D: u3 ]) P
else if (document.layers) {: c% W/ P' G. A
xMax = window.innerWidth;( n1 V. Q; e' ~8 ^9 S1 O
yMax = window.innerHeight;
% n: y% I7 L `( p7 U) { contentWidth=document.supertext.document.width
3 z5 l G X* w/ y- K8 D contentHeight=document.supertext.document.height0 H# z* ^; d; k. L' o
document.layers["supertext"].visibility = "show";
- E3 l ~ F* {& c- S2 f/ v }3 R9 u- z- l5 j) c0 \
setTimeout('moveBall()',400);, T* \9 l& x5 |. K6 |' T
if (hidetimer!='')+ q5 d& s7 ^0 S5 F7 w
setTimeout("hidetext()",hidetimer)$ j$ I% ^) v8 k
}
# L% z4 B+ S0 ~6 D# ?/ @, I& ~# K6 @ V
function moveBall() {
! \" k" Q4 R/ ?/ D if (superballRunning == true) {; |( f7 x, t4 B+ I C/ m
calculatePosition();
+ }5 P9 i9 Z# |( K- J5 a if (document.all) {2 i3 e$ i7 y( \% q) {
document.all("supertext").style.left = xPos + document.body.scrollLeft;" x/ l3 t4 e1 G& @) ]
document.all("supertext").style.top = yPos + document.body.scrollTop;
& Q9 N2 Q9 t& j: m9 h! ~ } Z6 Q$ }# S# w2 q
else if (document.layers) {* x) @5 W; Q) e4 O9 c
document.layers["supertext"].left = xPos + pageXOffset;1 @2 ^* S9 \2 D; j) W! D; F
document.layers["supertext"].top = yPos + pageYOffset;
& D5 M! k# ^' L0 e* _4 K }
2 ]0 r; q) P0 y2 b; y' I( e animatetext=setTimeout('moveBall()',20);- N& V% c- B) n! E; w% p0 X$ ^! @
}
/ U9 ~# ?( N- ~& u @9 U; J }
, T) {. p5 P3 X
) ]/ `3 S! Q* @# y& X! F) w* Hfunction calculatePosition() {
- L$ g3 o) e; {6 l: W5 A# { if (xDir == "right") {& d) D5 G; }, s* z
if (xPos > (xMax - contentWidth - BallSpeed)) {
9 D" t4 c. n; C( H; _ xDir = "left";
1 H* R; k0 @* h1 N2 u, G/ }: P }! j; R3 [/ o) Q3 J
}" R6 [: W- I% a$ h0 @& H) N
else if (xDir == "left") {
% h) X/ D# m. Q' N if (xPos < (0 + BallSpeed)) {* \! ]1 `' ~$ L4 j
xDir = "right";
& D# H8 K# d& ]' W1 v( z$ C n }$ W. {: K7 s1 G) r# ]
}
c5 z1 K6 y1 \" E$ Q7 d3 d# l if (yDir == "down") {
, ~ T' x, h+ A4 s0 `, @9 k if (yPos > (yMax - contentHeight - BallSpeed)) {3 d6 |6 \" e1 j7 H" h' M& H; X; K
yDir = "up";
; v) I, p! L0 X3 r+ G! B5 u3 f. ~: H }
: ]- z& q8 Y1 q, H8 s% L }
4 W9 {" D3 Q2 ^# s: l% m else if (yDir == "up") {
# v0 J+ g, ]7 c: c- i5 h8 U) h if (yPos < (0 + BallSpeed)) {
5 h( s- f& a% C yDir = "down";
4 E" u" x" n, O; H" ~. ~ }
, G! J" |( [/ n" n; `7 R* Q1 C5 f }% c6 f( ` o$ q% Q& _8 @
if (xDir == "right") {
6 @- E) Y& l% z xPos = xPos + BallSpeed;: f0 M/ s& d2 {% l/ g, ]+ B/ b3 g2 A
}8 z q; ^& q% L
else if (xDir == "left") {0 k. K" x5 h3 b% U& d
xPos = xPos - BallSpeed;
" G) t ~( S5 U+ ? }
3 d" M6 T4 r2 X' g7 D9 s else {% ~- Z @( W6 H& U& v& [8 ~2 h' P2 L
xPos = xPos;
! a v; v2 |& I$ X8 m% I }" V( w9 V3 n0 |4 U
if (yDir == "down") {; B. _. o+ ~. m
yPos = yPos + BallSpeed;1 g& A& `5 l& j6 _; L& S
}4 N8 [0 u$ \& E
else if (yDir == "up") {
! W# j" _# w' P) U m yPos = yPos - BallSpeed;+ @- P2 @6 K& |/ q+ \4 d! x
}
5 E/ u8 \& g3 a* d, i else {
5 _2 L' Z6 T" | c; P yPos = yPos;9 j2 ^' }( ^. g. v
}% o: V/ Q, y8 C1 p0 n0 p
}& d0 g6 r& ~' i. K$ O0 |5 l
4 d& r& ?& _0 p4 i4 l1 ^
function hidetext(){
2 v* R* c6 o; E' J, s! T; A0 K) g2 nif (document.all)/ C4 X1 i0 L7 I% Y6 l
supertext.style.visibility="hidden"7 R2 x% \. S* M6 N$ I
else if (document.layers)2 X/ [: p' B2 k% C) h0 t
document.supertext.visibility="hide"7 G p+ r: c, z9 P! V
clearTimeout(animatetext)
3 Q, T a5 Q4 B3 Q& E}
7 ], @0 U+ N! h. r j: n
* p7 Q" Z8 ^+ U6 s; q" D$ Y0 \6 Y2 @8 @if (document.all||document.layers){7 ~7 @ D9 o7 x6 k! f
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
i" F/ F1 z/ j G4 r& L: Wwindow.onload = initializeBall;6 b4 W- E: e$ W0 v( Q q% b0 F$ s
window.onresize = new Function("window.location.reload()");
: @ Y9 p2 q* a$ Y+ v+ C: b: J}1 {0 ]6 V2 f) m4 b( _
& a6 o8 p/ [, A: F9 o5 n! {1 j- j# k</script> |
|