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

|
网页之不断弹射的文字-特效
<style type="text/css">
8 c4 f8 E) u9 u( P( D4 `4 z#supertext {4 A: w& W" M% C. ~
position:absolute; C. a" j$ _; T
left:0;
5 B/ \, I K2 Q( i, X# Qtop:0;
) w# W% L2 n0 b! n4 [$ o C1 \visibility:hide;
9 F. a8 K. {8 U r$ z' Q5 Wvisibility:hidden;
% z* U- w) |# K( `! E! ]9 N}
8 Y3 k+ b, r6 V) L n6 w( u</style>5 ?$ J. W" C, T+ D: f4 X3 {
<script language="JavaScript1.2">4 p& w2 W5 i7 |4 G# k) P
<!-- 改变下的字体的大小。颜色-->: ?% A) J' b7 |+ I3 e% t
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
; U) c" \9 G0 l4 C9 R$ ~var hidetimer='';- K! d+ f0 i, w9 D! i
<!-- 改变下的弹跳速度-->1 {. I7 F5 _& A- y( g$ F
var BallSpeed = 20;
+ I4 q) i8 W8 h7 Qvar contentWidth;
6 g: @1 x. u. u$ l" ?6 cvar contentHeight;
( S) q1 n6 v/ a( ?; k! |1 Ivar maxBallSpeed = 50;4 Q+ ?9 a" o) V
" q1 C# e! D. S% W
" J S+ _# p3 L! Pvar xMax;
0 W! \6 x5 i8 cvar yMax;
' c2 a+ }" D& B4 `/ v! h1 c: gvar xPos = 0;+ R( i6 J" p! m3 t4 ~
var yPos = 0;4 d" ^! Z0 D1 T S, ^+ c1 s
var xDir = 'right';" A6 h, z( j' l+ g- Z
var yDir = 'down';% Z% r" K* ?% |1 {6 G
var superballRunning = true;
4 d! c8 H/ r `/ B% avar tempBallSpeed;" c, Y: D1 l5 e
var currentBallSrc;- g& E' [9 b0 p6 u0 A
var newXDir;
$ }' K6 F M$ r: T3 P M: x9 qvar newYDir;& U& m6 N9 m( s5 P9 S
0 u3 X2 J1 |! Sfunction initializeBall() {; g* E# o8 X2 F+ |5 }' Q' G
if (document.all) {. M8 g2 d( z, j I( g5 O, e) i
xMax = document.body.clientWidth
( ?; T) J1 l& u. I' B1 [ yMax = document.body.clientHeight, O- o2 h- N. w, _! T7 f
document.all("supertext").style.visibility = "visible";
8 U5 S+ J3 v2 k$ ` contentWidth=supertext.offsetWidth
1 N8 h+ p7 h6 ~! L3 R: {1 W3 X contentHeight=supertext.offsetHeight- x3 x4 }( L l( ^& L
}1 F' ?( ?/ W; _* y! R
else if (document.layers) {
/ I. W: |( r, B( K) D) g+ [ xMax = window.innerWidth;" a6 f" {# e7 V `0 J( @ L
yMax = window.innerHeight;
: }( p7 g4 E! c contentWidth=document.supertext.document.width
1 v8 ^4 \6 P' { contentHeight=document.supertext.document.height; A, c" V t7 |2 ?1 c- u
document.layers["supertext"].visibility = "show";! ~4 `* M- K( z( O+ Y( t9 t
}
8 i/ V2 V$ X0 x setTimeout('moveBall()',400);! O6 _7 }5 v+ G/ W; N- n$ j& ~: g
if (hidetimer!='')
* s/ b% p; Q0 I( ~# j" v, {( o) Q( R setTimeout("hidetext()",hidetimer)
4 y( v7 l5 e4 T6 c }
! e) h! ?' B4 ^3 I, ?5 D
8 Y2 }6 c2 w: q! [ a7 ~; Rfunction moveBall() {
+ X( _8 m1 V: x# S9 b* y if (superballRunning == true) {
, j& P/ G( r4 D" Y" \0 O calculatePosition();
: C1 ?& v0 @3 |3 k if (document.all) {# F+ X3 ~# M9 w8 {2 r6 Z( ~
document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ E0 Y! S9 A1 t+ ~5 y# q document.all("supertext").style.top = yPos + document.body.scrollTop;
9 b4 w" _6 q$ I7 Q' s }: h6 |) B8 U. N( |
else if (document.layers) {
y0 |0 ]* ~7 D; b Q5 ?7 A6 i document.layers["supertext"].left = xPos + pageXOffset;
( W, ?/ d8 X, A0 p+ q k8 ~: l document.layers["supertext"].top = yPos + pageYOffset;; G+ Q$ A4 g- \
}, H: L$ z( f5 _5 x: q
animatetext=setTimeout('moveBall()',20);
- [# w- u8 u T0 Q! \, J }& b; ]6 K% f) R3 J. U
}1 ~ C7 r, s) H) G% W D
; n* F- f- K0 X- w; k1 \function calculatePosition() {
1 L& I" C9 a+ R* ^, V1 [8 D' P) E if (xDir == "right") {
* G, P7 |0 q! P5 Y" }. R if (xPos > (xMax - contentWidth - BallSpeed)) {& K" I, f/ E7 C. Q7 m; a
xDir = "left";# t1 s0 n. b+ m9 C% y, Y
}
0 z' t0 i- Q* Y- C9 n, x }5 v8 r+ |6 v" B3 P! e8 q$ w& b
else if (xDir == "left") {0 R& W& S, C+ G6 m P: @$ h% L- K
if (xPos < (0 + BallSpeed)) {$ J0 [+ ?$ u! ^0 s1 m2 n) I
xDir = "right";. b( L, p9 S7 u$ Z2 y$ {& n$ w
}
( H! i& d5 ~6 v6 a# I }
0 \+ n; p* w$ x3 h1 ?1 ^& w if (yDir == "down") {/ P3 @! e9 D# \$ q9 V& w
if (yPos > (yMax - contentHeight - BallSpeed)) {: L* T7 s+ k) W% {& S
yDir = "up";- c1 ~" D4 Z4 U% L% T+ K; g
}
J/ b) x* _2 {/ K6 z/ f4 e }. j6 Z a6 o, @! | N7 X% Y# J4 x
else if (yDir == "up") {( a+ @4 x! W, T6 i& U
if (yPos < (0 + BallSpeed)) {
6 i$ W4 p" G- b" E6 q' J7 O yDir = "down";
) W& U4 ^# n( K0 w }
( d0 I. }! p! F- Z: Q }) F% I! V% I- _ c
if (xDir == "right") {% D: K5 k6 O9 A$ T
xPos = xPos + BallSpeed;0 V5 {2 L2 u2 c
}
# G" J" f' M2 t% b3 L& s) X else if (xDir == "left") {
0 `& u, b; b- z; d xPos = xPos - BallSpeed;% [0 D) ~4 ?. B5 V Q8 }$ C
}, m( ` a, |( Q0 F& V6 O
else {
; x1 b( T, s5 Y- |- M2 b1 w xPos = xPos;
' t" D5 t! N% g6 Q }
$ w5 {/ S; B& X- X' k, _- Y k if (yDir == "down") {
1 w* E3 d) [+ ]2 b9 G# Q yPos = yPos + BallSpeed;' @" Z, o4 w* b: }( e( u
}
2 ? x2 ?0 n: x! o- C% ^ else if (yDir == "up") {
2 p( A, Y6 F& p9 x0 U: ^ yPos = yPos - BallSpeed;2 A/ n3 n5 C: h% E5 W, a9 O- c* @
}' X0 b1 `# ~( E# n' I, y: y
else {) G4 n: P% }! Z& j4 G! n
yPos = yPos;
% @0 R+ U: j) P8 [' A }
+ u: X1 {' ~+ C f$ |5 I }
% @5 W/ h D6 I& w% R3 J. W- F: p- I# V; W- ]
function hidetext(){
+ f7 o6 V g0 S8 b3 V* kif (document.all)
/ g# G% U. |6 Q( h! Isupertext.style.visibility="hidden"
7 p% d/ s/ t. J, J2 velse if (document.layers)/ t" x6 K- Y% [* W' S4 v
document.supertext.visibility="hide"
3 Z! r1 q5 o( t3 C$ |" A7 sclearTimeout(animatetext)
1 p" y. S4 B" `/ r* d8 \}& ^ |1 p; q/ m5 w+ }
t% M4 u( b! i: k& O8 R
if (document.all||document.layers){ q6 L/ \& |6 B
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), e7 ~& {& C1 J" m' s" o
window.onload = initializeBall;: r6 A+ ?7 B9 M( z8 `) a
window.onresize = new Function("window.location.reload()");
$ P* |* m) H9 p' O1 O}
7 M* s* y; C. v" g* V! J' g; E, o z2 t
# B4 t5 z& m7 P8 N0 A6 J' g</script> |
|