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

|
网页之不断弹射的文字-特效
<style type="text/css">! u0 o6 H8 G( D6 |6 x2 h
#supertext {" R. ?2 Z( [( W8 b
position:absolute;
( j: i* K5 P9 U" P6 X1 W2 U; fleft:0;
/ [# a* v0 v7 i8 Q7 b, Ktop:0;
5 M4 ~& [. |" T* s$ uvisibility:hide;: |5 Y5 n6 |# i1 @5 B& j
visibility:hidden;, w( j9 G' j: W; I" j, O7 a) P, f
}4 g5 p- }! W$ i1 J" G6 t( O
</style>
H3 `- c( b1 b0 {, V<script language="JavaScript1.2">' l8 i( h! L7 N3 f. B6 W! v% S* D
<!-- 改变下的字体的大小。颜色-->0 Y! D0 p: @' j8 P4 b
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ g7 Q. ]' P$ p8 {1 ^$ [
var hidetimer='';
" j& d4 L0 {0 l( r. f4 @<!-- 改变下的弹跳速度-->
; }$ z5 C9 Z3 o2 w5 n; gvar BallSpeed = 20;0 s, ^7 y- d0 v5 }
var contentWidth;
8 t/ |! [2 k$ j# ^var contentHeight;& N% j' v2 \/ l$ k& K
var maxBallSpeed = 50;0 f2 ]2 `1 ~; B: p
6 f9 t' \+ M* R2 J# Q8 ~. z* z
5 Z; U6 c& a* k. S) y9 Z
var xMax;
9 j6 p8 F) ~5 a% uvar yMax;5 L( I' T: K/ K2 i' h- ~
var xPos = 0;
7 ~! `0 ?$ k2 N* p' K W1 Tvar yPos = 0;: x& a! X& O* |3 H/ Y+ W
var xDir = 'right';& f, j3 t+ X+ x0 W: R3 N0 d- {6 k d
var yDir = 'down';0 S h: ^0 K' Y# e& Y
var superballRunning = true;* v. d/ K7 g- _
var tempBallSpeed;
# c( H: Q. J: U4 [; w7 o+ Uvar currentBallSrc;
4 c M4 Y. `& C4 V/ Vvar newXDir;7 N6 m! a7 J% K5 ^" c
var newYDir;
- i8 E9 H& Z; `$ c% K' b' D: q! d. Q9 `9 {& S# J
function initializeBall() {. J6 D" w$ J+ c3 N* z3 U& f
if (document.all) {8 W' j0 @9 q$ s- g" x" Q0 m! s
xMax = document.body.clientWidth
/ S; ^0 a8 I: k4 i yMax = document.body.clientHeight
9 q# f5 Z# V' {) j5 [ document.all("supertext").style.visibility = "visible";
( G( Y: Q) B# G# \% f contentWidth=supertext.offsetWidth1 r3 U$ P8 k7 |& }% l+ d
contentHeight=supertext.offsetHeight1 [* c+ h& \2 ]8 T
}
- [3 L, H2 Y1 A3 @ else if (document.layers) {4 V' F; y# F9 k' X. s5 W
xMax = window.innerWidth;
# q7 ~$ O/ N T6 E8 F. r0 O, H* J yMax = window.innerHeight;
6 |5 z1 D% D* s contentWidth=document.supertext.document.width u4 V! j# a# X C6 f
contentHeight=document.supertext.document.height
/ ?7 J! s8 |1 A$ ` _8 Q$ P document.layers["supertext"].visibility = "show";
6 y+ r* w; f. [. m$ V+ N2 {1 X }
* ]$ X. l6 n: ?- s setTimeout('moveBall()',400);
/ c4 Q& |9 H. e A! p% b. s$ g9 w if (hidetimer!='')
, K7 b0 V2 }) H+ x7 M setTimeout("hidetext()",hidetimer)/ l' a& R$ g( b9 c/ F7 b8 V
}9 i5 Y$ M/ Y- W7 K* \$ i! B( L
7 _! p' ?# h0 l% p) h* q0 u
function moveBall() {( V, d" M' g' d+ M' n2 `
if (superballRunning == true) {" f/ ~7 Z4 X5 x0 ~. L$ `' s
calculatePosition();; D G9 a% F W3 z/ j
if (document.all) {1 r, \- z% G$ l6 K d1 m" [# D6 n
document.all("supertext").style.left = xPos + document.body.scrollLeft;
, M6 [% o6 B: d. a$ t document.all("supertext").style.top = yPos + document.body.scrollTop;
& C; [: L+ g5 f; i5 C& I* Z8 [ }
, S, R; z I1 Q else if (document.layers) {
7 v$ ?& i# q, x4 \6 G& o2 T) O document.layers["supertext"].left = xPos + pageXOffset;; ?: q t; g' q
document.layers["supertext"].top = yPos + pageYOffset;
- [& D5 G( ]$ v5 E$ l7 {* L1 Y7 g9 m- Y }
% y) K% u! }2 D* v6 f8 @8 k7 l animatetext=setTimeout('moveBall()',20);
& ]' M4 v |( l! K& U+ {) [1 ] }
7 K b1 f7 I% ] }2 P# |8 a% g) T. U! _
- A- }8 Z" q2 K4 Z# Z; ?+ L& sfunction calculatePosition() {
9 V7 E+ Q. Q l6 K* C2 } if (xDir == "right") {
/ k' w/ N. U( r' J% w4 r if (xPos > (xMax - contentWidth - BallSpeed)) {% r% O4 H% ^1 c% f
xDir = "left";
8 G/ @( r( _5 u# h0 N }
( d' a" f7 x, l# M }9 z; [; F: S O& H
else if (xDir == "left") {
) ^& ?1 W/ C& b# s# l s2 p- ~) R. | if (xPos < (0 + BallSpeed)) {
N: M* D5 g, d$ N+ @+ v xDir = "right";6 z% |( n5 w* e& y% Q8 {
}
7 e& d% S- E# L1 F }
. |% u9 ^* b4 |- `4 m$ l if (yDir == "down") {
; ]! K8 @- L: N. C" q, @ if (yPos > (yMax - contentHeight - BallSpeed)) { f. ?' K2 d# q- d. ]) a
yDir = "up";
9 C* v4 `. O! K1 L }
! ]- _. M1 j/ d }* i8 g9 y- {1 t. N. K! N# q
else if (yDir == "up") {* ]7 Q4 p z9 T& Y' G/ n
if (yPos < (0 + BallSpeed)) {* U+ @ R$ A/ X& Y) Q7 F9 F
yDir = "down";
4 \6 S4 D4 D+ H$ m7 x }
( {7 e: ^* |& F; o }
. @7 y$ r. ^' F) d* M- c* i; I4 A if (xDir == "right") {
3 e+ M7 b; b0 N# M xPos = xPos + BallSpeed;( p2 X* t2 ?1 _/ @+ m& Z. d
}
3 `5 i) M& T5 t' f1 ^ else if (xDir == "left") {9 b8 y# g1 h7 _' I
xPos = xPos - BallSpeed;) d+ Y& q4 o. @, g
}9 ^6 y2 d( h7 Q, Y) o1 E
else {
$ U' V" w, b$ w% D1 N xPos = xPos;
0 O/ b( |) z8 Q }% Z+ y8 T' X: b m
if (yDir == "down") {3 P. T& b1 W: ^( f) Y/ z
yPos = yPos + BallSpeed;
( c( I' R0 E; Y, `6 ~: e }# h8 }" c* `" }$ a2 ?
else if (yDir == "up") {! E( L. g( Q1 ^+ o# {4 e9 B
yPos = yPos - BallSpeed;
+ a6 w d" M y1 Y& q4 M- C }
. r/ M' Q/ g/ O/ n) u- R/ X else {- t) \! o' e$ g8 J$ I9 y1 S5 v. U& z% R
yPos = yPos;
" z( E: B$ d' _; I2 {) B. X }
) I$ R8 G9 W1 B }
! f; a7 l- D" O6 | s4 [
7 f3 j' `% A- h! L! a/ }function hidetext(){
+ Q; ?, z% a A- Z- u! _% g) V$ gif (document.all)) M$ h$ H1 S! Y
supertext.style.visibility="hidden"( J( C9 Y+ Z2 W# @# N2 @; v
else if (document.layers)
" p% l% b6 y# I H- U5 n; f* gdocument.supertext.visibility="hide"2 P- Y1 K1 {! a8 h
clearTimeout(animatetext)
1 }4 P3 ^- ^- A X! j. c$ R/ `* y}
8 s% J. e. G) o2 j1 E. N$ c$ y; i/ b
if (document.all||document.layers){
( N$ a c9 I9 f9 A" K) J% N$ Y6 f+ Ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ v0 ^& Z' w V+ w
window.onload = initializeBall;
2 K" \# j' X. E0 w6 c: S Kwindow.onresize = new Function("window.location.reload()");1 \% `# I3 l5 M+ _% I
}7 U- C0 e% X: M/ Y$ \- L9 V. Z
' I Z0 d4 Y, O- N+ V$ i L1 Z! q% E
</script> |
|