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

|
网页之不断弹射的文字-特效
<style type="text/css">
+ A! `, X- i5 {4 J* G, v9 p#supertext {6 Q: P* w! q1 ?! i0 [$ B' @. s
position:absolute;
0 Q$ x" I7 w2 b* ]left:0;
) W: b( c) r- V3 ^( s4 Ctop:0;
0 o) B0 O$ r2 q& y- Tvisibility:hide;6 |# s, r/ P6 r5 a4 u2 Z& y- r
visibility:hidden;* G4 n3 ~; M. h) k9 G \
}4 c/ G$ ]- G$ m5 A2 F9 R
</style>
* w8 R7 m/ a4 }" x2 l" \" X# r<script language="JavaScript1.2">0 J6 c0 G7 z) {) b7 [4 Z( {# P
<!-- 改变下的字体的大小。颜色-->
9 w8 s7 w/ I' x3 `) K; r: q% `! Svar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 z: w0 P4 h% R" y; x. K8 q5 [var hidetimer='';/ R0 q* `" C M, ?. {8 i) ]
<!-- 改变下的弹跳速度-->
' J6 @& G. a& S( U- I0 Vvar BallSpeed = 20;/ s8 p" A& { d4 @5 h3 [7 J4 k
var contentWidth;2 a; e8 l% i6 J
var contentHeight;
" ~. W# T- p; Z ~2 P' Bvar maxBallSpeed = 50;0 {/ J! v- b* ?7 E
. a& V3 L r& N
. f# j: x- [7 S+ ^1 Z; C
var xMax;
2 f+ Z7 @! L' i6 v, k5 }var yMax;
: o `1 s. D. c. ~" b% _var xPos = 0;. G; r" S% C i- v4 A
var yPos = 0;( p6 m1 Z# t5 d' C9 [' Y# ^
var xDir = 'right';
! e3 B- J8 n& Svar yDir = 'down';
% X3 Z ~# J0 Jvar superballRunning = true;
0 v x8 V8 t" m% Fvar tempBallSpeed;$ }" u( t/ z+ K/ K I3 a
var currentBallSrc;
0 L2 \# h6 K- @var newXDir;6 n y2 e+ n" F+ Z" X# c
var newYDir;( B0 L3 k* Q" d6 ^
" x& R+ \5 @7 e: D2 x
function initializeBall() {
9 S/ I4 E+ y* }- i if (document.all) {2 A( N( Y+ ]+ L0 d( j8 Z
xMax = document.body.clientWidth
8 u6 R2 K, Q% p2 {& r$ R yMax = document.body.clientHeight" ]- g! B1 [9 z- k4 K3 x) [' V+ Z
document.all("supertext").style.visibility = "visible";' R5 ]0 d! f7 i. Z
contentWidth=supertext.offsetWidth& C" O- e6 r: W( k3 G6 m3 {1 P
contentHeight=supertext.offsetHeight
% J; k0 J7 z9 z- ? T) U }
" w9 ~- l0 ^+ G6 l8 |( q) F else if (document.layers) {9 z) u3 \$ U% Q% C" m
xMax = window.innerWidth;: \' Q2 I: C& c4 C
yMax = window.innerHeight;) z2 u0 \6 K8 N
contentWidth=document.supertext.document.width
) O5 ^1 h x" o& r% z$ c% ?9 T/ R4 F contentHeight=document.supertext.document.height! |/ X* T% E) z* c2 j
document.layers["supertext"].visibility = "show";
6 u2 a; I( v" i& Z }
6 o! @+ `. o& l0 }1 U: k setTimeout('moveBall()',400);
. n+ O5 | }- q8 y& t" F if (hidetimer!='')
$ ?5 r" A! k& P; o4 v: D @ setTimeout("hidetext()",hidetimer)! `0 m4 x( S2 Q# p) v
}% p! I7 g, Q+ t
* S0 M# w1 X5 W; mfunction moveBall() {1 G' W9 a- h$ _! ^% W
if (superballRunning == true) {
& w6 ] A8 M! u; k4 g% S calculatePosition();
( s& m7 L/ Q" {2 \' D if (document.all) {& ^9 B* {1 q1 ?* |
document.all("supertext").style.left = xPos + document.body.scrollLeft;4 N/ ?) f# [5 \+ \; w Y
document.all("supertext").style.top = yPos + document.body.scrollTop;
1 v1 L# Z Y: i& D }* s( r5 y; @, p* ]
else if (document.layers) {
\ G5 A8 G& E9 H7 Y+ h7 r document.layers["supertext"].left = xPos + pageXOffset;( \" q3 V. @3 e, L0 B5 v8 W+ }* b
document.layers["supertext"].top = yPos + pageYOffset;6 A* j0 N2 k6 j5 r7 F$ z
}6 a; ~) q2 i. \" Z9 Z. K( `
animatetext=setTimeout('moveBall()',20);2 T% K; [& M {6 s3 s! U- s
}
/ r3 E4 `7 B# n0 G+ K- |$ t }
) V( L: G5 F* f' n2 e" p) J7 X2 K6 q, ]1 e! V$ |+ a, R' g7 ], {; B3 I
function calculatePosition() {
* {2 ^: L/ ^- \7 ~6 ^# L$ v* {- s if (xDir == "right") {
2 ]! v6 Q0 r, l) q( v5 m if (xPos > (xMax - contentWidth - BallSpeed)) {
; U8 }% K% D* H/ w9 c xDir = "left";. X1 n" y7 m# |) e0 Y3 y
}
9 ^1 X) J! X9 v, `9 f5 u* p8 W5 H2 K7 e }
$ V1 T9 k4 N6 H( @1 c else if (xDir == "left") {. _+ h( w1 |5 D/ g
if (xPos < (0 + BallSpeed)) {
6 ^" _( D1 z+ C g% E! x; ? xDir = "right";
3 e+ U p1 o. T9 V8 X5 ? }0 T! \7 v/ F/ M' f% M
}
5 M+ L, Y1 O6 _; g, t if (yDir == "down") {
5 B: E. y% r) e+ `5 I5 M if (yPos > (yMax - contentHeight - BallSpeed)) {+ R0 K4 \! h1 D5 h, W
yDir = "up";$ p, o8 w$ a+ u1 R& k# K
}
# A$ M; _3 M+ ?) b* w% e }/ i% S5 ?7 p1 a
else if (yDir == "up") {/ L! E8 t5 r% f/ I: _6 `4 u. U4 h o
if (yPos < (0 + BallSpeed)) {
1 X5 q/ H& S& ? o A' Z yDir = "down";8 n+ w8 b+ o' n- M' B, b
}3 f) u5 m! p& {/ p
} u/ O- \( j* k* Y5 W4 E+ t
if (xDir == "right") {* K. Z" t4 g5 V/ v
xPos = xPos + BallSpeed;
, }$ o# y& j6 v9 w }+ v, W. a0 z, S7 \9 W" h
else if (xDir == "left") {% e2 d* W* \+ Q- t
xPos = xPos - BallSpeed;* H" t# R! J; `! x
}" S4 I# i: U, d; Y6 w) {8 B
else {
9 V# c4 L% r G A# `) @" l xPos = xPos;; v: L8 x; [: J# T8 Q1 u
}
/ p; T! z# E/ H8 U2 A1 } if (yDir == "down") {
1 d. L3 v( G2 j2 [2 n0 { yPos = yPos + BallSpeed;
9 a3 O; S2 U% l, C$ ?; T1 L }' A X9 I1 v) K1 a( `/ U
else if (yDir == "up") {
% x: H: }% W& x* B2 I" Z: n R yPos = yPos - BallSpeed;
) r! l0 t" p3 _( { }
0 O8 q1 ^ U" y$ P, R& |" ^8 ?! @ else {' U' c0 v3 @! ^! v! l
yPos = yPos;
- q, C6 l1 a" N0 [! w }
; r6 }* x- U0 `# Z5 h \ }6 ]/ |3 T2 u( i9 W$ e# J
" K, q& M, @1 \% H6 K; I: L6 Dfunction hidetext(){
4 C" `$ T: u7 Z8 f. vif (document.all)8 r8 P% q* E! N/ I
supertext.style.visibility="hidden"; e; t; w0 p* B. U: Y
else if (document.layers)* a* \, U: H' {3 { a1 ]$ a
document.supertext.visibility="hide"9 |) Y4 m& e7 e( C8 E" I& Z* Z
clearTimeout(animatetext)7 }$ t6 U4 e/ _2 [, I) x# j, [% f, H
}1 g+ C! i* @7 y4 y: Y1 R+ f
' J, E8 n- A3 }: `: Cif (document.all||document.layers){- P3 W o1 g/ R& j# N( q
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
+ j6 f4 Z: u5 g6 [9 Gwindow.onload = initializeBall;
; _/ Y% J! Z% F6 Hwindow.onresize = new Function("window.location.reload()");0 k% R0 f/ ~+ {3 d+ m* w) m
}; o7 C+ N% K( N+ Z5 ^
0 k u2 ~% a& N7 M9 I
</script> |
|