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

|
网页之不断弹射的文字-特效
<style type="text/css">
) j6 i" T7 S0 o$ {#supertext {
9 P8 Q+ {( ]( X" O: ^position:absolute;& C% O8 E- Y6 a# Y1 Y9 D) U
left:0;/ G0 K4 I0 |- n) T
top:0;' Z; h9 {' I; b
visibility:hide;, m( T& t( }5 [( K$ N, j
visibility:hidden;
* c0 G: i* V% n8 o8 _}/ Q9 |# v- i' D8 i) y% c. `
</style>
# A8 j: \* t% |, G( O5 X; f<script language="JavaScript1.2">1 f0 S2 t) o- u1 ~6 q/ g
<!-- 改变下的字体的大小。颜色-->9 ~8 k( {- _! k) A5 Y* E) K( `
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
; j" W7 ?) r$ A* l' t6 l9 yvar hidetimer='';6 N2 a8 F* c d
<!-- 改变下的弹跳速度-->! V4 J2 K$ h7 o( `8 ^! i K; i! N# \
var BallSpeed = 20;
, k' U! F* h9 O) rvar contentWidth;) _9 W! c# v; P3 p% R
var contentHeight;, }% v" f4 D: O) s1 H4 ?
var maxBallSpeed = 50;
4 m* ]( W( w* Z# c+ n) C) R7 \" t# `0 D0 I. B' c
( a+ v% r* p2 T' B5 I6 A
var xMax;
3 U4 t/ }8 X% L1 P# C3 B( jvar yMax;6 _4 b, e" a' o
var xPos = 0;$ ~- K% O& ^5 F. G# [0 ?# N0 Q
var yPos = 0;
/ Q) E; a! h- a3 l) ovar xDir = 'right';
" E) L4 z, H: ^. Nvar yDir = 'down';
- w2 B" W; I7 X# Y! ovar superballRunning = true;0 x2 m3 a* m3 f8 D8 {
var tempBallSpeed;6 X3 c/ a' o+ ?! W5 \, }7 R
var currentBallSrc;
F. u9 w! N0 m9 Q" Hvar newXDir;
0 k( e0 ^9 f. ivar newYDir;
/ u; O# W% F+ V6 M0 u9 Y' N p! k2 e' X
function initializeBall() {
" G" e+ t2 J$ K4 ~. |7 A* c' Z if (document.all) {3 I E5 v4 G' ~0 T5 z" S
xMax = document.body.clientWidth
& ]+ R+ Z l. C, x( z yMax = document.body.clientHeight6 g% d, b# d! D5 d, q
document.all("supertext").style.visibility = "visible";
- ?* p7 T! H9 W, l7 B+ _) q contentWidth=supertext.offsetWidth
2 n# q1 P: n2 A9 c) { contentHeight=supertext.offsetHeight5 @; a' f4 k. W$ R0 w1 @
}- I& [8 R# g1 h1 j& V
else if (document.layers) {
y% j1 x6 w/ f1 L3 C# a W5 p) E5 E" Y xMax = window.innerWidth;# ^6 C( r4 p M7 T
yMax = window.innerHeight;, t; p+ N% E# m
contentWidth=document.supertext.document.width
- ~4 y$ p& s5 Y7 U9 | contentHeight=document.supertext.document.height
- U% G" q; m8 ~# k6 @ document.layers["supertext"].visibility = "show";
5 ?* b4 a' b! \$ ] }
4 F* R, d3 q1 H* j5 m" L) e l6 D setTimeout('moveBall()',400);& t$ W; q" b# F+ `+ V
if (hidetimer!='')/ \8 K6 r: g* p o
setTimeout("hidetext()",hidetimer)
6 X& `( i u, g, r4 O6 V* u" h }5 E, K1 Y+ m" _+ p" L7 D
7 B7 ~8 W" O" ^* w% T2 j9 q
function moveBall() {
5 F' t8 x$ F% [" s if (superballRunning == true) {
, \+ F( x3 h) ^9 m calculatePosition();
3 y: T! R8 A0 y! R w if (document.all) {
' W. H* f9 B8 G document.all("supertext").style.left = xPos + document.body.scrollLeft;$ _# h& e/ k: ^
document.all("supertext").style.top = yPos + document.body.scrollTop;1 K- ~ V* d$ i1 T. ]
}
$ h/ H4 I& X% Q, H* X: d: r else if (document.layers) {
9 O* z* b5 [% e/ D- }; j7 _. H5 n document.layers["supertext"].left = xPos + pageXOffset;9 t1 y- u1 A- b, O* _
document.layers["supertext"].top = yPos + pageYOffset;
! D6 o+ o, K6 H }
$ Z8 H! G% h8 j0 _+ L animatetext=setTimeout('moveBall()',20);
5 F; t! t- \* W% ?8 F }
9 _9 c! ?& r& d# a. l7 L3 s }% i% j. N4 Q' E, W
0 K r% s' B2 ^" n2 V) u5 d
function calculatePosition() {
6 p0 G. v1 O }; | if (xDir == "right") {
( G! Q* d; | ^) F6 x7 L( s5 W/ W if (xPos > (xMax - contentWidth - BallSpeed)) {
3 Z: S! D& d3 a. H5 l: ]2 K0 c; ?1 s xDir = "left";& m$ `, B' H# N6 s' c0 _, R
}9 R- n1 O5 V8 V7 P' G4 r H
}# l/ v8 s7 W) j& |9 X9 J5 t) N, T
else if (xDir == "left") {
0 m) b8 k. ~( n7 Z" `, {/ Q if (xPos < (0 + BallSpeed)) {
- d/ A. `' e" v8 w4 X' d xDir = "right";
1 @. f1 U, U! ? }5 S5 ?* H& l- O1 ~3 F
} `8 ?+ @) B! M0 `4 U' `: a4 C
if (yDir == "down") {
, B2 f0 C; x; c4 l6 V if (yPos > (yMax - contentHeight - BallSpeed)) {- T; g% z& z2 x4 }9 ~. @ S
yDir = "up";' v( G) J6 N6 n0 K, K
}
6 X( c) X/ x$ k. O9 P. e0 i& [ }* N4 L' G" j0 y+ f+ {6 m
else if (yDir == "up") {
4 {/ }' \9 O8 o3 R+ |. B if (yPos < (0 + BallSpeed)) {
5 c0 s6 U1 X3 ]7 h yDir = "down";
! j9 s D/ m6 A2 r; J2 `7 Y: ~ }& E& H$ U$ E- x
}
1 _$ Y3 o9 d: R3 |/ f7 I' Z9 ? if (xDir == "right") {5 B6 e3 D% K. w+ {
xPos = xPos + BallSpeed;% s3 Q$ `3 {! A P" N
}
- r) Q& I0 @0 j2 R* F9 ^ else if (xDir == "left") {
( B, f! e: m+ W) s% l% A3 u xPos = xPos - BallSpeed;' l! R/ k* }8 E, h* O$ L5 X$ p
}. }' F) ^; e( F0 t" }8 e
else {* t0 P8 E7 m) q! ~# i- w
xPos = xPos;3 b3 u6 i1 p9 O
}
8 J" k! p; P# J; j; C+ L+ X' n if (yDir == "down") {; O T1 ~6 g9 |. u+ s ]% J5 G6 X
yPos = yPos + BallSpeed;
$ M3 m# f7 A2 ^7 h6 n8 o0 f }% x8 q' j, e" o) G) s g) n! `
else if (yDir == "up") {' {! @( H) {- T }, V# m0 j
yPos = yPos - BallSpeed;
" v( {# V% M, {! ~4 U; w }
3 |" g Z. O* i `) f! [ else {
% G3 g5 }- s$ i$ ^ yPos = yPos;3 [4 h$ k8 B6 a# H
}
; Z) e6 L# C5 i( Y }4 _4 \* N! O- D- H2 T9 ?
+ Z5 ]( @8 z- q
function hidetext(){, Y9 _! e% h; ^# Q4 P6 i: w. [2 y
if (document.all)
7 } h* v: O2 \2 z- V# M* esupertext.style.visibility="hidden"& Y- K) T9 [& n$ y
else if (document.layers)
9 ] h3 A1 X( q2 {document.supertext.visibility="hide"4 V4 h8 k5 \& \% w
clearTimeout(animatetext)
7 B2 t0 c6 n X, U/ Z. O6 Z l' L/ t}: D- C/ \( f# ~* X4 y1 A
1 N z/ l; g( eif (document.all||document.layers){+ i' V9 W4 d p. z
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')* |1 l4 u: T u. h5 d! e# i$ a: X5 F
window.onload = initializeBall;
5 x8 T F% n) \# X1 I4 c" mwindow.onresize = new Function("window.location.reload()");7 H# T4 I% v1 Q$ R) z# w: M
}
8 ], W/ k2 Z/ L0 a5 S* E4 p$ h9 c+ R6 [
</script> |
|