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

|
网页之不断弹射的文字-特效
<style type="text/css">. ]( v2 |( u% Q i9 E N
#supertext {" g! T. L3 ^% m* I! D4 F9 Z( q
position:absolute;
+ o ~! [9 K, \( g$ ?# @# mleft:0;
' Q7 e+ ~5 Y0 B9 j4 U( F+ Q, Vtop:0;5 |. e$ ]7 E" `% I5 s) m
visibility:hide;
: H( K+ k/ P5 `2 Kvisibility:hidden;
3 P- e$ r: B* w6 w}3 b4 H" `9 v" J, j
</style>
" p$ T# b" W, E. g. G& l8 x% f; s9 ~<script language="JavaScript1.2">2 C5 W) \5 ~( j- M
<!-- 改变下的字体的大小。颜色--># }3 F7 [4 N) M2 {+ s
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
! T# d3 b( b9 R4 z' \- @2 Xvar hidetimer='';
9 Y E: Q0 S/ M+ K<!-- 改变下的弹跳速度-->7 k! [6 N8 e$ w1 F
var BallSpeed = 20;
! Q, Q6 K+ R8 j" X2 U3 Q3 `var contentWidth;
- b3 V V: x, o6 uvar contentHeight;* X( Q. K3 B# w1 k3 }
var maxBallSpeed = 50;6 L ^) n. L% }; I
5 S; M! ]8 L2 |( z. g
2 ?. m N. W% h, \5 [- x0 A. i0 {var xMax;
+ y% I! T6 A( e7 `0 u. }3 t1 Q) nvar yMax;
7 m; B6 j& z5 D- o1 @, E/ Rvar xPos = 0;+ J- T% {$ N; V8 B: y+ r
var yPos = 0;
/ ^/ ?; o' t1 Gvar xDir = 'right';
8 a) O' a% p9 `8 s9 e" j5 b: \: Zvar yDir = 'down';6 n/ r1 Z5 K, z
var superballRunning = true;; O. t. I% w& p' u
var tempBallSpeed;& G6 E( G" x9 U: N; G0 Y
var currentBallSrc;, z9 z& p, ~# q8 V' X* S) Y
var newXDir;) W7 Y7 ]2 h: N. V' Y' h4 O
var newYDir; b; H* |: U7 r# i9 c. s' s
r+ E3 O# g) U. m& }
function initializeBall() {8 H5 ?9 S7 J3 |2 Z
if (document.all) {/ @, K- I4 M* ~) d9 l9 P; S
xMax = document.body.clientWidth
. S# j" \7 m- ~" L% W% v/ N yMax = document.body.clientHeight
8 t' E Z! Q) o# X document.all("supertext").style.visibility = "visible";( h" `/ L2 F& S7 @4 q" U
contentWidth=supertext.offsetWidth
* I% u4 x- E# S9 d/ \- t. R contentHeight=supertext.offsetHeight
) c7 u0 l0 ~! E& U+ q- N: t }1 m p9 H- |0 Z. E0 k3 n* W$ c
else if (document.layers) {
; d0 Y+ F$ C) E8 ~, q; g( n xMax = window.innerWidth;
$ w- }, a- B- D/ S7 i yMax = window.innerHeight;
$ c8 A( r6 Q: C' F" v% f contentWidth=document.supertext.document.width9 ~/ J5 L6 q, k& N
contentHeight=document.supertext.document.height& D: ?$ C5 |9 K. d
document.layers["supertext"].visibility = "show";
$ C; {9 V |# k6 _ }
# f1 K, s5 z& L2 F; ~4 N setTimeout('moveBall()',400);8 |: K0 I, x. G, z" p
if (hidetimer!='')) p6 j" g: L4 G. w# ?
setTimeout("hidetext()",hidetimer)
7 y, i5 R' p h v& C- |1 P% V }
- R2 @+ h: q6 n2 z8 O' ^. A" o8 r5 M# ~, K) B
function moveBall() {( j: q G, @, h9 Q
if (superballRunning == true) {$ T# Y$ C7 Y0 j$ `
calculatePosition();1 X) C& o+ _) m
if (document.all) {
0 Q0 A: }% {5 A, E4 ~. X document.all("supertext").style.left = xPos + document.body.scrollLeft;
' b: G. L2 _- n3 p, f' M1 n document.all("supertext").style.top = yPos + document.body.scrollTop;
0 L& j+ T+ U1 [1 w# @# ~ }5 n5 ?/ ?' s: S" r( d
else if (document.layers) {$ i' ^6 h/ w- h. O: K5 ~; w" M S
document.layers["supertext"].left = xPos + pageXOffset;' n( o, X7 P! Z5 f$ `5 t' |) m
document.layers["supertext"].top = yPos + pageYOffset;& H( b- h5 b- N* x3 T
}/ g. s& a4 V7 u
animatetext=setTimeout('moveBall()',20);+ o% A7 ~+ }; w
}
) i1 ?+ g% d+ c }
+ l6 S( O: f+ t% F* a {; W1 H
function calculatePosition() {
" C p+ t, g% s/ s/ W if (xDir == "right") {
7 A( j9 [- i! T/ ~( W+ T. h" W if (xPos > (xMax - contentWidth - BallSpeed)) {
/ n' @. L- y8 ^! K xDir = "left";
6 F6 }0 A. x+ l. f* d" w }! k' |+ t- k* U1 c: y8 O1 X! D: s- @
}# L( ]6 r* s% H! N; V7 K
else if (xDir == "left") {
1 G' z8 t$ a4 o if (xPos < (0 + BallSpeed)) {) J3 [' x* N( \6 D
xDir = "right";& ~/ Z) n6 z8 F- q" D9 b4 c
}& {" i$ k5 ~2 k: t! Q2 G/ g
}) M; w: s5 t! i
if (yDir == "down") {
, R4 L! V& c# [ if (yPos > (yMax - contentHeight - BallSpeed)) {
0 p1 l' B& q: r& D4 H; V Q7 U yDir = "up";
5 F9 i: V- t7 z }* i: O- m; {& T" @. t1 X! Z' w5 O
}$ M, P ?6 O. M0 \2 s1 a
else if (yDir == "up") {
- x ?+ X" [, `2 L4 i4 o! [ if (yPos < (0 + BallSpeed)) {, u8 L* |- Y. E) U [5 [
yDir = "down";; j& V3 K5 s2 R4 p# E% o; y7 b3 d
}+ u7 k7 K2 j/ B: x0 p0 e5 d1 D z8 P5 D
}" u$ A# L& O0 t
if (xDir == "right") {7 i3 M5 \2 `; |
xPos = xPos + BallSpeed;% L! W) @; E& ~8 y: [1 g
}9 F5 Y0 y9 ~( U6 g
else if (xDir == "left") {
0 y4 J# S$ b5 C ^' t xPos = xPos - BallSpeed;
) t5 i$ ]" m! W3 u& D }
$ _2 N: Q1 t& M8 O L" b else {
' l2 z* ^8 c% U9 g9 ] xPos = xPos;
. f% O4 F3 @3 ^ }0 r- X+ j' s$ u: l/ n7 n4 c& p/ ]
if (yDir == "down") {' d1 S4 |* l$ o: N0 J
yPos = yPos + BallSpeed;: n/ W" @3 }& b% u. M9 X" @
}
- {9 h, a) s( W. ] else if (yDir == "up") {
6 k5 m6 j5 K: ] yPos = yPos - BallSpeed;
0 Q V0 P& a$ w N( j7 b# J' j }
4 t$ S9 k4 }; o6 u else {' b2 }) h+ l. L9 a
yPos = yPos;
* l: ^5 n1 o& s7 q: S$ a2 C0 p! Q+ | }! O6 r, j7 a( V* V
}
9 _- z. `3 M! t! @$ l
3 P4 ]8 C) Z2 \% s6 Afunction hidetext(){
]" t8 P' c; |% Qif (document.all)1 R2 o. X4 @& P7 `: E* y
supertext.style.visibility="hidden"5 F0 M: E" v+ g1 j8 t8 k8 h
else if (document.layers)& T) a# ]0 m9 i% c, [- `, e
document.supertext.visibility="hide"
: \# g) m0 u- [, k+ F& D% GclearTimeout(animatetext)
; `! ^0 \ h9 G' k* Q}
# A9 p& v7 N6 y7 h/ ?
0 R8 n' y9 `) D& ^ U5 Tif (document.all||document.layers){. K$ |( c" K w2 a& p- `
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 p+ _8 x% N5 X2 n2 s4 s5 swindow.onload = initializeBall;
; w; ]7 u9 @3 T* e8 Pwindow.onresize = new Function("window.location.reload()");
, b2 X/ j# X! z}. t( `* }- K' j$ E" e4 w
, z7 L, ]' A+ g! w& S</script> |
|