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

|
网页之不断弹射的文字-特效
<style type="text/css">
! `3 ]* \( t4 N' E# ~: H, f! v#supertext {* t( Y) Z+ V/ [+ i" p2 J3 {: l; E
position:absolute;
$ _, b$ |. [8 }left:0; c/ h# J; w6 Q/ y
top:0;7 J4 v: J2 `. s) g7 l ~* j
visibility:hide;
: c# Y* v9 i1 ?- gvisibility:hidden;
( p. R% S3 q. w} C( g3 m- b" d8 Q$ q9 }) i0 S
</style>' m% k4 U# q' R% K4 u
<script language="JavaScript1.2">0 f# I" Q1 F# z2 Z4 i
<!-- 改变下的字体的大小。颜色-->
% v/ x$ s3 ]8 u+ i& [. x$ z/ svar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 P4 s2 T- f( ~8 P3 F- y9 jvar hidetimer='';
: B* [9 G/ {' U9 J5 A7 K7 b<!-- 改变下的弹跳速度-->+ [& F K t, A! q+ [, r2 i K
var BallSpeed = 20;& S$ S% \ r- R0 B
var contentWidth;- ~. O$ L: ~# l* J3 w( z
var contentHeight;
+ O6 |( u( i2 m4 [* F& tvar maxBallSpeed = 50;
2 f2 p/ g1 b; N% j3 J2 {/ \
6 w) ^. L$ ^) G- z
) j9 A" Q7 w$ Pvar xMax;. m# Q7 P; a" J3 F" n
var yMax;
, X. ` W5 R( k/ V. @var xPos = 0;; k n) o) T ^2 x' ?
var yPos = 0;$ r# G% @8 s7 l. X/ y
var xDir = 'right';
" f. i! f( u: e* {, K/ Gvar yDir = 'down';/ F4 L, X C' Y* u
var superballRunning = true;
' {* J& g) T: j7 F4 R( g. j. u1 z4 p$ ~! ^/ _var tempBallSpeed;
) B3 c% b4 ?) Qvar currentBallSrc;- t8 k4 N9 [- a. Z* A5 j- A3 F
var newXDir;
7 x, K/ z6 k/ e) _0 ^var newYDir;
0 U7 f1 q0 t" S+ A
* s% M5 K. N& `- }3 E( R8 Pfunction initializeBall() {
( r8 a% w3 {* k2 p8 _ if (document.all) {6 ]3 L; l. d, }
xMax = document.body.clientWidth
6 f* J, h% J, p1 o8 k4 |# Q! x yMax = document.body.clientHeight5 N" h, B d, U
document.all("supertext").style.visibility = "visible";
+ U! ^+ |; m7 j( f2 \1 o; J: z5 w9 F contentWidth=supertext.offsetWidth
" n& i" t: K d0 t9 W# M& ` contentHeight=supertext.offsetHeight: T: C* D8 r% E- I) _( `. f
}/ l, C/ M- o. a/ A+ I9 @
else if (document.layers) {
2 ~ e( {, t+ f5 x4 |& V xMax = window.innerWidth;
/ R, b8 b- P$ G5 _, \" l yMax = window.innerHeight;
# ?5 f; U, C* d$ W9 X$ v' B* `" w2 n contentWidth=document.supertext.document.width0 a5 m s$ u* I: a6 `# R+ q% A
contentHeight=document.supertext.document.height: ?0 n* T u6 ]: {
document.layers["supertext"].visibility = "show";
& _9 l# u; ~8 c% _ }: s% P, R5 ~, I8 C
setTimeout('moveBall()',400);+ }7 W. ?5 }* Y) |6 q& v) `
if (hidetimer!='')8 V+ R+ f' e* r
setTimeout("hidetext()",hidetimer)
$ `3 t% |2 {5 d3 j }& y1 U, f+ Y# c/ [' w1 b
2 n* X& F. Z& V/ r$ E: I6 I
function moveBall() {
8 @ G$ T7 d5 F! h6 a8 ] if (superballRunning == true) {8 N$ m/ S2 U( P: t9 t: j
calculatePosition();# P, N1 A5 Z: s f; G8 ]' e! _
if (document.all) {
+ ]( d. d2 f0 E document.all("supertext").style.left = xPos + document.body.scrollLeft;% _7 l! r6 h; p- M4 F U, j7 J. `; B
document.all("supertext").style.top = yPos + document.body.scrollTop;/ |# U* ?$ y# K) I; A! u
}0 B" @; Q: e" i/ ^
else if (document.layers) {
' G. ]" H: }' o8 j: u4 ] document.layers["supertext"].left = xPos + pageXOffset;
+ z- l: `" n9 d) {: J: i; U2 I document.layers["supertext"].top = yPos + pageYOffset;
: P* Q3 Z# V' X7 |) k4 y8 B }% d5 D6 B4 `. o. O( O8 s& A
animatetext=setTimeout('moveBall()',20);
; J9 \5 o, @5 l( P; A% Q. ? }
* C- c/ R. d4 u( l }" C1 N+ {( t, o1 @
" s5 r9 f* x: w/ i
function calculatePosition() {, }+ ]7 B/ @# B% C) r: a7 [
if (xDir == "right") {
* ~# ` K- K6 m if (xPos > (xMax - contentWidth - BallSpeed)) {
4 s: |* S* V4 \% Y& e& K' T3 B$ y xDir = "left";
2 q/ K7 X" H* ~# `- V V) _ }
. g1 u H8 S4 a }4 ~" \" ]5 [7 Y1 _2 E1 g# ~
else if (xDir == "left") {
% `+ [7 W1 }2 i. Q0 l+ B$ v/ y if (xPos < (0 + BallSpeed)) {! ]: ^) ?3 `$ S
xDir = "right";/ [3 ~5 [) X9 H& Z) j& V7 z
}
H9 Q9 b: Q) j; b |) Y( }) v( z }
- t& f5 ~* g+ I: s6 {% s5 ?$ t& H if (yDir == "down") {
9 i! n! A: r- I" C if (yPos > (yMax - contentHeight - BallSpeed)) {( P$ [+ X* P5 Z9 k; F
yDir = "up";/ B4 E7 X. Y6 g* w- H; q
}
( S8 [( b& Z- l- P5 @$ O( v }! A; E: k+ y" e8 @$ W
else if (yDir == "up") {% t* @, X5 x1 d3 c1 I3 j1 @
if (yPos < (0 + BallSpeed)) {
/ p8 p6 T/ @5 j) k b yDir = "down";3 {- V( p. }5 b( h/ \
}8 M' P; d' A P2 l* \
}4 c) R. w# K. q, R7 L
if (xDir == "right") {1 |" u& W0 U, m* M
xPos = xPos + BallSpeed;
) K. u( q& ^1 j" o }
- v4 L6 a! o7 D+ v: x else if (xDir == "left") {) @+ y" F9 m# s' q% @! A
xPos = xPos - BallSpeed;' h( L! x Q3 ]" q* D& A( i
}
6 X9 h, F/ Y5 k else {
4 \- F3 l- X) ^8 L* Y xPos = xPos;
( P& Z" q/ C- G4 J5 W1 ^& g }
0 R& o" ~, v5 q$ I% V if (yDir == "down") {
3 L: ^1 z% [" x3 | yPos = yPos + BallSpeed;- Y) |" L7 t8 r3 \5 O
}! o' C: u- @) R5 I! V7 S3 p
else if (yDir == "up") {
& V4 n! z f6 s6 U0 G% `, A, G; u yPos = yPos - BallSpeed;5 P+ r) I0 D3 B0 Q4 }6 T2 z
}- {& J- p! d& K) e' e
else {3 z( X% X& L9 r( x3 |* o
yPos = yPos;
# b, F" E8 Y d# k }1 N9 f: P N; J! [" I* n
}8 Y* p9 N. y3 v' ?0 _# y
. E! L. C8 _/ U* |- A
function hidetext(){( B5 { n- D7 W; |- S
if (document.all)- _% D r/ T" S9 ^6 G3 d: U
supertext.style.visibility="hidden". Z' G% T: L4 i; Z5 h' m* W
else if (document.layers)" U* W3 A G( n, L7 Y+ n$ ?7 k" z
document.supertext.visibility="hide"
: s$ D4 x& D t: L( FclearTimeout(animatetext)
/ ~ C% G J ?! }9 C}5 c* `6 Y0 s7 ^$ }+ k8 Z
% |# S! _" v$ T5 \& a+ h) f0 Bif (document.all||document.layers){
) X8 f% A+ [+ C0 {1 l! adocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 y; G/ ~4 F! b) E1 H, N
window.onload = initializeBall;9 R. s1 i- P% h
window.onresize = new Function("window.location.reload()");7 _ D4 y! w& d3 h% { Y9 M9 s
}
$ ?5 {. y5 Y+ w3 W h. |+ r, i2 h* Z b& H- ~4 ?, b
</script> |
|