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

|
网页之不断弹射的文字-特效
<style type="text/css">
3 H1 b5 N6 C- K5 I2 N#supertext {
, W) s. ^2 G: s3 K" a1 ~2 zposition:absolute;
+ }: M1 R% E1 F7 A+ r, a5 Cleft:0;$ H& ? m. ~# U- w3 A- d
top:0;2 ^9 E6 J5 L" Z# Y
visibility:hide;$ K7 c2 a9 _* L) H$ o& [; N8 ^2 e
visibility:hidden;9 M Z6 _7 f' `8 A% l
}$ F' b0 I* V/ a
</style>7 o# ~: u8 m& O% ?) T" b9 [+ H* v
<script language="JavaScript1.2">
+ T4 ^9 `4 }6 j+ O3 Z8 l<!-- 改变下的字体的大小。颜色-->" H5 h0 f0 a4 @ M7 Y8 C5 S
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) P( K% c/ j* m6 N* a0 Z4 ]: Rvar hidetimer='';* \5 b- ? q* W
<!-- 改变下的弹跳速度-->: P* u- N2 l, P! i* J
var BallSpeed = 20;
$ H7 n. e0 B& h! u3 Z8 Fvar contentWidth;; d$ W; ?. q8 j% R( M S' V n
var contentHeight;% M: s6 a! i7 B3 a! B
var maxBallSpeed = 50;& R9 X' u! P S5 L
4 F* x$ j: G2 z$ w
4 F: [2 t# B. J: ~. Rvar xMax;
A! w) F: Q! Z5 S: D* ^( c6 A# Lvar yMax;
! E% O: ]$ y/ K6 wvar xPos = 0;
6 a+ \4 ^4 Z ]: f* Wvar yPos = 0;& r" D8 C. b- K0 L' u1 G1 F
var xDir = 'right';
: J! }6 B& f [5 Jvar yDir = 'down';! ?9 F5 i0 a* n6 F0 D8 b+ }
var superballRunning = true;7 n, l, [# y# S0 N
var tempBallSpeed;* Z1 G$ }& X( d4 q3 a8 F
var currentBallSrc;
0 i& r' R) P, L% I0 Yvar newXDir;) J, r6 B* a' z2 L$ x8 g
var newYDir;3 Z1 }+ K; M; f. M8 J- ~ G
* y# H7 G3 V- d6 A) z0 A# \6 \" m
function initializeBall() {
; F+ ~ [! |& M* ?5 Q% u r if (document.all) {* K& k }. S/ y
xMax = document.body.clientWidth( S( O$ E7 L, a# k& X( N) C
yMax = document.body.clientHeight( F" S. y3 X) I* L: N
document.all("supertext").style.visibility = "visible";
$ V( C5 Q. P% c- J ] contentWidth=supertext.offsetWidth F6 y+ _% D6 ~/ d7 ]' a8 u6 }
contentHeight=supertext.offsetHeight# z9 j" ?! j% h/ K
}( u% i" r/ ~, m: B# P& |. W7 ~) M& e
else if (document.layers) {& n$ |+ U! U5 m S' h& N0 f
xMax = window.innerWidth;
. d3 t' a4 B3 |- R( T4 d0 r yMax = window.innerHeight;1 M0 C5 p( O% A# a: i
contentWidth=document.supertext.document.width
. H) T( Q- }4 J4 p! p& i. j contentHeight=document.supertext.document.height+ G% J, \ |6 q0 E9 O) y, G
document.layers["supertext"].visibility = "show";
- q( L) q! E6 q& }+ M: x& \/ t3 ~ }8 }6 K+ ^0 y2 _% i: v5 \; I( _
setTimeout('moveBall()',400);
" @6 D8 ?3 p- [+ I if (hidetimer!='')
2 U! _! ~6 w5 m- l setTimeout("hidetext()",hidetimer); F B- ?, H' X$ s/ c
}& T5 y0 N/ {$ n! E0 y
( G# p, O, p: i" X; j$ ?! Z5 i' ~: l' ifunction moveBall() {
$ Z% w# {' ?9 `( I if (superballRunning == true) {7 f: g6 v6 z* M! A
calculatePosition();6 z/ ^ L9 b. U2 G
if (document.all) {% B7 q% d% R% i T
document.all("supertext").style.left = xPos + document.body.scrollLeft; K1 i& w$ Z( Y0 Q
document.all("supertext").style.top = yPos + document.body.scrollTop;
: E0 @6 _' K0 f1 K } h0 N; I1 L% R6 D C# e: m
else if (document.layers) {. x- `* M1 q1 r! e" ?
document.layers["supertext"].left = xPos + pageXOffset;
! I3 \4 @6 [# h! S document.layers["supertext"].top = yPos + pageYOffset;
# f) ^( N8 I: i8 I }
5 q$ A& n/ Z7 H) I! q animatetext=setTimeout('moveBall()',20);
( \) |2 }% f# e; L \5 w }
4 i; ]) E _, I! l$ O U9 J1 q; V }5 m: C6 u& g# \+ d+ ^
/ t+ }8 b( c/ o" a& i- v, i
function calculatePosition() {
~5 s* B9 F. B; [) A, p1 K if (xDir == "right") {
A$ D; m+ D5 c6 @ if (xPos > (xMax - contentWidth - BallSpeed)) {% D4 i& W' S9 N5 w
xDir = "left";
) u7 D% i1 t8 A0 c# @ }
" `+ u/ C9 ]9 t$ F* C% g. i+ S- ] }6 Y( L, h1 ]5 a* L G) H
else if (xDir == "left") {& _' ?: Q, ^9 y5 ?2 S- @
if (xPos < (0 + BallSpeed)) {
: m7 z, g( K' ?4 g8 p: Y xDir = "right";: T* `/ @/ v8 C" @: ?. O
}
* ?6 s0 g* {# ^5 ]5 a; j; K2 j }
, K. \" R4 F/ B5 p) h if (yDir == "down") {
& f- L: N* ]' r! A if (yPos > (yMax - contentHeight - BallSpeed)) {
3 r4 S0 G M" I3 y, Y) {$ L yDir = "up";
3 ]4 F, n$ j+ V5 u' A) z) j7 C/ B }- N8 e& @" A% ?# j7 p) R
}
' h$ h' G j$ W; T# h9 ~9 f2 x else if (yDir == "up") {6 q: A# Y. A) u& A
if (yPos < (0 + BallSpeed)) {. w# e5 [( ^; k8 X2 M! k2 F3 W
yDir = "down";. V# ~. `. q2 [. b
}0 i/ k! T! V5 ]# ]
}
) V. l" |9 q; i9 j* n+ n if (xDir == "right") {
9 K, X; r* |. [' g/ s7 X xPos = xPos + BallSpeed;
" l1 G2 f( q7 b }
! l- a$ S! E0 B3 f6 j! Q+ H, ? else if (xDir == "left") {
- \0 W3 O& t Q xPos = xPos - BallSpeed;
, F. \* C. o& W }
( H/ f2 k0 j& u9 r$ {' K% K5 f! V else {
& T" p' z0 A; J6 c4 t( Y8 g xPos = xPos;
6 {" Q1 t2 J' ]4 \% K/ i }
: [& u" ]) W) M, \8 G8 N7 D2 U if (yDir == "down") {
& y0 ]7 S) W- e4 J a. q+ K7 p yPos = yPos + BallSpeed;2 Z# I W' g5 \. M; _( ~
}
, W( K. P9 Y+ M4 ~ R5 \% X8 v else if (yDir == "up") {
$ h+ d8 \# t3 G1 u1 Q0 p+ v yPos = yPos - BallSpeed;# w# @9 y6 B' O# s) k( |
}" T" D* {1 \' u$ I2 k% F
else {
1 |/ q1 F7 j7 V" b yPos = yPos;
L/ h$ N. u' l0 @. A. |3 w }
* |. o! i6 @$ L6 G# E6 a2 { }4 }) v; b# Z- }0 C
$ P f& h N" B% \5 t* d( Wfunction hidetext(){' ?: w4 c. a! T2 j
if (document.all)
) ]2 v4 ~* K$ h2 P3 T2 nsupertext.style.visibility="hidden"( g8 l6 U' M( ], e Q
else if (document.layers)
, m; p: s7 Y& y8 i2 c9 Vdocument.supertext.visibility="hide"
7 U2 ?+ O: i) d+ NclearTimeout(animatetext): y9 w$ P ]6 w/ y
}1 H4 B( t. n! o. h
3 y, u* v: K% y8 n2 T2 xif (document.all||document.layers){4 v! u; z5 ]% _7 P, ^5 t0 d
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. `4 R% n( V$ R. Awindow.onload = initializeBall;# p: f+ l; E M0 N# _
window.onresize = new Function("window.location.reload()");
; U) Q8 |" `. J! A: U7 y}
% A' c5 C7 M5 D2 v/ k' R! O5 |) X+ N% _2 M+ x; o0 `2 q
</script> |
|