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

|
网页之不断弹射的文字-特效
<style type="text/css">( M% n. X& y" m
#supertext {6 \- {/ M' V# _$ ] C7 C! @
position:absolute;; W2 k* f1 X X6 k2 g; Q
left:0;
! Q1 p3 n: _4 b L) E* xtop:0;" b7 D9 j& S" Y4 |2 M7 f
visibility:hide;% T; K. c2 _' e4 E- `
visibility:hidden;* M1 K/ O7 X, \, T, L8 k
}! G' V+ f$ O3 B; o) b5 w6 n; x
</style>$ b7 Q' Q% q7 u7 u
<script language="JavaScript1.2">3 g6 _/ z5 y2 T! M
<!-- 改变下的字体的大小。颜色-->
9 j! c! x$ r. e# G% Hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
/ Q' Q( c- R2 i6 p+ m- m9 evar hidetimer='';# i* }% L6 z( k- W6 D7 ~
<!-- 改变下的弹跳速度-->) j" X" u- o3 \) U
var BallSpeed = 20;; u& i6 C4 d- X" [6 v' n
var contentWidth;9 `& E& z4 J. d: ?* y! h
var contentHeight;' A8 Z3 e# A7 r
var maxBallSpeed = 50;
- e1 l3 }0 J t ]7 }. ~
: z& q! B9 b3 q/ ^% d+ Y
" U1 s. A- M/ {, H' |var xMax;7 r& [ E1 E8 s5 `6 {; U3 n, u
var yMax;5 k) ?$ z! L3 D# ]. Y3 X1 [% ?
var xPos = 0;- m0 F0 A0 F) B N9 n7 l
var yPos = 0;
) Q( f G" ]: {4 U- i0 G3 Pvar xDir = 'right';
7 j- L) N/ }9 P5 Rvar yDir = 'down';6 u# F) V, e/ r, i% {
var superballRunning = true;3 ]4 f# L! a/ V' q3 u u
var tempBallSpeed;- I/ ?9 k2 ]5 y
var currentBallSrc;4 p! r5 P* ^! ~. \- k. `
var newXDir;# d* P$ _/ B+ O8 q7 T9 [' \: s
var newYDir;+ d5 H; g9 K+ i/ z. i& Z
8 \4 `3 m- H. O4 f4 n: }- |function initializeBall() {# j. p) @3 d& N, ]) _8 X
if (document.all) {$ y' o& |* F4 ]6 X1 [( G
xMax = document.body.clientWidth; `9 J1 b8 t: d. [
yMax = document.body.clientHeight1 _: F4 \- _, \; q: g4 Q' I8 `
document.all("supertext").style.visibility = "visible";/ } G5 c! ?8 k- P7 w2 d8 y4 x
contentWidth=supertext.offsetWidth9 s. ^4 i% B" b2 Z# F% n* S$ y+ u
contentHeight=supertext.offsetHeight* ]: P& G5 W& L! M& ?+ L4 T9 d$ k3 G
}/ x2 _$ u% c7 C. E/ l/ c2 l
else if (document.layers) {8 A6 i: |) ^. V
xMax = window.innerWidth;
: n( }6 U' a" E$ {2 v, d yMax = window.innerHeight;
6 U2 W7 V: Q0 j: s7 b- _5 G contentWidth=document.supertext.document.width
6 X# A3 U, v/ l9 H contentHeight=document.supertext.document.height3 H, K' K; |1 T c7 k1 |
document.layers["supertext"].visibility = "show";$ j/ A% A* O7 P8 j1 Z
}7 x4 d+ G2 L# `. g* v# d
setTimeout('moveBall()',400);
5 p7 x& \" e" U3 x% }# x! ~ if (hidetimer!='')( |0 b& D8 F5 a+ t3 D( v0 T' I
setTimeout("hidetext()",hidetimer)
" m( _& w+ F U7 j5 G } g" U2 @9 H! D: f, Z
% x% Q! I8 r- z3 hfunction moveBall() {7 i0 t2 U1 |% L, |
if (superballRunning == true) {
1 _0 _0 b! K+ E' O0 b calculatePosition();" i6 t! I+ |' W
if (document.all) {
0 j9 P% m4 b; b document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ {/ C5 r; D/ T8 }/ E/ O document.all("supertext").style.top = yPos + document.body.scrollTop;2 c: W1 x: Q; P' F* H
}
0 A" \) e: v8 E# L else if (document.layers) {
( A( Z' i6 S# O: ?/ h* c document.layers["supertext"].left = xPos + pageXOffset;
! g: w" z- J+ h! y document.layers["supertext"].top = yPos + pageYOffset;* T$ t. @5 P- R( c# G, A x6 C. d
}
! D1 U9 u) r8 E$ h: x: h9 n# r( h8 P animatetext=setTimeout('moveBall()',20);
9 ]4 t8 L4 O9 A) j% E }
' ~+ s" c% U c8 q( d }# E& h+ p @/ H0 W! ?4 `% {
$ r2 k8 g; C; D9 Kfunction calculatePosition() {
' j3 b- i2 A: z3 j9 E0 m, O+ Q if (xDir == "right") {
9 E9 y& ^1 y6 H$ h# J1 l if (xPos > (xMax - contentWidth - BallSpeed)) {: k" X: ]: l: D0 R( L; ^. Q* q. v
xDir = "left";
( t$ F! y% U9 e+ ?4 h0 l: `. U }- Z1 I3 b) H1 |8 R! Z5 b. X
}7 ~) U: W9 M8 B& C' a& W
else if (xDir == "left") {2 b7 e1 I( h, |% L* i! f8 J
if (xPos < (0 + BallSpeed)) {6 a- r8 Q% ^4 F9 [8 \/ V
xDir = "right";( C1 C. W4 C9 g: @' ]( g8 S
}
! c8 i' W% D! Y0 A1 m7 [$ _ }- h: ^& Q+ }0 D3 d. Y) g. R
if (yDir == "down") {
$ w! H. n( j C$ E2 ^9 }/ a i if (yPos > (yMax - contentHeight - BallSpeed)) {
3 N% f8 ]) l) L6 I- a U+ R) N& Q yDir = "up";
; A5 j2 u: I- j, C }
# Y( J8 L; N2 { @( [8 Q$ q }# @" j. j; s% I8 G3 w
else if (yDir == "up") {
/ t2 s" b( d/ ?, }) ^) T if (yPos < (0 + BallSpeed)) {
8 [( E3 g2 t4 o' d: @9 o. R' R( R% |" N yDir = "down";
^% l6 ~# C9 Y: r1 f- s }
& F; U* ^- N$ X }8 R6 z) q) @& G' n
if (xDir == "right") {
) _: t7 D# J" Y0 ` xPos = xPos + BallSpeed;
8 A2 x2 u; H4 l }3 o Z6 q. K7 V/ _1 e6 R" L
else if (xDir == "left") {" A! m+ }2 T4 L5 O- j3 q
xPos = xPos - BallSpeed;* q6 w5 v( K% t" N7 {- h
}' `0 w% C- @% @1 A2 a. b
else {5 Z. ^3 p+ F( _2 [- p4 S+ t
xPos = xPos;: K( y9 j6 m/ k9 U5 u0 s- C
}
. O( K+ P# `# Y if (yDir == "down") {
1 Z, u! b, N" a# \& }# I; z- D yPos = yPos + BallSpeed;7 g) ?7 O4 N9 q( {7 N. l. n
}
9 M! R- G( d6 W else if (yDir == "up") {. F0 ]/ f9 V: t4 I; p2 H' M
yPos = yPos - BallSpeed;
; w2 u7 W. r0 A8 s7 K# w }/ s* Z7 a' u9 A' b
else {
( D& U5 s! L' ]( w! d yPos = yPos;
1 x% n3 ~! }" n. r- X }5 X: h8 ?4 [5 b$ m. g! j
}
3 m2 B0 K+ |% s% E8 u8 b" {) h4 l, G: I- n; i' Y; [1 c$ @
function hidetext(){
6 d2 R: x/ A8 |* T- w9 Wif (document.all)
) R$ x5 {6 {5 Rsupertext.style.visibility="hidden"1 ~8 `% A* g: i! Q2 b: m
else if (document.layers)
8 M2 k% s7 n$ i i/ m0 c5 H" cdocument.supertext.visibility="hide"
1 V0 X+ q' c' r5 J. DclearTimeout(animatetext)1 [6 `7 t. U* z8 z+ t0 z4 d$ s" O! L
}, ?' P) p1 g2 [$ B; \4 v
D$ T# H9 I6 {& o1 C% K. d* j% Hif (document.all||document.layers){
" i6 U. T( {) C+ ndocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ }) Z) H# f/ C% Q# f8 J" Lwindow.onload = initializeBall;
' _1 C# D- N8 O; p. Gwindow.onresize = new Function("window.location.reload()");" k' y, o, D& J. x: y- M
}- |/ R8 d2 g1 j* ?" R$ @
V* H# k6 `/ T: ]) f6 W+ A$ G</script> |
|