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

|
网页之不断弹射的文字-特效
<style type="text/css">" T( f$ k2 A, f9 r& y$ I! e4 @8 k
#supertext {/ U* B( n2 D- `8 v3 O% g4 X
position:absolute;
7 \' N# v3 x9 e9 p3 o; pleft:0;9 c" P# [' X' I) p+ A! P. u
top:0;+ a9 u0 X2 Y9 R/ G% N6 s, I$ v
visibility:hide;. R: j+ i- K6 }5 {6 _- t: r7 I
visibility:hidden;
g; v6 W7 J! {, t}
2 D& w J k9 o' c$ m* v3 w, s! ]</style>
* m0 j9 g8 [* u; V3 g; D8 X<script language="JavaScript1.2">2 H" H9 d4 W! H2 x7 {4 I3 B9 E
<!-- 改变下的字体的大小。颜色-->6 C" s. W+ G8 V: f
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
8 N9 w$ t7 h$ V: cvar hidetimer='';5 `7 h- ^8 P' p$ C" [7 K5 o" ?
<!-- 改变下的弹跳速度-->
& j2 r4 c2 P7 O; v3 @var BallSpeed = 20;8 L+ O! }. b3 `8 G4 E
var contentWidth;; S! r8 f, E. `4 q" j
var contentHeight;
* B* k! j) _% @7 [0 m4 evar maxBallSpeed = 50;
6 F; e" h4 v7 H f# g& B$ E$ E. s7 Y
6 S4 ~2 K3 U0 r: S l9 rvar xMax;% B% k1 r% h! A4 v% S
var yMax;, ~4 i# S3 V% A
var xPos = 0;
8 m: n) x- f1 P+ Qvar yPos = 0;
( |. E/ \5 R) S: Gvar xDir = 'right';
- `- \. W0 Y( E& J6 I. Q5 Fvar yDir = 'down';
+ t) j+ B( Y% E$ Nvar superballRunning = true;. H2 L- y+ x! a: k4 Y$ W2 h0 E
var tempBallSpeed;/ a" J& ?7 I) q7 v5 P
var currentBallSrc;
$ B- k2 S! b2 Ovar newXDir;
' Z3 `5 O' `1 Avar newYDir;; S4 _- @$ a+ {
% S+ i" e- B$ J; Nfunction initializeBall() {* M3 o" A4 C: u% b3 J) X- ?6 B1 m/ u+ w
if (document.all) {' V- i1 e, J" D* W3 R
xMax = document.body.clientWidth
4 P" N. {1 r& P8 \5 m yMax = document.body.clientHeight
. f5 s3 x+ _5 C4 `9 H document.all("supertext").style.visibility = "visible";& M0 d) n q. X) D* U/ |; q8 L$ D
contentWidth=supertext.offsetWidth+ ~% D. v/ j" q) W& V! z
contentHeight=supertext.offsetHeight
& k! o. a+ ?0 V9 C }+ S: a5 D& G- y7 S1 v3 w2 c; v
else if (document.layers) {( j' m! s8 [! g* |9 @
xMax = window.innerWidth;
& G' b2 R( Y$ o" e- K+ o yMax = window.innerHeight;/ \) w) V! a; f0 L" ^; ]
contentWidth=document.supertext.document.width
* h& X) v; P6 y+ N5 V3 |# j contentHeight=document.supertext.document.height( f- w& s8 z; K* k7 l
document.layers["supertext"].visibility = "show";; H" T c/ E% |& B" |
}3 U- Z. |* c j! s* a1 e! r
setTimeout('moveBall()',400);
6 j( n3 q/ Y" O2 u if (hidetimer!='')& a* a8 m9 [- @. j" m; u
setTimeout("hidetext()",hidetimer)$ S1 Y, N) i9 ^- C/ A5 u, {
}. g' g3 y! x2 A9 V, L0 F* L
' { C2 p: h+ H
function moveBall() {
+ Q. h3 B) p% y3 I" z if (superballRunning == true) {/ F- I# K$ Y0 y! S) H! v2 ?0 e2 o
calculatePosition();2 [" q) x) w3 G
if (document.all) {
, l& C# k4 \/ ]# o4 { document.all("supertext").style.left = xPos + document.body.scrollLeft;
# u# `" X, E- O z% c' v; m7 ^ document.all("supertext").style.top = yPos + document.body.scrollTop;0 O$ ]9 [$ s& G+ T( t
}
6 X w' J$ D, b3 ~/ q( m else if (document.layers) {+ A4 B. t u- @. r5 u6 K- X/ ? Y
document.layers["supertext"].left = xPos + pageXOffset;
' M7 Y) Q8 }/ K* G document.layers["supertext"].top = yPos + pageYOffset;9 z z/ y% n" |/ {$ [7 D' r
}! n$ q3 i1 @6 e4 D2 L% ]& r
animatetext=setTimeout('moveBall()',20);% ~1 j' L0 \. h
}3 A; g$ p+ |, w2 J
}8 p8 p+ T; E3 L: R! N" h; `
5 Z5 I a$ F5 d$ b5 T2 B$ c
function calculatePosition() {
/ `6 X# v& h A if (xDir == "right") {
2 m2 Z( B# d* D+ b! F if (xPos > (xMax - contentWidth - BallSpeed)) {! `/ C, D6 p/ ]1 g+ K
xDir = "left";5 e! _! A6 @4 W) p
}
+ D& r; M T6 l Q }6 E) y8 g+ M6 L, b; [: p/ ? j
else if (xDir == "left") {
, O! A5 r4 {) i1 T* V if (xPos < (0 + BallSpeed)) {
4 l9 ~6 ~+ P7 Q- J0 `1 J9 W xDir = "right";. Z1 S5 {$ B( G1 m* C
}2 M4 x, h0 q$ K, ?
}
0 [! H; C! y6 ]$ W; _ if (yDir == "down") {& D6 g: ] z t' F- F
if (yPos > (yMax - contentHeight - BallSpeed)) { o5 X9 Q: r/ o7 l7 Y; n
yDir = "up";
7 h1 p- E! u) F( x }+ b" t* Z- B& G1 U$ X3 a, g z
}
; ]7 j' @7 P3 b5 D! P' r else if (yDir == "up") {1 Q, H' X5 w) J* ^( f
if (yPos < (0 + BallSpeed)) {
8 ~% a5 a# z w0 o0 G yDir = "down";
# j( u K5 |" C3 r0 x7 P: v }
' E$ r6 u; _. ^ }" e% z) H$ k/ [! Q* c
if (xDir == "right") {( P3 j6 C3 Y4 P0 c5 _$ O) s
xPos = xPos + BallSpeed;
! R/ e( N$ f" j2 z0 g: B }' z6 B% Q# Z- _& q: F; E9 c0 v
else if (xDir == "left") {% y# P, G5 a! ^
xPos = xPos - BallSpeed;
! _( a6 W1 _: a1 S% B7 T# B }5 I5 i8 ~$ V. o3 L" l& Q2 u
else {, g1 ]" W+ n2 T! a* O" q
xPos = xPos;
7 h! n. A, K4 Q1 m6 @ }
! n& f& @: r. A% L9 W if (yDir == "down") {: H' K9 I, o( K# b6 G
yPos = yPos + BallSpeed;
0 e" `' T7 V& \0 [ }
& b. ]5 D& k# v! |. w else if (yDir == "up") {) M! P. B1 s u" C/ [; r* w1 W/ b
yPos = yPos - BallSpeed;1 B6 [/ ~ O( u7 @" T4 H3 s' Z0 |- a4 }
}
' z. `3 S1 w8 B: d4 v else {
, O9 n5 i- q3 d8 t3 r yPos = yPos;3 d# v7 G6 |/ v6 K8 O+ l
}
. g8 v! {+ ^( c- L5 y" K/ A }2 K8 S7 V9 Q# e! ^- K2 i& \
# S6 n$ {; {: a) n# r
function hidetext(){" ~$ U6 ?" c% `9 A5 E9 [
if (document.all)$ \& ~) j) v' } _5 W3 B: W: W6 b- O
supertext.style.visibility="hidden"- k6 V+ B" f; \2 E; a0 w7 y7 Q
else if (document.layers)1 C; s) i, p# j1 g1 i/ y3 @' O
document.supertext.visibility="hide"/ ]2 R, k2 u, K( ^6 F
clearTimeout(animatetext)# C: D+ b2 H) s) q
}. x$ C" Y9 d( e0 ?3 x% d
( U X8 O& { o( ^/ u0 {: J
if (document.all||document.layers){
: A% i8 x0 l# f) b& B: ddocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
o( @' ^6 B* H' q, Mwindow.onload = initializeBall;
# L a3 W& w7 d4 K! z. qwindow.onresize = new Function("window.location.reload()");
4 R5 A; h$ d: K9 D}
' Q5 M* a% }5 I2 T" U$ F% q; ~- f2 H
</script> |
|