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

|
网页之不断弹射的文字-特效
<style type="text/css">
8 x( U. L, T' b6 s6 u1 _#supertext {5 F* w& U+ P% v4 q; F- v; t
position:absolute;2 T! E0 c6 n, V6 K% o- [
left:0;9 m9 C: t$ n0 b5 b t
top:0;
& J, ]6 X+ C9 c# Rvisibility:hide;
' W. }9 w+ {" ~0 Y- N: D t5 wvisibility:hidden;
% \8 W4 f' l1 e: i) f9 m) t}$ u( |3 O! f& y- [: F
</style>
/ S# h( a3 c& m% N. I2 I* D<script language="JavaScript1.2">
& g4 b! r+ { x5 G$ t) T& n<!-- 改变下的字体的大小。颜色-->
) _7 [: f) t1 S, ~4 d6 r0 Xvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'- \0 T8 W$ J+ [% o; e; {; @+ ~
var hidetimer='';
6 r1 P# U5 g7 f! }% N: b1 Q0 j/ h2 U<!-- 改变下的弹跳速度-->
. d$ n7 G; H, M2 Q( R" Wvar BallSpeed = 20;
9 Z0 @; z& a* m. ]1 ]var contentWidth;
% \! i1 v1 d# l7 b% uvar contentHeight;
* B, p2 y+ J( m M4 p, g2 O- zvar maxBallSpeed = 50;
: m5 \% L) A. J0 j1 [, ~1 V: ~9 P
3 Q4 S! K4 v1 G" d( x* l: [; b" X" t0 z U2 I* `& c( `( o
var xMax;0 E& t' }, ?& \' G# q: \- B8 w
var yMax;; o& }3 B0 C/ M6 S B
var xPos = 0;1 z; l" ]+ I5 B; z( U( b1 B
var yPos = 0;
6 W! n6 {8 Z/ _$ N2 Vvar xDir = 'right';
% X9 k3 K) O6 _" evar yDir = 'down';2 b8 f2 Y) ^7 z$ r& t; K6 L
var superballRunning = true;
% X8 d) p- U1 A4 b; B+ P" Q/ O. `var tempBallSpeed;
2 J6 r# J7 T7 b- Bvar currentBallSrc;
( |2 B! j, V' {. c3 Jvar newXDir;$ [$ ]& a3 Z& Z* |0 T& \
var newYDir;
6 Z3 X5 R9 x, H' X" g$ r/ V5 t: r! n
function initializeBall() {% p" Z% \* R3 L- M
if (document.all) {: e. M9 s' M& J9 g( A4 s
xMax = document.body.clientWidth
2 d' N+ K( F1 b! I yMax = document.body.clientHeight/ ^& y! N6 z H& D7 O8 w K
document.all("supertext").style.visibility = "visible";
- Y* ]' H# y0 l/ O" { contentWidth=supertext.offsetWidth: ]& R! z7 x9 J
contentHeight=supertext.offsetHeight/ K) u8 E1 j0 _" k5 S, I' ]
}$ N1 g, x" ~$ L. _" A3 v: D; f- H
else if (document.layers) {# P/ V4 P1 G0 N) C
xMax = window.innerWidth;+ y- F5 z/ j+ W1 o
yMax = window.innerHeight;
6 {( |# a' y8 \- X7 @" |9 ~& p& B9 K contentWidth=document.supertext.document.width
7 F6 y [0 d9 p: z2 L3 ]3 V contentHeight=document.supertext.document.height
@1 J1 H0 x& M, N; d& h! f document.layers["supertext"].visibility = "show";6 V# R; H P. G2 d4 Q- g% c! b
}
8 E) w% \# P8 O9 F! r setTimeout('moveBall()',400);
. {7 s/ d. f& | if (hidetimer!='')
7 s( i/ ?+ M2 U. i4 w3 o setTimeout("hidetext()",hidetimer)
8 m9 j( d5 g( e- ` }. C f2 _" W- H, Z/ M8 m# o3 u5 Z
2 T2 f: {3 @$ d, ~4 A" v z
function moveBall() { ^; p/ r7 j6 V3 A
if (superballRunning == true) {
3 L' b! p* O: Q! ` calculatePosition();. E, [' Z- S4 k, t# T0 P# X% T
if (document.all) {
- ?* C- H0 M6 A8 u+ t& { document.all("supertext").style.left = xPos + document.body.scrollLeft;
! Y2 {7 z' f6 f document.all("supertext").style.top = yPos + document.body.scrollTop;+ G6 k, T5 M: S5 {( S. n
}3 N2 j3 M3 p: e
else if (document.layers) { ^5 v8 j$ @/ ?7 z& ?
document.layers["supertext"].left = xPos + pageXOffset;% z8 `7 v' \! R
document.layers["supertext"].top = yPos + pageYOffset;
6 ^9 T0 W" C+ @ }
% i) p( [: t- Z' b! A% U! [ animatetext=setTimeout('moveBall()',20);0 r- T$ e2 y2 k1 K, r$ v
}+ h6 }' I s, J6 C& s
}
% t4 M6 j( f! V" e6 c! `) x7 M* w0 k& b% Z* K
function calculatePosition() {$ U# ^: q+ U" ], H/ f5 U& t
if (xDir == "right") {
7 l9 O3 d4 d4 `1 u if (xPos > (xMax - contentWidth - BallSpeed)) {' P# U" k$ R/ ]$ z5 ]1 p+ Z+ F! R
xDir = "left";
, o) C8 D" s: v' d) j }$ K8 J# H6 P& U# y( S; D. f
}
: f; X) p, t: w else if (xDir == "left") {" i. F+ P8 ` n6 m9 I: D- |
if (xPos < (0 + BallSpeed)) {' r$ i/ q2 Q: \1 l
xDir = "right";3 h; ]- e: u1 G
}
5 T* ^, ~& I/ R }
9 t, a& ^7 p4 z2 \( E if (yDir == "down") {1 P) j% S2 M1 }6 c4 z ^0 X0 R7 o+ `
if (yPos > (yMax - contentHeight - BallSpeed)) {
1 ^0 D2 ]2 y' j& E yDir = "up";5 Z/ `6 a/ f! n, _& Y5 o4 W; J
}% K% T" G7 V$ b9 C5 Z. D% ?- Y% G: S
}! u* }8 k9 |# h; d. e
else if (yDir == "up") {
/ h3 b$ k/ Y" s if (yPos < (0 + BallSpeed)) {
v$ D* Q' @( ~$ y$ e n) w yDir = "down";
, C9 b: \1 e5 L* k+ v9 D }, P M: w9 ~+ Z
}3 E6 ?* t7 O2 c, c& o2 E5 s
if (xDir == "right") {) K/ ?; ]: {# S: m- P
xPos = xPos + BallSpeed;
, O% g9 w4 M- o6 H }. B: s7 o* H- g
else if (xDir == "left") {
8 ]' e6 A0 d) s' s( p% l# X* Q* ] xPos = xPos - BallSpeed;
- {9 @" t% X3 n& `% Z }
: F- A6 X# D4 s else {
6 N- J2 M7 _5 \ xPos = xPos;0 @% a# [# q& p6 B7 M
}
, N/ A- u+ Q4 { x* e9 L$ D. y if (yDir == "down") {
! I" Y7 z+ T5 z1 ?; v# o yPos = yPos + BallSpeed;' j( m% H# `* @/ u* b0 ], q1 ]
}$ }( R2 l8 L$ \/ Y. H
else if (yDir == "up") {4 C" n! \; C1 e9 F" ]; f. L5 N" Q$ U" J
yPos = yPos - BallSpeed;0 O0 J: c" O! \. q1 A5 o- b
}0 t7 d5 V, y+ G3 `
else {
6 T' |2 ~+ e5 \0 |5 z D yPos = yPos;
& }+ p5 i7 T; T# V4 v& p+ | } m: S+ J& U$ E8 u! I Y
}4 X8 \* g- Z0 S; ]& W7 f: v6 x
1 b. i) ~( j& r' Z- v3 Afunction hidetext(){
5 j" w! {& W; b7 ^2 k& t; wif (document.all)8 D2 n2 \2 D- k" h! q8 x. K: f
supertext.style.visibility="hidden"
( }' K7 @9 Q' y% O. o' F' kelse if (document.layers). u( ]9 e4 k2 s* P3 k, B9 V
document.supertext.visibility="hide"' G% L+ J8 h! H8 N
clearTimeout(animatetext)4 i' O9 S% T9 ^
}. I+ |7 I8 X$ Y: D
* i4 m# d9 F/ b
if (document.all||document.layers){
: T6 S- m& ~+ n! n& n# ~! z$ k; ^document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), @' G- I/ E/ D! e& T y
window.onload = initializeBall;4 a5 l i( q* W( U' n0 U+ S
window.onresize = new Function("window.location.reload()");$ ^2 P1 |3 F0 L
}
( @9 e6 l3 z, M: s8 h& U, d
) W1 K* I5 O, H% n3 E( \0 _; m</script> |
|