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

|
网页之不断弹射的文字-特效
<style type="text/css">
( K7 x, J8 [' p$ {. P7 b! i* d* t#supertext {
0 b) [4 _7 Z+ v1 D, jposition:absolute;
! A: t( h+ J8 h8 W' E! Rleft:0;
; q* w, Y; ?3 k. }6 |# ftop:0;' h- J+ }) M) @2 \
visibility:hide;
a/ B& l$ U" z% i& }visibility:hidden;; Z9 V- C% c g' X
}9 _+ a k. h! S* t0 q5 P
</style>" w) a( E( f' V; g
<script language="JavaScript1.2">
9 p* Y8 `# u. Z/ P& F<!-- 改变下的字体的大小。颜色-->
2 ?& c( {0 v6 B4 E. x, Q. q, \+ }var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 e _0 \' h0 u `* P0 _var hidetimer='';1 J: O K. X9 i& [( F1 U9 z
<!-- 改变下的弹跳速度-->
, K6 F% i E3 ^7 }4 s+ O8 D0 ovar BallSpeed = 20;/ g( S' b+ G5 f9 b
var contentWidth;! @$ {% W6 \8 \+ o; K
var contentHeight;
- U) S! J8 X5 \0 D, ~. Gvar maxBallSpeed = 50;
X4 f# M4 e' W$ M) o' I) p! Q9 @3 ^: R- W8 Q' Y, `
$ E1 D' q* y( G, ~, b% Q7 g# M
var xMax;
" ~, d" ?7 d1 X8 D5 D+ |* lvar yMax;
: \2 B8 O* i& G. N9 ?# Xvar xPos = 0;# p5 S3 c0 ?& y4 h, r5 U. y5 M1 u
var yPos = 0;
& _# H3 B. y; G# i& f; b0 a$ ovar xDir = 'right';
' c( T/ c u/ S% _ E* P6 Ivar yDir = 'down';. m/ o2 I* |1 s
var superballRunning = true;
5 I( u% M9 D$ p- |- R8 ]var tempBallSpeed;
3 ~3 e9 X" }. F' h% y1 Ivar currentBallSrc;+ u, s$ b, f9 W$ W6 }8 C
var newXDir;
7 ~ w4 }2 X7 @var newYDir;1 ?3 T: Y7 R5 n) v
, a, Y2 A/ L: J" c0 m: r
function initializeBall() {
+ C9 _6 q w# w# B9 x5 ?" B if (document.all) {
$ F: p& q1 Y1 G6 U, A( i xMax = document.body.clientWidth/ e8 `0 p. a# x) V8 C" {& W# O" b
yMax = document.body.clientHeight% L1 u/ a" _$ p
document.all("supertext").style.visibility = "visible";2 ]" O" w. l+ _) ~% Y9 i
contentWidth=supertext.offsetWidth
" W* O* Z, ^$ \* l0 `4 U3 D contentHeight=supertext.offsetHeight1 O U8 E1 h" G
}# v o; p/ e9 d2 I' N8 `+ \7 `
else if (document.layers) {
- K: O1 W! X# s i4 e8 K) T. e0 m xMax = window.innerWidth;
+ e- i5 N" v! i$ h2 G7 z yMax = window.innerHeight;- K: D3 S# [" Z, |+ U
contentWidth=document.supertext.document.width
) f$ w- r A7 }5 g# j) h contentHeight=document.supertext.document.height( s7 p' Y5 W& |2 x# w/ Z$ V
document.layers["supertext"].visibility = "show";# k) r$ _7 h/ L
}
7 x3 Y* Q7 M0 [5 J/ a setTimeout('moveBall()',400);
0 H' e% z: S% S if (hidetimer!='')+ C1 h/ m, a% ^6 B7 |/ s9 s5 d# O
setTimeout("hidetext()",hidetimer)
, u* C+ O) ?; M! ^1 q* N5 P }, ~! F2 M- J9 @3 `6 w
' ~9 F7 L! B2 x* i, Rfunction moveBall() {
) o! i# f9 I$ L6 R if (superballRunning == true) {
" }, _4 X% L0 e: d calculatePosition();
) Q" ]% b( m0 d( f { if (document.all) {, t1 E; _2 i7 P( ^( G- Q- z9 L L1 b
document.all("supertext").style.left = xPos + document.body.scrollLeft;- J7 c& ^8 ]; H8 M/ i2 g" a% a6 Y
document.all("supertext").style.top = yPos + document.body.scrollTop;' F, B* ?1 m1 g; `
}
& W$ H- d. }9 z! O2 ~5 R3 W2 h else if (document.layers) {, o6 P6 F! K1 A. M+ R* g
document.layers["supertext"].left = xPos + pageXOffset;+ Z1 V8 I% R: m9 c* T+ l
document.layers["supertext"].top = yPos + pageYOffset;
% B; c) Y4 h+ l( G }/ P+ j! g) i# G6 S: i9 W) C' ]) w
animatetext=setTimeout('moveBall()',20);
% }& L; W/ V- ^: @* @0 M }
1 R4 _8 @2 i3 d* V }- h4 h# n. j4 c! k
) c! n8 e X/ A$ n9 ?1 X/ J8 Afunction calculatePosition() {
" L& B1 s, ~& y7 u; e if (xDir == "right") {
, }* m/ E) S4 B+ f if (xPos > (xMax - contentWidth - BallSpeed)) {
8 s( z, K, h* i v+ E xDir = "left";0 y1 o+ o. y/ |6 _8 M; Q
}
% Y( s1 R& O O# b6 `5 U& l7 u }
: `0 F! p- \" P9 B) ] else if (xDir == "left") {
5 r! s3 V' J. x if (xPos < (0 + BallSpeed)) {3 Q) B$ [0 i+ L. X7 e
xDir = "right";
. H' b, o( {9 r5 J6 B4 N" Q" H a }0 B# L+ l- @0 e+ y( `3 g0 L
}
: H1 Z7 Q$ R, h if (yDir == "down") {
. [ H! P' d2 x Y9 t* l; l! q if (yPos > (yMax - contentHeight - BallSpeed)) {
n G ?+ c6 I1 R4 z( [* R yDir = "up";1 n( q! b; i" a3 T! {8 O+ t
}- P) l! T# L3 Z8 ~- H- T' @
}
4 u [ I9 @' z+ D else if (yDir == "up") {
8 F5 F( e# V4 \4 B. e& X" m if (yPos < (0 + BallSpeed)) { M: g# Q. [! S# F2 o. R- Z
yDir = "down";6 r4 t7 C+ C; Y1 i, @
}( _4 [7 | ]; y0 e* h$ }& _
}
# g) Q# V2 |' q! w% ~, i if (xDir == "right") {3 D7 j3 g- v/ q/ q9 s" u
xPos = xPos + BallSpeed;
: F" [* ~- E4 |( e D) g }5 T& m+ ? a" u/ a& I2 ]
else if (xDir == "left") {) o: s0 w' W. g. n2 e) F; @
xPos = xPos - BallSpeed;
4 o5 T: i/ E* P2 ~6 |% h }/ W. }9 H4 H1 x c: p& s
else {4 X2 P8 g0 _3 L0 Z! E1 L# Q O
xPos = xPos;' u- }6 Z+ \7 g) d6 ~8 c: f! }( N
}0 i6 y" Q9 W- y w0 i
if (yDir == "down") {+ V, ]& H* c z# U' u" T
yPos = yPos + BallSpeed;3 H5 a% i/ H5 q1 A, K" K: R0 e
}
0 t! j1 R! N/ d5 P else if (yDir == "up") {, e! U5 I N6 Q, q4 y1 u; S7 O
yPos = yPos - BallSpeed;4 { R/ b! E& S2 ]
}( o5 {+ d# m0 D# v
else {
$ C, G* N( y* c: U- o yPos = yPos;
' o4 `. f* S& V& d. A2 R }6 _) Y/ ?& |' v- A) ?
}
, v6 |. N5 c$ g9 v/ e/ M5 j: f y- ]4 Z- Q
function hidetext(){0 V5 K% {! L2 F8 \$ ~3 `' M+ P
if (document.all)
1 B6 x' n+ l: e/ dsupertext.style.visibility="hidden"9 @3 d* ?6 s1 _% V% h: F9 s
else if (document.layers)
$ B, `% K" w$ @: ^3 S; Vdocument.supertext.visibility="hide" n( N: Q3 |/ S: O* K
clearTimeout(animatetext)0 t+ v$ [+ k. i5 J' d/ ~
}
! m* L0 F5 ^6 E# |- z2 T; h8 x2 i0 ~" E$ d7 L) M
if (document.all||document.layers){
- i% W8 W) {$ a5 ^document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')8 P& V/ _! X n! [) g9 j
window.onload = initializeBall;
( y+ u" Q# w/ J& w1 p5 O! ^window.onresize = new Function("window.location.reload()");3 F; v: Z" ?9 q# d7 X* }: I
}
1 {& ?% L q, T3 |
; k- F" o: ?" v! X</script> |
|