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

|
网页之不断弹射的文字-特效
<style type="text/css">. e* Z- S4 W% Z3 Y, o; x$ |
#supertext {
" `0 p- S% r |position:absolute;- s* z7 \$ u; @& |
left:0;
) e" S D* K4 Ctop:0;
% z* M. [' {( Y. L1 t0 @visibility:hide;3 \' N3 U! {6 T" q
visibility:hidden;
) X' m, p! S+ n2 |}
" b9 C4 I2 x- \$ C3 M/ H8 B" S</style>+ b3 |& Z9 b& e k2 P& d
<script language="JavaScript1.2">
4 G/ e9 L+ k$ s) ~<!-- 改变下的字体的大小。颜色-->
' e% b0 k+ c/ {- k, U0 hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 C c9 B& @+ f pvar hidetimer='';
/ Z$ P* x4 d0 F9 z2 `. b9 X<!-- 改变下的弹跳速度--># k5 V+ b! @0 m Z
var BallSpeed = 20;- u6 V |. M. l: K, C4 f- s
var contentWidth;
5 U7 F' R I" p; O: t( W% r& e* qvar contentHeight;) ?( T& J/ t1 a$ h
var maxBallSpeed = 50;! A" K/ B8 u; g6 q9 ?) K
; R7 ~7 R- [% F+ _7 I3 ]; X! d; \
! h% \9 d4 e9 A& F$ C- N0 B6 `; ~var xMax;
$ U, K( Z8 s: Zvar yMax;
2 t' E9 E, _- j8 i3 t* y2 Tvar xPos = 0;9 ^3 x T. r" V: F6 s7 d
var yPos = 0;
3 N5 ^3 B1 W- u* Fvar xDir = 'right';
; |1 d: \4 {/ ], m! Z' kvar yDir = 'down';0 K5 v( R/ l7 t3 h! J% X
var superballRunning = true;
- ?3 f7 f. l% O U" h0 @/ j8 Lvar tempBallSpeed;! N4 ?+ A* d6 M# V
var currentBallSrc;6 g, }4 |# w5 D u* k* r% G1 X
var newXDir;
1 m" j6 S. r( D. hvar newYDir;; \" U/ ~' d2 t5 U3 N
2 U; U, H9 `. ?# b; U
function initializeBall() {& ]. ]* n) h/ a( v- \3 z+ }
if (document.all) {* c8 T/ x* {! k& r) J8 \, }5 E/ ~
xMax = document.body.clientWidth
( ^2 P4 _* A" V8 v! o yMax = document.body.clientHeight5 H# s+ f. c+ y9 A2 J- g3 m* ^
document.all("supertext").style.visibility = "visible";8 k! y% C M# b4 j/ u
contentWidth=supertext.offsetWidth" N+ l! Y& @9 x
contentHeight=supertext.offsetHeight
4 A/ {6 i/ O4 h; o }5 x! M. x! A; L! o+ X
else if (document.layers) {0 R- M1 N+ t8 o9 c- z) R
xMax = window.innerWidth;
9 V8 I+ ]3 g$ q) } yMax = window.innerHeight;
. X+ [ |( _1 }5 i; w7 m3 G contentWidth=document.supertext.document.width; f: C. t k5 h4 Z$ x
contentHeight=document.supertext.document.height$ U$ k- H+ f0 j1 E2 f0 _
document.layers["supertext"].visibility = "show";
- D ^& t0 }! e* n8 o. t }
9 O+ ^* S5 ~1 q, ~ setTimeout('moveBall()',400);1 p+ I& p/ I. f2 @/ w
if (hidetimer!='')
5 `4 o4 `( U, ?' ]1 w( d& ] setTimeout("hidetext()",hidetimer)
. j& N8 g# d! H" i }
' r5 l' }) M: ~' p F- n8 O J- w! l- b. W
function moveBall() {
. E2 L; B: A4 ~4 O: d/ P& j+ ~ if (superballRunning == true) {3 O# ^# [5 ~4 S/ ] e
calculatePosition();
( X/ @1 _2 J4 Q$ M if (document.all) {8 I" l9 I6 C1 O" V2 [! r# { n3 N2 E
document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ {8 _. g5 s% Y# W- x6 r9 r% Z: d document.all("supertext").style.top = yPos + document.body.scrollTop;
. H% g, b5 Q7 b! a) c }
- p* |5 f- b6 E/ F else if (document.layers) {
+ w$ t( Q/ d, M3 w9 W document.layers["supertext"].left = xPos + pageXOffset;
" U7 G* e% o, ` d document.layers["supertext"].top = yPos + pageYOffset;: [4 t4 B* ]/ h% k$ u$ i1 d
}
; e$ H; ^$ i# c5 F9 g9 r6 X animatetext=setTimeout('moveBall()',20);1 a. s( {- H0 J% [" S( g' U
}: n/ W9 l4 ^8 T
}% d5 u; Z" {- _) @; z$ s
0 N6 W- j8 @3 Q+ K q1 N2 q/ b. Q: x, tfunction calculatePosition() {
: J+ |4 G3 o6 V9 @$ P- s if (xDir == "right") {7 h8 h/ ` F" a5 X( Y; _" i
if (xPos > (xMax - contentWidth - BallSpeed)) {8 v0 _2 S- d7 ~' y
xDir = "left";
7 M$ E/ U) Z# t# a7 a }% A( C- v" C8 C3 @ P- v
}; P3 ^1 {5 _) L
else if (xDir == "left") {+ q) s- ^( x) p( ?" F/ w
if (xPos < (0 + BallSpeed)) {9 P* x; V1 b2 H1 h. x
xDir = "right";5 r6 q" Q6 O' V
}+ }1 p e6 Y( d
}
& P( ]: a: g( } k* V+ Q if (yDir == "down") {- ?+ |6 g M! t# m% F. o
if (yPos > (yMax - contentHeight - BallSpeed)) {
% z, ~$ c( D3 {3 A; h8 X6 d8 J$ l; G yDir = "up";
m/ [0 I9 W- E }
9 H# l! J: I! R& X, u& C# T! ^ }4 o. I, d$ p" u
else if (yDir == "up") {' ?! k' V" h2 y9 u9 O
if (yPos < (0 + BallSpeed)) {
; A: P: d5 C- W; x yDir = "down";
( g _4 g- l4 S: E* f* E }
0 V0 u l- x2 z3 D$ D; s. U }
) N' {( `1 K* [1 n( {. g if (xDir == "right") { t0 T" N' ?7 B4 @: ^9 m' x. N& M' S
xPos = xPos + BallSpeed;# w1 O( c( n, A: J. f
}
# j( d5 r( M# V0 t, N) L# m else if (xDir == "left") {; z; Z- N' [0 F$ X$ Y: E
xPos = xPos - BallSpeed;
9 q: Q, o, g6 B! L5 ^ D* t }
1 T/ O# V, K- n9 n' `+ c else {, z8 g( m- Y8 I0 [, }
xPos = xPos;! {! y, b9 K7 @2 L' O
}
0 g1 M- x+ S0 y if (yDir == "down") {) i4 I6 v" w+ e9 F
yPos = yPos + BallSpeed;& r4 a$ c$ [0 q; n
}' h0 I3 u) u( k* ~0 p0 c, j/ w! h
else if (yDir == "up") {& b" N* o7 s& f3 Z; D
yPos = yPos - BallSpeed;
( j* B! [' a4 U8 M& D1 ?- |2 }- H. g }) T7 n1 Y5 b2 h( t* b% L6 [3 R+ F
else {5 l# f2 F9 S6 v) C
yPos = yPos;( Y1 p1 O+ T- ]$ I% l5 q# {
}
6 f3 h* g1 C% _( f* F' z* H& R }
/ N; L" s* J3 W9 N' |$ ~! ^
: Y6 [) k( p; t' d- R( U" I" ifunction hidetext(){
$ l# b# s. }7 g$ h" oif (document.all)
9 ?0 ~! G4 V( m; k( `- Lsupertext.style.visibility="hidden"# j f9 r) W. Y# ?/ k! w
else if (document.layers)! X. H4 J4 M. |3 u1 U J
document.supertext.visibility="hide"* t& |+ b# E. X
clearTimeout(animatetext): [& u) j0 C2 Q A9 B: l' Y, m
}
7 a3 A5 V5 m7 d# m/ O! D
( {$ A9 V" L. r0 L" Rif (document.all||document.layers){
/ R1 A0 Z6 ^0 ~) Q$ rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 E3 V) F8 d2 L/ `: @window.onload = initializeBall;
2 m" ^7 F( t8 D6 Z7 n& twindow.onresize = new Function("window.location.reload()");) f2 j: u2 D* H
}
& J$ O# d3 z* J) g5 x# F! V$ p
! t7 ^ A/ M! Q% C( ?5 ?) q</script> |
|