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

|
网页之不断弹射的文字-特效
<style type="text/css">8 _# u; P$ R7 W/ E# T
#supertext {) q: B+ m' G+ [2 Q, I4 z
position:absolute;/ B/ Y7 y' R" v; X J+ S
left:0;
e. t# N z3 X8 U |top:0;3 z1 N: o! b6 y. E! l2 F8 b
visibility:hide;
. U4 l$ z( s# W& @0 jvisibility:hidden;% E: e* A g) i7 `- p
}& }( h3 x5 E9 T4 i, }. ]0 V& |
</style>& a6 J7 U9 ]& A: c
<script language="JavaScript1.2">$ ]3 g2 H* w9 s4 ] W$ y# f
<!-- 改变下的字体的大小。颜色-->7 E/ `0 \4 n7 _& w/ H
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 j8 J1 M. ?) L9 Z d% n( W
var hidetimer='';3 J. Z& |6 d' F/ b! X
<!-- 改变下的弹跳速度-->: m. o1 [* h" |$ D
var BallSpeed = 20;
- r# K) T+ ]% t" @# jvar contentWidth;
- }! \" t. P6 i+ d/ uvar contentHeight;
# ?/ q7 q. t, _: l' b4 Vvar maxBallSpeed = 50;
8 h& r+ o1 j& C f" R1 z
5 j7 B. ?9 P+ X) b: U! s) s. }0 ?* b
var xMax;
4 s2 h: E# M& X9 L. Nvar yMax;
9 i( Z A3 C9 h$ Lvar xPos = 0;7 ^( G, s# w- v+ T5 H
var yPos = 0;
0 T/ W) c) a2 w# r# c" `var xDir = 'right';
4 N! {+ A' U: e7 d5 k2 G p( Rvar yDir = 'down';+ O; U8 j! ?- j2 q' r) x
var superballRunning = true;
1 V$ g/ {5 _9 y$ P2 j. [var tempBallSpeed;
9 Z! w2 w7 q @: B$ Mvar currentBallSrc;
& a+ v0 P& F5 M: w/ V4 J1 _3 gvar newXDir;
' Z7 X4 k1 b! p* ?! Q/ @, ivar newYDir;9 k N! q+ K2 J- e9 K2 D' s
- r$ h+ J( Z# zfunction initializeBall() {
& \5 J. v4 j' D F6 v# g" ^8 i# B if (document.all) {
4 @. G4 j0 [$ ?% v xMax = document.body.clientWidth
S0 y) q: S" Q& A% d yMax = document.body.clientHeight/ v/ s, Q; H7 \+ P
document.all("supertext").style.visibility = "visible";1 c2 n% D! K- u* F+ W0 T
contentWidth=supertext.offsetWidth
" b3 b+ E$ d5 A. V6 \" E- T contentHeight=supertext.offsetHeight
) u( h- H6 R$ v! t+ `+ B, U }
- {# _- c5 S, }: a/ S# U+ r1 v else if (document.layers) {: b) S# g) I/ s$ v \2 i
xMax = window.innerWidth;
# M" L# t: @# b, f yMax = window.innerHeight;5 l) Q$ N1 p( q4 N& ?% G
contentWidth=document.supertext.document.width
' @& w' i) c! E* E# i contentHeight=document.supertext.document.height j) I6 w- z$ U) m: v
document.layers["supertext"].visibility = "show";
( Q% i6 T& ]1 Z+ e4 V }" f$ j' W2 o* ?% y! G
setTimeout('moveBall()',400);
" E6 q9 y/ e4 E: f1 Y5 m% O if (hidetimer!='')& U# I) L/ Q6 F9 l
setTimeout("hidetext()",hidetimer)" z) ^$ l# S. p8 J3 d8 s
}
! I$ I$ Z. B) o
4 {4 I5 |5 l: w0 Mfunction moveBall() {1 z. Q) V" X; i" o9 w: O5 y$ O; Z
if (superballRunning == true) {+ t9 X( d) A6 e4 E8 s3 K3 s u
calculatePosition();, h$ D# I+ P8 o4 q p
if (document.all) {
1 ~1 [6 f3 |3 W document.all("supertext").style.left = xPos + document.body.scrollLeft;
8 d! ?/ H! ~2 d" O; `! B4 g9 | document.all("supertext").style.top = yPos + document.body.scrollTop;
N6 W1 }% a8 ?! ? _ }
& i* g0 \0 X8 j) v2 Y0 M- r else if (document.layers) {
6 x$ j. A2 o8 Z6 Y0 a y document.layers["supertext"].left = xPos + pageXOffset;* K0 ^/ u7 q/ q; v5 m% @' ~1 ?3 m! q
document.layers["supertext"].top = yPos + pageYOffset;
$ ~) G0 |( z- ^+ {' w* O) Y; i }! g. ~$ r c( O' j) W4 M; E* ?% l% Z
animatetext=setTimeout('moveBall()',20);
. e( V4 Q3 L. }! h; p5 u }" D% c# l# C( j* b" r
}0 q& g" R5 j8 | ^$ F
3 |* H, G, G1 G" J1 \7 o: R ^function calculatePosition() {: ^2 Y& s# R1 a7 f
if (xDir == "right") {
. `; r. v8 g. H: x( y4 Y3 \ if (xPos > (xMax - contentWidth - BallSpeed)) {' r0 R. \( L' B+ M: ^/ O. U" `
xDir = "left";. @6 {% D9 d2 w( }* x4 B2 t
}
4 N; j# s0 A# G4 D }
* L7 A/ f% H m2 L% u, r$ D else if (xDir == "left") {
, @3 i! O* V3 T5 R: O3 R9 B if (xPos < (0 + BallSpeed)) {
9 j5 C; d+ {6 u2 L" f xDir = "right";
" H: P) H u5 @2 H! o/ L0 ^ }. d0 e% R9 o: j& F
}
- f- k/ ?6 S; \6 d& u if (yDir == "down") {) Y! F: [* I4 f( M9 m3 _
if (yPos > (yMax - contentHeight - BallSpeed)) {6 q3 g! V0 D* c# L" \3 m% F! V
yDir = "up";
! Q7 b% x! c' m* i0 A/ f }& S" ~0 y7 m6 q( _
}! ~/ Z }% K6 s. e6 t+ @1 b
else if (yDir == "up") {
0 g$ d: X+ x X% q, s e& c if (yPos < (0 + BallSpeed)) {) e9 \1 v5 @6 j* C6 D
yDir = "down";7 I, ^% E+ K d8 w5 V
}
* p3 V2 Q" K; \7 d Y) Z/ \ }( p' a2 ?# }$ x
if (xDir == "right") {
- O" h: r' [( D" W$ g- ^ xPos = xPos + BallSpeed;
! Q2 N2 v: f9 \/ x0 b- s e }1 C" B; v' U! }5 j! w! _7 T
else if (xDir == "left") {
5 v4 M: h/ a2 r- y1 E xPos = xPos - BallSpeed;
# Y2 D5 h$ Y2 o( ?" G! g; Y }
/ ^3 n4 h7 Z$ O) G% i3 t/ s else {) ~. X8 L% ^8 Q* _
xPos = xPos;+ m0 I5 }/ }' \7 e+ V+ ]8 C& ~
}- N- N! C& V) w) c( V1 `) R
if (yDir == "down") {8 v: w4 ^6 q3 K
yPos = yPos + BallSpeed;4 ]1 Z! z" E' g" A6 `# Y. n
}
" i8 Y7 j& c( H" @ else if (yDir == "up") {2 p/ M+ t2 i: V1 A; b' \6 K7 c
yPos = yPos - BallSpeed;, n; Z$ r! K/ C+ [! P
}) q. J1 z. q; h( W1 ~7 O
else {
* `+ e) B3 z8 a7 x; c yPos = yPos;
% S3 z. P2 O5 k, ` }7 T! p# y$ i" ?7 A% l2 c0 A
}
" s; M% e k% N9 g7 V) t! L4 v7 O# ]$ a" j r5 u! A7 C
function hidetext(){
" M$ R) h5 G2 Y8 n+ ^+ jif (document.all)( v. k6 T& Z/ \( d
supertext.style.visibility="hidden"
5 V7 X& _* `# L v7 @else if (document.layers)
0 \ X+ M7 k* K* U2 Cdocument.supertext.visibility="hide"
0 z& o; K, @5 J- k) o: N9 AclearTimeout(animatetext)& u7 ~4 {2 ~. w% K
}
; d4 \* l5 q' h* R
- `1 w0 q* p4 N0 {$ o- Qif (document.all||document.layers){
2 |+ N- R7 q; C" p+ C' E bdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
: R% H+ b4 @/ X, Y! i7 Nwindow.onload = initializeBall;
# x: o7 |+ X7 W; Qwindow.onresize = new Function("window.location.reload()");$ G: f+ A: w" u d& x$ Q4 p
}
( Z- y4 [+ W( B+ S, i
% u5 M( ?& c d, I4 |</script> |
|