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

|
网页之不断弹射的文字-特效
<style type="text/css">
! A7 l8 }7 A! y7 o4 S8 q- G#supertext {3 S' f$ S6 Q) K: |/ O3 `, l1 C
position:absolute;( ^- \! @+ n4 U
left:0;
. m* l* {* e' S7 Xtop:0;8 X& Q9 ?6 A9 G+ T/ z8 k
visibility:hide;7 h" c" \- e4 z, f; u1 O2 X
visibility:hidden;
6 B& G) A( B" J" [ I}
# R# X, r0 r0 u</style>& I# D# m5 w" ]& q2 `8 d: L
<script language="JavaScript1.2">
/ x9 Z; r+ i! M6 ~4 P4 y( \- G<!-- 改变下的字体的大小。颜色-->
' P, F4 Q! `2 h2 s2 I: A! [var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. h- n7 H$ j& ~* _6 [var hidetimer='';
3 r. i5 Q$ C+ _5 p% a6 R<!-- 改变下的弹跳速度-->
, E0 |1 h4 D; ^# ]7 s, ?var BallSpeed = 20;
' |$ N$ O& k5 _1 Gvar contentWidth;
, v6 P1 q a: w) J% {, e" k' bvar contentHeight;
, `, g3 u" D+ H# H' N7 M+ B6 z" ~var maxBallSpeed = 50;$ |# M( G" Z: k5 r0 ~
& f7 k/ @- N1 e0 ~* n
- \ ~8 z. T- X+ E1 S$ a8 d- C: Z/ l
var xMax;6 A8 v. }0 U4 r! @2 g- A
var yMax;! J5 J" F6 w! e1 }: |7 h) t
var xPos = 0;
9 a1 E1 e" ?9 xvar yPos = 0;2 q; P8 q) q( ]# ]6 _
var xDir = 'right';/ I# B% X7 p! d7 W* ?# L6 B
var yDir = 'down';" ?- a# k2 u, j5 \
var superballRunning = true;: z9 r6 \/ ]- H5 ~) `# }
var tempBallSpeed;
. r8 y0 _ m# ?9 L% M/ N* u. pvar currentBallSrc;
. q a, C- ?. W; J- U+ t2 avar newXDir;1 U, ?: F7 r; A( D' M
var newYDir;
& F! E' ?8 y; G w% m0 E Z, x& e% s* C5 N
function initializeBall() {3 @ i6 x, M) J3 n4 [
if (document.all) {) t7 N' U z7 B- G
xMax = document.body.clientWidth2 t4 {, S( ]! Q
yMax = document.body.clientHeight/ c( J% P' U( o! @+ ^* v, C ^7 v
document.all("supertext").style.visibility = "visible";
: U# X' _# A, Z T+ `7 E9 G# P' z contentWidth=supertext.offsetWidth+ V& z3 c M/ O- ^
contentHeight=supertext.offsetHeight
' z) |) Z2 O4 A1 n, [. }2 p }; K" S' U% q7 Z; E! C8 p
else if (document.layers) {1 A* X# o+ D* B2 e/ b4 U
xMax = window.innerWidth;
9 k/ f# @8 u6 B$ j3 C& i4 T* P& A. F yMax = window.innerHeight;7 @- Q+ b/ t; W C
contentWidth=document.supertext.document.width
7 G! q- Z v' h2 d* j contentHeight=document.supertext.document.height
+ h! I' |) h/ @* O! I# o, O document.layers["supertext"].visibility = "show";
$ V( B( T1 x& G9 F% j* e }* @2 G. d: G( o- _
setTimeout('moveBall()',400);' ?# M3 o; z a1 e
if (hidetimer!='')3 X3 o+ i5 M& x: d) N- G* }
setTimeout("hidetext()",hidetimer)
% d1 M+ w7 Q" q3 g: S l }
; i1 f. d( _3 w9 ]
" X0 h% J! T+ |: Nfunction moveBall() {. h- H8 _- c$ `0 B
if (superballRunning == true) { c8 u! \+ `$ W6 b: a
calculatePosition(); y( \% D- c& _
if (document.all) {
* h: W* R! r- I. K/ E L document.all("supertext").style.left = xPos + document.body.scrollLeft;# V9 j' _% d: h7 H+ }3 n3 b
document.all("supertext").style.top = yPos + document.body.scrollTop;9 o+ s& F% b% H) B1 y
}
' X6 I" D9 Y9 e4 S2 b. G7 v else if (document.layers) {+ g3 y5 [' |1 t- q P6 Y
document.layers["supertext"].left = xPos + pageXOffset; O. c- S6 y/ _, b3 O
document.layers["supertext"].top = yPos + pageYOffset;/ {' w1 N" w! I, s7 s4 H0 W6 B
}3 ~5 ?5 o: H+ A7 O4 [
animatetext=setTimeout('moveBall()',20);
6 ^% l/ w. e* ~& B& o! g% V0 } }" M: O2 z/ `+ T0 U
}
8 ?1 |! L% ]" o9 f7 l% @! o+ r
8 }6 a2 E8 \' W) r) G" Z, Afunction calculatePosition() {( ?* e. p# t% c/ l: I
if (xDir == "right") {$ E1 W; G9 p0 I: I- p/ n
if (xPos > (xMax - contentWidth - BallSpeed)) {7 R$ t, @ i2 ?4 U/ [4 C+ v
xDir = "left";
( t# ~2 \6 {1 `3 b, K1 g* I }
7 l7 C/ ~: ^) q( Y! ], |( \, ^ }1 W- B6 N7 X+ `) ~ Z
else if (xDir == "left") {0 H+ ~ _; z7 ^" ~! v7 x' h3 J
if (xPos < (0 + BallSpeed)) {
6 B& x4 a: D8 Y' L. _ xDir = "right";' f0 C* s5 |7 A" e+ Q; D
}) J; m5 s9 B& R: A- y) ?
}
- P2 ~5 l0 d/ [; L- V% f# }& k if (yDir == "down") {6 [3 i& B4 T$ x [' u- |: C
if (yPos > (yMax - contentHeight - BallSpeed)) {
8 E" b7 O0 i3 d! a: T yDir = "up";
, M3 Q+ ~( v* W9 e1 I }
3 f; ~7 P; e/ X) X# e }. _9 @/ K$ `4 Y @% |# q
else if (yDir == "up") {; @- _2 y3 s2 F; \( o5 B% |5 \
if (yPos < (0 + BallSpeed)) {
' @8 \' r2 ?! ]4 Y6 R( g& w yDir = "down";
, Q! {' _) k8 i. {7 W7 n! @ }3 w/ T8 ~3 `( w0 ]$ z( K
}
$ {8 y, K# O1 O9 {# U6 l if (xDir == "right") {
% N* K' C* k+ ~; A3 Z7 w, z6 T xPos = xPos + BallSpeed;
# C' |. n) l+ o1 O- v: U }
4 g' O5 m# Z6 h else if (xDir == "left") {( C* z1 o7 Q5 {, }- n
xPos = xPos - BallSpeed;
1 M! H2 d8 D5 x6 ~0 F' N9 d& \ }
% ?! q$ q: a& y0 x- c9 W else { y4 T+ Y8 c! m. _/ C' A. R
xPos = xPos;9 r2 _' e/ T( e& H
}: @& Q [- `2 Y
if (yDir == "down") {
* ]5 K$ _$ w( s5 R; W! a# n- W2 k7 ` yPos = yPos + BallSpeed;
3 d8 x' X% M) E$ _ }5 h4 B2 N! a, i/ F
else if (yDir == "up") {
, a9 B/ M# q) l" q! o- g9 {, ] yPos = yPos - BallSpeed;# c T5 a9 a1 v, n6 [
}
; E1 g% b* g: H) B else {
5 {( m& n* B% k4 f yPos = yPos;
" C4 N$ Q, w8 s+ m }
. T" k) t6 N, z! H# v/ U. ? }% n2 e( K& _) o
! V! z% L% z! }+ Wfunction hidetext(){. A0 x; E2 _* Z
if (document.all)
0 q& X4 h) q8 x- ~8 A# `8 Ksupertext.style.visibility="hidden"
( Q/ y( V* L, ^2 n$ k- @else if (document.layers)
% Y5 W0 D3 ]9 b: o3 d2 u( zdocument.supertext.visibility="hide"
) |. b* w1 R5 y' d* uclearTimeout(animatetext) i6 h Z0 b- c# X+ g B
}& U* S: W2 i+ S% l3 ]% i
- j8 d( j5 k4 t. ?! k
if (document.all||document.layers){
Y6 `% _9 h" D3 e( a( O' ?# F" A6 _3 n' idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
+ m3 ^. {7 ?/ V5 ?/ j- fwindow.onload = initializeBall;; \+ [. S- O* i# ?4 y# M( l
window.onresize = new Function("window.location.reload()");
3 }& O) a9 m5 h; L}
A% G, t) E6 N9 g# i( S9 \1 W! @2 t( E- \( Q9 @# e
</script> |
|