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

|
网页之不断弹射的文字-特效
<style type="text/css">
0 }6 M( p0 I. {" V#supertext {& P f4 R0 h; N j2 z: }
position:absolute;" Q5 o, u4 G# W, s% U$ @: ]' _
left:0;
, R) h! H0 D: ]6 J0 D. r# ?top:0;
" C7 R' o; j- s1 v$ g8 f4 wvisibility:hide;/ W4 B# l) R7 w2 H# a: N( Z
visibility:hidden;
" Q3 G( O/ X. x+ E8 p}
0 r1 U% K9 o( m6 ~6 I</style>, {7 I; \( T f3 J% f- m
<script language="JavaScript1.2">
6 |; U, |- J; o4 J<!-- 改变下的字体的大小。颜色-->- Q) D* V& O! s
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% W, A! ?) [* X9 v, a- P
var hidetimer=''; h, j- Z" R- r, H* c
<!-- 改变下的弹跳速度-->+ p0 l ?/ G1 @, O4 c# N& g: c0 ?( ^
var BallSpeed = 20;. V j. y; `1 W' e1 g
var contentWidth;4 A8 o* H% k3 @/ E2 E' S, h
var contentHeight;
: J6 x7 m: r8 n5 y# `( U* @- nvar maxBallSpeed = 50;8 o' |% D! t4 J
. F( N! _0 k3 H2 E
3 T7 F$ ~1 \4 X1 R" {. g s
var xMax;
; ^! }4 n/ p' L: \# P6 l" Nvar yMax;# s$ l' z. }6 G6 Q, Z
var xPos = 0;1 z u: n9 _/ a+ S/ X
var yPos = 0;
7 s% E# H, k- Kvar xDir = 'right';
3 o9 [7 a( u( c8 j3 |. A7 ?var yDir = 'down';
& |- ^- }0 r4 C8 avar superballRunning = true;
! Y2 @; |! x, ?6 f Q* ^( [1 ?9 vvar tempBallSpeed;
% [% V# P7 N( S3 dvar currentBallSrc;
! P. J& Y/ S' f2 y# \: F3 Ovar newXDir;
0 R; l1 I/ l4 i, b1 H% \var newYDir;, N& N4 X1 E* ~8 U1 C" j; q# d; e
2 ]9 h5 Z" V3 v @7 B
function initializeBall() {* N$ }8 |. q- K' Q; X% I
if (document.all) {
3 z- A! O& m% _4 | xMax = document.body.clientWidth
) u1 X- A1 V% o$ A/ A, A4 c yMax = document.body.clientHeight
1 f/ y Y+ ^5 @. ^ document.all("supertext").style.visibility = "visible";, ?6 a7 @. V" H
contentWidth=supertext.offsetWidth; R3 s& b8 X* i0 w; F$ R+ m
contentHeight=supertext.offsetHeight
, u" n, i( J! ? s8 U' q }
4 X6 p _6 r2 B" N2 o- U else if (document.layers) {
3 N3 c! u7 u/ L xMax = window.innerWidth;4 I. R3 g+ k# c! ]
yMax = window.innerHeight;
$ ]5 l7 M5 E ]- { contentWidth=document.supertext.document.width0 H2 c6 v, }; w8 C/ L) Y, }, ^6 k
contentHeight=document.supertext.document.height
2 b4 _( V6 m- e document.layers["supertext"].visibility = "show";5 \% y5 \* i a$ `; d) V1 `* N8 \
}
6 H- W( c1 [) F w5 G setTimeout('moveBall()',400);
) a4 I! I8 H' t6 e- o+ T2 t E if (hidetimer!='')3 S; N3 \! I# O: Z
setTimeout("hidetext()",hidetimer)
9 m' v {6 L* |; z+ `( B }
9 z$ Q' B d$ ^* u: {" {$ S/ ]+ V. b% L/ \& J4 M; p x$ e" w
function moveBall() {
% J' c# [8 U8 c3 o2 D" W" K h if (superballRunning == true) {# ^7 n' r$ Z' f+ D' \# V2 L/ }2 y8 v
calculatePosition();
$ o8 m: |; i+ a if (document.all) {
/ W0 N0 M. g8 r/ u document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ h# m1 D' ^% ~1 @ document.all("supertext").style.top = yPos + document.body.scrollTop;
/ ?3 g, G7 _! [; x+ @! k* }9 r# g }7 x5 Z2 Q+ K" Y$ }1 S
else if (document.layers) {8 m0 G4 l/ i6 E: G o& A J
document.layers["supertext"].left = xPos + pageXOffset;
$ ]+ b$ L( E ? w9 u document.layers["supertext"].top = yPos + pageYOffset;4 r" v5 z. K9 d2 s' W7 t& C
}8 O Z6 `7 _7 s
animatetext=setTimeout('moveBall()',20);2 c# T: h0 a6 z3 K# B/ j9 L& G2 E
}
5 u! l! z8 [. }1 l }
9 ^3 E7 P3 k6 x% D: S6 q
/ h! G1 U) L; h% l! W1 a( Tfunction calculatePosition() {# Y$ Q+ T; \) u" t4 S5 [7 h
if (xDir == "right") {
2 Z/ h9 N h5 f' p% r0 G3 _ if (xPos > (xMax - contentWidth - BallSpeed)) {3 w/ p' j6 W9 b; N, @
xDir = "left";+ U7 l) A& M7 [) R5 c7 T$ ^2 D0 [
}
) b! F) Y4 s S0 R% P. T }
8 G' }! f+ \4 Z- ^ else if (xDir == "left") {
1 d( j7 F9 a) K3 b, G; ^5 d if (xPos < (0 + BallSpeed)) {
+ k9 C- j' a0 t7 j xDir = "right";" W% e8 j5 B, _" S, R* ]+ C
}& u7 g0 E% |% F2 n1 G4 {9 t
}( K6 _3 o9 A$ X% s- a( E
if (yDir == "down") {
! ~* b2 m. x. i9 l if (yPos > (yMax - contentHeight - BallSpeed)) {6 i: B- ]$ r3 s3 R$ x3 ~8 C
yDir = "up";
# o2 m: @+ c" g }
& I' {' m; ]+ H/ N& H. [! p# m }3 p d' ~( V2 F+ b, `
else if (yDir == "up") {: M2 b! e- d" P I6 {$ P
if (yPos < (0 + BallSpeed)) {
) j' a- z# ?0 B1 ]( v yDir = "down";' c$ `. w- O1 }& Y
}" u6 S w' I6 ~' [2 z: P" V
}
0 ?- s. W5 T+ F/ G8 ] if (xDir == "right") {
$ J5 A5 A' g! m, K* [ xPos = xPos + BallSpeed;
9 T, A# ^$ q, s0 T0 w) d }
0 V. \+ s8 T; { else if (xDir == "left") {
9 k. X% k9 K# r3 _+ F! l$ P xPos = xPos - BallSpeed;8 v) v$ K3 B1 n8 H7 C4 f+ p; H; n
}
/ \6 Z# K) k* k |. E else {
4 r3 |: X1 H# L' N7 @) u xPos = xPos;5 I! U+ `/ h$ x
}
$ I" x4 ]% h" b- f7 x0 X# e* V if (yDir == "down") {
0 L$ S% u0 d+ j' s8 Y0 w3 A. i yPos = yPos + BallSpeed;4 }8 x& x0 ?$ D/ L
}( y- D+ w7 ?' f; b4 z% T
else if (yDir == "up") {
4 J2 G% R, u E( L$ ^( { yPos = yPos - BallSpeed;
# v0 F3 S9 `1 h }
& M7 V) J3 ~1 B/ a: }% g( c. g else {: y& G8 q* o$ S4 z2 G% y2 a2 g
yPos = yPos;
: h% Y4 C! r5 `3 R }
J/ w) a' j9 k' i" ]6 E; u }
Y% ?1 ]8 g0 d$ |" j+ `2 U) D2 Y* L
function hidetext(){
- P7 S+ p6 u! e, H1 Rif (document.all)
9 l( T y2 b: ]; v3 e+ u3 q( Xsupertext.style.visibility="hidden"4 `# }6 u" z# I$ |. U! l
else if (document.layers)# H0 k; L4 d2 r( O0 G0 j+ I$ W
document.supertext.visibility="hide"5 A, ]6 D( M8 X8 u
clearTimeout(animatetext)7 E4 u. r/ k: h
}
& \( K# _2 g/ U0 e! T" K
7 h$ _6 ?4 @# j1 uif (document.all||document.layers){
. s ~# C5 F$ U" Pdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
' t: {& [3 Z( X7 |! w0 H3 ?window.onload = initializeBall;: i4 d& b- H, l' ]0 [# M% F
window.onresize = new Function("window.location.reload()");8 A- w3 n" R' n! e
}
% Y8 M3 T5 b/ I6 ?5 M) e, y: j! s: K( i$ y y. Y+ k
</script> |
|