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

|
网页之不断弹射的文字-特效
<style type="text/css">* p8 {( ?2 c& ]: M& G3 f
#supertext {
6 C z6 V- Y' Y* r! s( _position:absolute;
+ L( B% C. j# S0 d: y* `left:0;# C* S+ A# ]) h+ E- } L: O1 f
top:0;$ v" t+ ~/ N1 Q+ l. T
visibility:hide;% M# N0 p( p5 D! b, U
visibility:hidden;
) a. `" A8 Q5 W9 r}( ?. ^( x) w z+ n
</style>
' T' f3 J4 a7 S7 r: f" v<script language="JavaScript1.2">* C/ X/ d! f; P- J3 }; U
<!-- 改变下的字体的大小。颜色-->
7 a: j& |! _& p* W/ F( p* Zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 U! O0 B! x8 u3 N
var hidetimer='';
/ H f6 ^; h( R4 U( m<!-- 改变下的弹跳速度-->
6 Z# X4 W* e$ R5 [1 |/ m- G. Evar BallSpeed = 20;
2 u1 N) V! A |4 A8 J! Rvar contentWidth;
; @4 J2 T" ]! u% a' h9 xvar contentHeight;
0 _ o, F8 t( t0 b" Jvar maxBallSpeed = 50;7 l. i" r# e! V, p
9 M8 K% B7 i2 L! I- P; p# V
2 ]6 X5 W! n3 V0 Kvar xMax;/ O0 ]1 U! v. e4 `) Y) ~# m2 V
var yMax;. R, Z, w* v u1 {5 k
var xPos = 0;
2 ^+ I) n m8 b) i7 R* v5 cvar yPos = 0;
( w* t+ P& L! p& f( @var xDir = 'right';
4 n9 j' J2 ?* Ovar yDir = 'down';8 M- V5 J) r5 `
var superballRunning = true;
7 x( Y9 j9 M3 @' |& H1 ]: [! Bvar tempBallSpeed;
) ^, Z/ E! Q7 f. ]3 p! C) o! hvar currentBallSrc;
! w2 h. Y; D) d6 P/ Lvar newXDir;
; J' |& F% V' xvar newYDir;
; j m: k8 S( t
. }+ o- t" I: f; [* a- cfunction initializeBall() {3 ~# a4 r& T/ C2 f
if (document.all) {
: `* ^ s; q0 f# ] xMax = document.body.clientWidth
2 d: ]4 c4 [# ?/ G1 ? yMax = document.body.clientHeight
5 v M: j8 ?8 G: Z" d/ n3 a document.all("supertext").style.visibility = "visible";% x8 i! y$ ]4 T! @" F3 c+ a; c
contentWidth=supertext.offsetWidth
: f& W4 t, J* a5 w* ? contentHeight=supertext.offsetHeight) r( l" A8 `- l8 o
}8 L" u# d* n3 @" s" }8 W" p0 ^
else if (document.layers) {
& T: \; y% r$ V4 r5 o( Y- |6 F xMax = window.innerWidth;/ a c* f* Z- F6 N1 A: {2 R" H
yMax = window.innerHeight;
' o, w4 g% t( F, P6 C+ T contentWidth=document.supertext.document.width
3 f! F, W% D% B6 Y+ {" i contentHeight=document.supertext.document.height
7 _) v6 ^3 E* V- W document.layers["supertext"].visibility = "show";; H3 Y6 b3 h( E- p. V: R* c, p# H
}
( f5 L# b Y1 u0 l, {) W setTimeout('moveBall()',400);6 W" k& o. Q& P' U/ A6 E" U
if (hidetimer!='')9 I. k# b( R) j
setTimeout("hidetext()",hidetimer)& l7 T! c* }! Y' l- M
}
0 c9 U) {! M9 P6 C% [4 D0 p; X1 M' m8 g' D9 O; W8 ]
function moveBall() {9 @5 B0 R' J+ F' Q' P7 @( P
if (superballRunning == true) {
@% S- ^0 @7 W. S }8 i- ` calculatePosition();( _8 k r N) G3 U5 M8 e5 F
if (document.all) {" |/ e7 j; Z4 z* a2 [
document.all("supertext").style.left = xPos + document.body.scrollLeft;
" c; |* Q, H) {- ]2 Y1 h document.all("supertext").style.top = yPos + document.body.scrollTop;
/ e: j Z p. A( T$ o3 e3 v5 m# K' S }
$ p. U" H7 F7 K- _$ v @ else if (document.layers) {. h) f, I8 q- x9 z4 _4 z
document.layers["supertext"].left = xPos + pageXOffset;9 n# g$ K) Q$ D, i3 h; l, y
document.layers["supertext"].top = yPos + pageYOffset;
/ b+ g3 |; L3 |$ o3 \ }1 s z$ f& Q* B( g' M
animatetext=setTimeout('moveBall()',20);
c4 l9 O3 ^/ h9 ~. G5 v }7 o; G, x) L( W$ P9 f
}; \& W( z$ R- L
2 A4 z3 Y8 m7 B' F5 z3 hfunction calculatePosition() {
2 P" p: p) y1 m4 N, @% p if (xDir == "right") {
- y: L4 [6 i6 R% P( [ if (xPos > (xMax - contentWidth - BallSpeed)) {
& a0 i9 H0 N" k' U" Y xDir = "left";
/ ~6 v6 ~% H, ?8 H+ U }) f. `4 j1 n9 {- |- Y
}
) V) K9 o* x' H* V else if (xDir == "left") {/ S7 S# o& e. x+ N1 f+ ~, B
if (xPos < (0 + BallSpeed)) {5 T% s# U3 N2 W" I# v, L" v* L O
xDir = "right";
; ]4 B4 M3 W1 z& }( W" U. U }( N7 ]& r( s2 b8 B& h% O
}
* W7 d; k6 [% V7 u' E5 | if (yDir == "down") {# x. l9 f' D3 A8 t+ @. i
if (yPos > (yMax - contentHeight - BallSpeed)) {
& } N: w( V5 C4 h0 F5 h1 d% }( a yDir = "up";
# b- F# P! \. b( p$ o2 @ }
5 n# A+ v/ n) c' q }) @9 D, {0 S4 i/ l; i3 I! K
else if (yDir == "up") {. r- j$ F" `( k
if (yPos < (0 + BallSpeed)) {
- D, u/ J( }* ~# X1 h yDir = "down";, f1 a+ t- I* T: Y% Q" n7 k( {9 n
}- Y% I* k+ N! T! \. D; z' s
}# r' ~0 o3 D. b' J) V0 K
if (xDir == "right") {
; l, U8 h2 T) e0 K# Z3 A2 a0 `. z xPos = xPos + BallSpeed;
/ i8 P7 x# _/ C i! Y }
, r4 V: E* T+ f. x' P else if (xDir == "left") {3 x! B/ B F5 _& m. ^6 b
xPos = xPos - BallSpeed;
+ q5 R' c" K) K7 `; M% v }. y9 O) m( e& m O* Q) e3 _+ @+ A
else {
% L1 K9 D( j& u1 ]" Y: n xPos = xPos;
7 M( K! \: P- `, Q/ N) L9 c& l }, H q! W9 N5 } b, G$ F
if (yDir == "down") {7 P% n% [' B3 e6 c. R. ~' J
yPos = yPos + BallSpeed;' q. a/ x6 ?& i4 K V$ V
}
1 X" C# `5 \2 ~' D# d else if (yDir == "up") {3 Z' A f+ i1 j8 p7 h
yPos = yPos - BallSpeed;7 ^4 f1 g9 @3 T# p n* h. U& r3 o. T
}
2 Y: i5 g# F# a+ V3 t: S else {
p# \7 f( L7 n yPos = yPos;
% D2 d0 B8 Y) o, H! ` }
" |, `: t. t" [$ I }0 W$ d0 e3 I, t; S! V
* {4 g' j6 @; x6 g1 l
function hidetext(){ Q, n! m. \5 V3 _+ n( C6 d `
if (document.all)6 G, [& J) z' ~: k
supertext.style.visibility="hidden"- f) a+ |' k! R0 _& J0 l
else if (document.layers)
# q6 v/ ^0 z. o6 E0 @document.supertext.visibility="hide"
: j5 w! K+ y! c, r: AclearTimeout(animatetext)# v1 i% _* _ u; u
}
" }. s3 w: l8 a- D: |+ n1 `! Y/ L' ~8 Y6 b A/ }# ]+ ^* h
if (document.all||document.layers){
+ ?0 V. {4 @$ bdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* ?3 B w5 h- f4 R4 F8 vwindow.onload = initializeBall;
& r3 l7 Y: O$ i) }; c. H8 Mwindow.onresize = new Function("window.location.reload()");
7 Z7 f( X( q9 o. d% {' Q2 t+ s}4 R, G; V/ h1 E- Q# ?+ X9 E
$ C" a* q# r) ?
</script> |
|