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

|
网页之不断弹射的文字-特效
<style type="text/css">2 d" M' ]* R$ W2 r( D3 _
#supertext {
' \/ w. B* c8 ^; R$ a) E$ ^' q7 ]* q% wposition:absolute;" s7 S* ?6 @. q; X: q0 J
left:0;8 ^$ I' F- p7 M+ H v5 s
top:0;! N* P7 C8 E/ x# Z l
visibility:hide;1 e& \( q( f. B4 D* ^' g
visibility:hidden;
% v# ^$ Q- ~6 C- y0 p}! R$ H1 d9 x3 a; h, i% Y& W
</style>& {& K, x: {/ I- q
<script language="JavaScript1.2">
# w2 A; i1 \" z6 r<!-- 改变下的字体的大小。颜色-->
* Q) ^7 n( L& O3 A( W7 r* Jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': x' z7 a0 ~& o- P/ Z0 k
var hidetimer='';
7 l) Y0 J8 R1 t<!-- 改变下的弹跳速度-->
/ A" c; ?, z7 P8 b1 C5 R' E+ |var BallSpeed = 20;1 ^: k t: \ v, f! f! q4 f
var contentWidth;! _( b7 |/ y) [) h
var contentHeight;
- t/ A: f- D. R* ^. Dvar maxBallSpeed = 50;
7 L4 I& p0 ]2 i- o- M6 s
4 {7 t! Q- M$ e) }/ {% |0 Y; g7 S, A9 D) H/ \, f( N
var xMax;
0 D6 y- Z' S( v4 Q% j# k/ B* mvar yMax;4 O+ z1 c7 j$ P$ A6 q7 q
var xPos = 0;
U" O7 h$ s8 B( Uvar yPos = 0;! T3 R2 a) o$ k. x4 X7 H$ q
var xDir = 'right';
0 S5 K) }: E0 ~9 e2 r l/ m# Kvar yDir = 'down';
! D2 q; V1 g9 `( Xvar superballRunning = true;: s+ G4 s8 F' r
var tempBallSpeed;, p3 }+ C" K/ y0 X2 g6 s2 W
var currentBallSrc;! \4 M- k3 S4 P# u; O: |" y% T
var newXDir;
5 [- ?! ]' J3 p4 Q$ K1 Xvar newYDir;2 N& j8 x* ~ a. b* c1 z
" P1 Q7 u& R s4 ^5 S
function initializeBall() {1 k! W3 n" |1 z7 N+ l
if (document.all) {
% S/ u, N+ R- ? xMax = document.body.clientWidth2 k7 ^ y0 }+ d
yMax = document.body.clientHeight; p* c* b5 a/ J& y* Z
document.all("supertext").style.visibility = "visible";3 z2 {* i! U( g& `
contentWidth=supertext.offsetWidth- R! s/ r4 J, n. ~* N) [& p8 [4 r
contentHeight=supertext.offsetHeight
/ L$ v9 f. g5 q. [ }
0 O' }3 A, g: v& W" K" u else if (document.layers) {0 p2 j) ~% ?7 x' d
xMax = window.innerWidth;5 u2 e- E Q0 @. U& d! U- s
yMax = window.innerHeight;
* g% S; y5 L P. _" S contentWidth=document.supertext.document.width# _7 v" N" r: b9 i& r* m' z
contentHeight=document.supertext.document.height
: g p, {3 `5 J document.layers["supertext"].visibility = "show";; F9 Y. @1 D( O4 W/ y+ Y, e2 t
}2 J4 [+ w+ i- ^
setTimeout('moveBall()',400);
2 _! ^. V- Z4 ]0 b3 m" _/ B+ g if (hidetimer!='')" ]: u$ r' \/ w, G- F( b% v
setTimeout("hidetext()",hidetimer)) N2 B! U# P. S3 \* I
}1 X' F2 u; m, k
9 o9 _0 {" N4 c8 s# T. P2 V. Q
function moveBall() {
! L% ^- U( p7 g: i if (superballRunning == true) {3 }- O7 y% m) \3 \
calculatePosition();: z3 O+ V# m$ S) A9 q; ]# r% C- w
if (document.all) {
7 L8 v S* C; F- ] document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ N3 {# \4 B1 ~ document.all("supertext").style.top = yPos + document.body.scrollTop;6 S/ z! W$ t! V- _! T' j
}) |& G% _. j: M, T/ z
else if (document.layers) {
" f; F8 v4 d: [ U: H- X& F document.layers["supertext"].left = xPos + pageXOffset;' H2 u+ T. l; P
document.layers["supertext"].top = yPos + pageYOffset;
! V j( M+ Z: B9 c }
, @3 k" E: C& U- k animatetext=setTimeout('moveBall()',20);+ R3 b( J2 k5 b% b& s, V+ D
}
' V& g8 Z' c% c/ z }
5 R- Y) u5 B- U3 U7 T
6 P* w1 ?! K) E/ m" d4 \function calculatePosition() {% O+ G# J2 t, S' l* P5 q0 P
if (xDir == "right") {. F1 b% P' T$ e4 {3 m
if (xPos > (xMax - contentWidth - BallSpeed)) {/ m; ^4 V6 P! I/ J: I
xDir = "left";" s& i A" I z* U
}% u5 |$ V/ S+ @6 k; g, e9 E
}& z" t8 ^" R* t; E* _. m- K
else if (xDir == "left") {% J- E$ W" e" e0 j2 e3 T+ {& s
if (xPos < (0 + BallSpeed)) {1 P Z3 `- n2 o/ \
xDir = "right";3 h; ^0 b1 k9 E, [3 l9 l: c$ J9 c9 V
}$ z. `8 d3 h9 Y. r: \
}; ?5 I: N( b# G
if (yDir == "down") {
+ B9 G5 \1 \! a4 S$ W if (yPos > (yMax - contentHeight - BallSpeed)) {
" m% M! P1 E/ G% [+ W. p yDir = "up";# b- @' H2 s/ S) l
}8 |) j. Y& t. J
}+ J; e" H1 s( e. i# y3 P3 L# ^
else if (yDir == "up") {% A* I; d1 p9 F9 o! i, [* s3 w. T. P
if (yPos < (0 + BallSpeed)) {
0 D! ?6 j; L5 t @ yDir = "down";
9 u% o9 p- F7 v& J. V( W }% P7 K2 e5 ~1 q& I
}
l8 }. ?' _9 Y$ P if (xDir == "right") {& {0 q/ n3 g2 S3 q- h& \0 {6 I
xPos = xPos + BallSpeed;
' t E2 v' Y( z1 m& v }
8 q3 h6 N' P4 o( C" l [- l else if (xDir == "left") {2 O, E4 C+ |! m# F9 ^! k
xPos = xPos - BallSpeed;# r5 `& t i9 T5 w) ]
}
' B0 a5 w( }; o5 J1 C# p else {
3 }. t* }) e4 p/ l8 N# ]" C% D3 O! b xPos = xPos;
8 q! q# N4 G+ |: B5 f }
- N7 G3 K) a Q# G a if (yDir == "down") {
5 k; q7 ^! X- l2 i yPos = yPos + BallSpeed;4 j3 p2 o; R/ q( c7 r k* y
}
( V" q# B2 {0 r8 K else if (yDir == "up") {& K; W9 N. {# \6 e
yPos = yPos - BallSpeed;
8 R( y+ x0 a% k, y }0 v7 f& J* J; y! m
else {
6 g* }, Q8 _, c: j yPos = yPos;
2 ?/ _& P0 Y9 `. l8 X) w* P- h } [; ]" ]0 d9 f' E& Y9 S$ `& g% r
}' Y9 ~0 }% a1 n0 t+ ^7 ^ E
1 I9 r* j* ]) x2 K# Tfunction hidetext(){
5 }- \7 e! g ?if (document.all)
2 o1 d- o8 d9 h1 N4 esupertext.style.visibility="hidden"
6 E2 o4 F+ \/ }/ A8 b4 s4 helse if (document.layers)' U' L! j/ f; W5 l
document.supertext.visibility="hide"
6 I" y+ r3 u; A; @clearTimeout(animatetext)
4 d9 d* e5 N ^ f8 _}' s& b% Y/ v. Y0 } `
& f. L2 ^4 n# I( q6 w' F
if (document.all||document.layers){& c4 G; c9 \# b6 v
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
8 v0 U+ U8 u" a* _9 Zwindow.onload = initializeBall;! U; ?1 ?8 C: L1 q. ?, q$ W. x
window.onresize = new Function("window.location.reload()");
8 N; u* N& ], c% V( L6 c, m8 v}
$ s( w* X; z# M/ j# D& ^/ G# I: T4 W: g- q, e$ Q
</script> |
|