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

|
网页之不断弹射的文字-特效
<style type="text/css">$ P2 G0 S* q" H: O. W
#supertext {
: h3 |1 C) X, ^0 A0 d% Oposition:absolute;
' `( ~+ w' Z: \left:0;
9 y2 K- ]0 z3 _4 r1 O8 J. A: {top:0;
8 h9 R5 }* |* r1 }visibility:hide;
* n P& k2 f3 o' R9 p5 {visibility:hidden;* k- S% \* K. t1 A# X0 \0 ~
}
, W- w: x7 `) u: Q</style>0 b1 V7 T) e( z$ ]
<script language="JavaScript1.2">7 a& p0 \+ ^! C) Y/ t4 T
<!-- 改变下的字体的大小。颜色-->) m8 b% S+ V/ V6 I6 c
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) ]1 e5 R; m( y1 F! p. Jvar hidetimer='';
* U4 r; g2 w/ ?! e( a<!-- 改变下的弹跳速度-->/ c2 ~* Q% }/ t0 g- g4 V& R9 P
var BallSpeed = 20;
/ Q- [, s2 M8 N9 H% jvar contentWidth;% R) L" G4 T$ f) \4 y
var contentHeight;* E# f* @, z ]. T
var maxBallSpeed = 50;# Q0 ]6 p4 |' U9 `! j. D7 n2 z' A
1 v# i& p9 N) P# U' _1 V, B% E/ X& F5 d
var xMax;& w5 a7 g- Y0 @6 @- N# `
var yMax;
+ d& U; Z1 o$ N9 v9 K! ]+ D/ e! `var xPos = 0;
E/ H$ ?- [- u$ svar yPos = 0;
6 X' ~2 T6 t K" [0 }) S+ Pvar xDir = 'right';
4 s; M* X# \$ V! Q9 Gvar yDir = 'down';
& S! p# z! r' q8 @0 _var superballRunning = true;" |" w }+ |0 t9 r4 o2 ~# N1 c
var tempBallSpeed;1 ]9 G P, q" a+ C, [7 ^
var currentBallSrc;
2 F1 a1 {/ y) P( o( |1 c& Hvar newXDir;
4 B1 I: j$ `* r7 }; ^1 ?3 {" _var newYDir;# X- r: q+ |4 n/ \* P
* d5 J( o' M+ {% O F* V
function initializeBall() {
2 I! V, e% C8 _1 g' S. o7 j% Y if (document.all) {+ D' J3 P& m* M' {! z5 P6 a
xMax = document.body.clientWidth
: ]- e! a2 D& P; }# k6 w/ H" k yMax = document.body.clientHeight/ B3 Z, s0 ~. K
document.all("supertext").style.visibility = "visible";
% h; W) w2 {. I6 T contentWidth=supertext.offsetWidth) ]% O3 ~ U4 l: L4 X, X
contentHeight=supertext.offsetHeight% }, z& u2 ]) Q( i3 g; y! ?& Z0 P
}, `: N# v! ]4 `& O( z0 K( i1 v
else if (document.layers) {
( V v- d- Z! J6 Z } xMax = window.innerWidth;5 F, w. I" _" S/ M$ J1 i, b
yMax = window.innerHeight;
- H* v9 @6 t; n9 N9 s contentWidth=document.supertext.document.width7 }2 n, a/ F% ]
contentHeight=document.supertext.document.height6 o* {9 u* t# V! H3 X
document.layers["supertext"].visibility = "show";' R4 s3 V8 z# o, M1 V
}$ k7 g4 J. Q# ?) X4 x1 @8 r2 O
setTimeout('moveBall()',400);* g! p; ^& y# k# Z5 a
if (hidetimer!='')! p2 C; |( E L
setTimeout("hidetext()",hidetimer)
. P# y1 n7 O' G- W: B( f }" v0 j9 t/ ?# P4 p' ~
! _+ \1 @! n9 z) U5 Lfunction moveBall() {
8 f. _. H$ N3 U* i if (superballRunning == true) {0 L8 P% g2 P- |4 W
calculatePosition();& g @* M" ] Y2 v, d
if (document.all) {: {- u y) R* ^+ q, f2 M: K
document.all("supertext").style.left = xPos + document.body.scrollLeft;
9 B4 f. S- p% i( d# x document.all("supertext").style.top = yPos + document.body.scrollTop;2 A- H' I. r1 T3 k
}. ~5 n l; q1 z# c2 {
else if (document.layers) {, K6 P5 F5 j8 n: A' K7 n
document.layers["supertext"].left = xPos + pageXOffset;
5 P$ A. w9 c0 |# y* n document.layers["supertext"].top = yPos + pageYOffset;
3 g/ y; }$ _, y$ y* I }
: C/ j' D8 p# v( A" R ] animatetext=setTimeout('moveBall()',20);. l( V+ y- H' p0 k4 j1 N7 a6 f
}
9 R) S/ f/ x0 p6 o9 N% ~$ M }
( ? O& b3 G" h+ K
6 Y4 U" m" U: H; s. {5 I4 Wfunction calculatePosition() {
) _4 V# V" m/ P1 i Z+ } if (xDir == "right") {. [3 W( q( X* ]9 h
if (xPos > (xMax - contentWidth - BallSpeed)) {7 F: I" T' \3 D& O. c3 C' z
xDir = "left";
& T' T- E$ Y, g0 g( { }
7 c B G4 a. j. ?* d0 w }6 e( s: I- A9 g! M+ ~4 k
else if (xDir == "left") {. R4 J% ~: U0 D! m: I
if (xPos < (0 + BallSpeed)) {# X* y3 ?3 T$ Q- u% E
xDir = "right";
1 L5 ?+ V1 k4 k$ ]3 d# \ }" x1 z" R% @8 p
}8 W# x) U* y! u; |1 t7 M1 ^
if (yDir == "down") {+ ^; ?( v+ q. A( Q, g b1 P
if (yPos > (yMax - contentHeight - BallSpeed)) {0 D. I. ]9 }- U
yDir = "up";
+ ~( p; f8 k: b, S6 t' a. T+ L }
9 J" V# W0 }4 q" ~, k }
+ D) o! I6 B) P o( P- y else if (yDir == "up") {! t" l* E3 L% \1 q# {: E7 s' f
if (yPos < (0 + BallSpeed)) {# G- U! N; J- F3 W; ^% ^
yDir = "down";/ Y6 Y+ e. d* r3 I/ x
}# {# \; o7 U& C; T4 F3 S- {
}
s9 p# f4 i1 m if (xDir == "right") {
4 i8 O5 J; b$ v x xPos = xPos + BallSpeed;9 F# M1 g, L* D# _ e: \& t& f/ z
}
: V/ t+ M' w" O* a: | else if (xDir == "left") {
3 |6 Y7 K5 |4 A3 J0 d o, T! O8 I; d xPos = xPos - BallSpeed;
- ]1 i' B9 d0 `8 Q0 `# O4 u6 { }
8 \) H# r( { ^# x$ C$ Q% \ else {2 W n7 ^5 A2 G1 M( ~' ~
xPos = xPos;
; W0 w4 O2 u( Y$ H% J8 ~4 L/ X }
! y* A; S8 F/ L ]7 u8 v9 G1 q& C if (yDir == "down") {
3 X* ]+ r5 q+ G6 ?9 p& D6 M yPos = yPos + BallSpeed;6 x% a; \! | @+ y+ `! @
}
" E, D5 M6 O! D/ N _, |* Z1 Q else if (yDir == "up") {4 Z: D2 ^% ^! I7 K" I# R( v8 w
yPos = yPos - BallSpeed;8 j( Q6 p- J6 ?0 b; K% ?
}, I$ m+ H4 \/ d2 ~$ a( k
else {
3 b1 F* ^% t' @+ @, h# R yPos = yPos;
- U r5 ~) f7 q a1 r+ m* @' Y }
: [; n" W5 ^9 ~: m$ n" ~+ x }' I- N' {1 E+ H! f8 L, y- Y# V
7 ]9 D& N B6 ]/ z0 ~; {* Z+ Xfunction hidetext(){
5 x& m6 o5 q% Q/ w: e9 Fif (document.all)1 p$ ?; ^; n4 ^/ N
supertext.style.visibility="hidden"
& a% z: ^( H! `+ e, O7 }" ^else if (document.layers)
( m- y7 o& e3 |' O1 Bdocument.supertext.visibility="hide"% L4 C% C( h' Q4 _8 v* ^
clearTimeout(animatetext)2 a! z0 [% l7 J6 E
}7 f; O0 ^7 c7 k7 n" v
- O# q& n$ L( ]% ^( i6 @if (document.all||document.layers){
4 v0 T6 h) @* T; mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), M3 L2 f! `$ c" E
window.onload = initializeBall;
5 x; ^/ |' |' B/ w' C# Wwindow.onresize = new Function("window.location.reload()");
- l. d/ l7 z. N& K3 k8 N}
/ _4 g2 K- x. I) l# P" u. W, `$ }, s( n4 @/ S* i* w4 a& O
</script> |
|