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

|
网页之不断弹射的文字-特效
<style type="text/css">4 p/ A6 I; q- u' b6 M* z
#supertext {, f! l9 j& H( i2 M
position:absolute;
6 ]4 m6 g8 B5 a; l* x8 Qleft:0;" r% N J1 V% { [ G/ _
top:0;
& Z1 a4 R" C3 r Q) Kvisibility:hide;
. R" F7 D( V3 P/ N) Nvisibility:hidden;
; F |: I% n, P* @}
: Z/ q, R& z. ?6 o: K</style>
1 i7 y4 x4 c5 K! Y( _9 Z- f: D<script language="JavaScript1.2">( t9 h' s2 A* J/ v& n
<!-- 改变下的字体的大小。颜色-->
* Z% [ ^0 U& ?! Cvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 H/ h3 _( c/ p" h' b4 M4 Y9 k/ Z
var hidetimer='';, C( `# {* v1 E) ~
<!-- 改变下的弹跳速度-->% S4 e/ o; v- J$ |7 \
var BallSpeed = 20;
* V; t0 I' `6 {* C2 z: qvar contentWidth;' ?7 W, c0 P: k5 q" ]5 |+ c/ V6 c
var contentHeight;7 q7 l2 Q: O J4 F0 M" U9 O! `
var maxBallSpeed = 50;
. B% v/ n! S" {' W/ ^+ q! y$ F
$ o% ~' q6 C" o& ]+ z6 x; s- m/ ^4 q* A4 u
var xMax;+ J1 F; E3 `& ~9 q% s( H
var yMax;
3 s' F" L2 v5 j; @5 i( ?var xPos = 0;
1 d, ?1 h1 ^! G: }8 d9 ~2 p* Z4 Tvar yPos = 0;8 H. D+ S7 N! L# ^3 X, K0 z) u
var xDir = 'right';
: Q/ ~; _8 G# [; gvar yDir = 'down';
+ c6 y) `( O& Y3 J% _var superballRunning = true;
5 \9 z% y) U/ i' A- \var tempBallSpeed;: E- t; P/ j$ s
var currentBallSrc;$ y6 ~1 i* {# Z) P" m* E6 [
var newXDir;% k Q0 c) f" _
var newYDir;# A4 L3 p" j9 W6 N
4 l* j& t" N' ~ a. N
function initializeBall() {/ q% a8 K+ f3 Y- t' P) C/ U9 C2 H/ v) t
if (document.all) {
; @2 F* |/ B7 M; l% F; K6 p xMax = document.body.clientWidth
) x4 a' S* D4 `, s, j& q yMax = document.body.clientHeight
0 E7 K" P0 F6 d+ o/ X document.all("supertext").style.visibility = "visible";5 A* r- N" Z N% O+ c8 e
contentWidth=supertext.offsetWidth
4 t% T& r M, s3 c9 ]: z) W contentHeight=supertext.offsetHeight) v" t' r) s, D5 B: v" G6 v z
}
1 o* d7 V3 @7 a& N1 ~# Q% u else if (document.layers) {
! A6 R5 I4 `$ G/ X xMax = window.innerWidth;: Q3 x; y8 j" |4 g0 T
yMax = window.innerHeight;& C6 K) n _9 e
contentWidth=document.supertext.document.width: V& C8 Q& O+ A2 Y
contentHeight=document.supertext.document.height
2 F4 x3 `) `, ]- J% |& ^, q% N document.layers["supertext"].visibility = "show";. h0 C2 b5 K9 c3 D, A: {! l' g
}% g8 B, X9 y1 T. h3 J X" a
setTimeout('moveBall()',400);
9 l D6 G( [2 {; _9 ^7 D if (hidetimer!='')
% k7 @+ K8 h$ ~# w3 {4 t9 c5 s setTimeout("hidetext()",hidetimer)
; {$ J; H4 M# ^ }. Q. p% V4 H" u. }6 ]
3 J% ^9 q. Q1 F) y# Q
function moveBall() {
+ I! a5 [- p8 o0 s- k if (superballRunning == true) {/ q [) F4 N) x; ^
calculatePosition();& D& Q' Y' h5 D
if (document.all) {
1 J: c) \" w6 E, I9 o* P$ l document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 p! H: `+ e5 @3 { document.all("supertext").style.top = yPos + document.body.scrollTop;9 P# S4 s9 m1 Z( r) I
}
3 R! _8 c8 M) y else if (document.layers) {; \2 J' ]- T3 Q
document.layers["supertext"].left = xPos + pageXOffset;" P) E. w3 k8 a( |3 h2 A0 _' G5 ]
document.layers["supertext"].top = yPos + pageYOffset;6 z, W9 H9 r" P
}& w5 U: H" p4 w9 C& z0 W* O
animatetext=setTimeout('moveBall()',20);% B7 _* o* e: X: g
}
! ?% g- M& ~7 R/ k" q6 k! q4 [ }: m; k% L. x; U6 w. `! P7 [8 x( h
$ n. ?; v7 r4 e3 ]' _, j
function calculatePosition() {7 \! H6 U; K3 n+ i
if (xDir == "right") {) w$ e* W5 ^/ d- T
if (xPos > (xMax - contentWidth - BallSpeed)) {& H) L7 C+ ^# _, B; d: _' }
xDir = "left";6 T, G4 y. F- P& O+ [
}& N6 `: `; ]# v/ [! |
} c5 v& O- l) V
else if (xDir == "left") {
/ O; t+ X6 [& b# i9 K" u if (xPos < (0 + BallSpeed)) {
- ?1 e* y5 c3 B" @8 W xDir = "right";9 |. S3 p7 F) X8 i5 H+ u
}
7 u& B+ X9 o# D l }
! Y4 O. h! v- i if (yDir == "down") {
. I! F- e" O3 z; P( K. y if (yPos > (yMax - contentHeight - BallSpeed)) {( n- N N5 V3 c! b( k: ^; S; V
yDir = "up";# B: p4 V2 F/ c% i4 Y( G# {* a
}
% ?0 v0 z7 l1 q! h3 m0 K }
% a3 Y& i+ e% Y7 `4 ~5 U else if (yDir == "up") {
. _ F) h7 x& y4 L6 h if (yPos < (0 + BallSpeed)) {* q/ t8 J! u$ p9 F, S/ }
yDir = "down";
+ E' _5 c4 T m }& O Z/ a! @9 N: q- `, }
}
! z7 ]8 Y; n9 ^: _& t, @+ e# ^ if (xDir == "right") {" I. P/ A5 a% P& |7 w& R! P3 `
xPos = xPos + BallSpeed;5 F' H v% S/ ]9 {: O- ~( _0 V, `' X
}
0 g- ~8 K2 Y7 l& k$ U! A2 w% \ else if (xDir == "left") {* f5 T& g' u+ {/ X- \( X: @* ]
xPos = xPos - BallSpeed;
6 u7 H! o0 p9 d3 {, J/ m: X% T }7 K( A t: E% c% C! W- t8 [
else {
* @: O) T F/ z, G xPos = xPos;
( o4 a" W( A9 g2 Y }4 d/ c) ~ u" ~
if (yDir == "down") {: w6 a. q6 m- [/ n/ A
yPos = yPos + BallSpeed;
# M8 ?0 r! ^! Z1 ]$ n }0 }* n; D0 `3 Z, p' s" F
else if (yDir == "up") {1 `8 n) E- b- o6 m Z
yPos = yPos - BallSpeed;# _9 f0 ? S+ D Q6 ]9 R
}3 n; e: N5 C1 T# X" ^
else {
. Q# E t6 }% J" H; @3 j yPos = yPos;
# t5 B0 [# x+ [$ @7 ^, Y }
3 @; B: P0 I2 _- c1 j7 }2 X }
2 k) y! r9 N; N/ H3 _3 o9 Y7 s
3 N6 X H) @) Yfunction hidetext(){9 [+ m8 K5 s' \- J! x" c5 W" t U
if (document.all)5 J* I* n" v9 }
supertext.style.visibility="hidden"
- ^ h' N, J% `+ a) Relse if (document.layers)
y+ W8 H/ v1 {6 H$ _document.supertext.visibility="hide"- _/ X: Z' m h) K, ~ Q3 E) l
clearTimeout(animatetext)
1 o2 y0 _5 r6 c: b) E* g* O}
8 m' n9 w# |: B
% z. _ L7 C$ E: g- Iif (document.all||document.layers){) Q V$ F4 q4 F& R& h/ ^
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
2 A I8 x, E1 {- d2 W. Nwindow.onload = initializeBall;
. a9 G) O3 s) ?9 S" awindow.onresize = new Function("window.location.reload()");
, ^" y+ N) v2 L6 l}. n# L) O0 }2 Z% k
( K2 s1 T' O9 F) [
</script> |
|