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

|
网页之不断弹射的文字-特效
<style type="text/css">% N: V. [: s6 j
#supertext {! k1 m! J/ |4 W/ c8 q
position:absolute;
* \# b& F! T/ { W1 ?' }0 nleft:0;" R7 ^$ `; t4 e) e% Y
top:0;& l4 p& k: t" O; {
visibility:hide;
2 q, \* |% O1 t5 @6 e) _3 S+ X+ ovisibility:hidden;8 P; Q% |0 l b% m' V6 s5 ~0 A
}
7 T3 s) M' X2 @" M5 X</style>- E# D) L) e8 a, f! P% u0 D' V* a
<script language="JavaScript1.2">5 |( X9 @8 h- A7 p5 O/ m
<!-- 改变下的字体的大小。颜色-->7 X/ M8 k6 B* ~/ A4 J, n! ]
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
9 O% q* ~1 J3 N0 ?8 O% Nvar hidetimer='';
/ J) t% e4 ]$ M* m0 i$ Z<!-- 改变下的弹跳速度-->0 u: i9 u. @: r" J5 W
var BallSpeed = 20;) b/ ?: l8 c3 G ?
var contentWidth;
1 h# k j0 K" U; {var contentHeight;0 m( O8 g" s1 L# t: k
var maxBallSpeed = 50;+ P* Z4 \5 z' R6 Z$ ^
9 S0 A$ w7 S* T5 F
6 m" f: ^( W+ cvar xMax;
4 N( m- O) H$ W9 Vvar yMax;3 v+ T7 ~7 a9 S L# Y2 N
var xPos = 0;; Z) a% _4 ?6 O2 ~' U' J
var yPos = 0;+ h* j2 v1 a; p6 D
var xDir = 'right';
- i: V# a' h2 Lvar yDir = 'down';
9 p( l. }0 A. T6 r* S8 Tvar superballRunning = true;$ O0 c+ ^7 U- \3 _" c
var tempBallSpeed;
7 u' I" ~& q ^; Yvar currentBallSrc;- t( [, G8 Z7 X U
var newXDir;
- C7 E9 c1 f; `) _- Y( ~7 Pvar newYDir;
( [" N, m; Y! ~. [9 n
, A% X: O2 r. Nfunction initializeBall() {
* W% V) D9 R6 c% W% @: G f if (document.all) {. ~3 N2 K( m3 g8 v$ m' X
xMax = document.body.clientWidth
5 T" w- ` a2 t1 v- D6 q yMax = document.body.clientHeight
4 a' Y% T5 Q# a. E; t" L document.all("supertext").style.visibility = "visible";
4 C- |; n* b( `' y& T contentWidth=supertext.offsetWidth1 Z- A- F, f* U; W3 c3 ?
contentHeight=supertext.offsetHeight8 |# v, M. p( w% x0 D. |
}
5 _4 k; f+ h. ^# o/ h* y* |& L else if (document.layers) {
/ b2 M- n& ~4 \. {" p3 v xMax = window.innerWidth;4 W9 a% ~5 ^7 P& K& R8 A$ s
yMax = window.innerHeight;
. B# I3 N$ b N4 a3 _ contentWidth=document.supertext.document.width k- d6 n3 C- }7 p
contentHeight=document.supertext.document.height) J. D. M' y0 h; z ?
document.layers["supertext"].visibility = "show";+ q! E! d, I5 E# r- d5 M+ b' D
}- D- H. I1 g6 T8 b
setTimeout('moveBall()',400);
, N, v6 {- }3 b if (hidetimer!='')
. r6 y C* y. I( a7 Z/ }, b setTimeout("hidetext()",hidetimer). ?- K5 [* N6 W
}- U' z3 p! p& A+ |% _2 _
1 d6 h. m" p2 q" t* k
function moveBall() {
2 Q& F# b& v; u0 M, @ if (superballRunning == true) {
+ O% D: w N! ]/ B5 F calculatePosition();
9 x& R1 ~" A. X }! Z if (document.all) {
; B) ?, g i: [2 H, K: V document.all("supertext").style.left = xPos + document.body.scrollLeft;/ M' C6 H! a# g1 ]& N( A' W$ E
document.all("supertext").style.top = yPos + document.body.scrollTop;* @* s3 ~- Z# Q* o/ u5 Z/ F" L7 w
}
. a+ b; K* Q; z: \9 ^ else if (document.layers) {5 l5 a. F- `2 @. i
document.layers["supertext"].left = xPos + pageXOffset;
$ I. r4 B l" ~3 E. G document.layers["supertext"].top = yPos + pageYOffset;
+ } t- q5 b$ @- T6 ?: O) N& T }
: J# E5 `: @+ x7 `$ d animatetext=setTimeout('moveBall()',20);
! y0 a6 z* Z' F }
: i( I! @, n4 r. X }; e. x# o' e9 q9 W
7 x& u' M5 I, U5 X7 [8 M! q
function calculatePosition() {. s2 s6 V9 i( z7 N% r) j
if (xDir == "right") {
" @, T$ n4 {2 M% w if (xPos > (xMax - contentWidth - BallSpeed)) {
8 W1 L" N* c u( ^! Y! u/ W1 u! ? xDir = "left";
8 k0 w" D3 b" B0 n6 Z }! B6 u# S" D% U* ~0 ^
}7 ], D3 l/ S" i$ M2 S( k6 }* ^
else if (xDir == "left") {) b7 `: B1 i% Q) F" w
if (xPos < (0 + BallSpeed)) {
! s& m9 ?2 U! l# j xDir = "right";
$ ~* O% T \& d" q$ | A* |9 r }
8 a# G) X; J3 E4 |( ^ }
# y& S5 b9 V* {: v* `% D if (yDir == "down") {3 P! P, v/ u& Q2 k4 `
if (yPos > (yMax - contentHeight - BallSpeed)) {
7 E& k% j8 `* m& Z) u4 @ yDir = "up";* g6 p1 a* s2 i: J) O) u Z
}
" w% [1 Q" K) h# m }) c) ?) Z. n, a1 `1 K* X
else if (yDir == "up") {
1 x: {/ g- E' K if (yPos < (0 + BallSpeed)) {
$ [3 Q, |8 X e- C yDir = "down";& N5 G% D" T/ i$ s! I
}
( G, C! Y6 k: Y2 W" C8 o$ J; b' a }
6 c! h9 L/ H- Y% V6 j if (xDir == "right") {3 O6 R; U& l+ }
xPos = xPos + BallSpeed;, ?/ l! W* L8 s
}
|$ l; y A" s6 p$ h else if (xDir == "left") {
1 M" b: e# S* s- C) Y5 P; R xPos = xPos - BallSpeed;
" D s. x1 R7 s3 F9 W }
0 w+ T6 P: T- q! b5 m' h2 ]3 E else {+ d, k, j- C4 P- T Z
xPos = xPos;4 y( H7 B- ?( c5 _# z+ p
}
0 ?# c6 F/ L5 i- m' R& i if (yDir == "down") {
4 E! G3 V% S/ g+ p6 | yPos = yPos + BallSpeed;
: S- L- k3 m( b% w v }9 \. I+ r' C4 z _/ ?+ ^0 \
else if (yDir == "up") {
4 Q5 e6 p' G9 h. L4 N; L: K& g2 X yPos = yPos - BallSpeed;
) A6 _# q2 `( O! J; ~ }* V- e( K; Q4 t f$ I8 X6 @( i T$ w
else {
0 s" p" c- v. }& P# j yPos = yPos;; X: D; f, D7 }/ `3 u( X, h
}: t6 z7 k8 f0 w5 O( p/ Y+ N
} L% s/ c, Q8 j" R
a0 }" \1 e$ x8 [, mfunction hidetext(){9 S3 ~# @' U) X* D8 P) V1 I! N
if (document.all)
, `& D4 h, ]7 e1 s, z6 csupertext.style.visibility="hidden"% { `& [" K9 ^, D' t: W
else if (document.layers) G" S* E4 h9 j @7 n _
document.supertext.visibility="hide"
& [! N) x$ p- c k/ N( ?clearTimeout(animatetext)
$ a7 T: W. e R$ r}
: V( G3 y* |$ b& \; w& ^, u! @3 ^
8 |. F; ~3 k& q4 {if (document.all||document.layers){, u' }% i; b6 J) A
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')5 f X1 \9 H1 ~2 Y) \7 Z& y: V
window.onload = initializeBall;
- [3 I i0 p3 V7 q. P+ Z$ S! Dwindow.onresize = new Function("window.location.reload()");; Z1 v( k+ j O+ V: I! m$ F
}
3 K8 W- t9 g# w
+ @3 }* P& A, o* b9 g</script> |
|