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

|
网页之不断弹射的文字-特效
<style type="text/css">
, H* R& @8 j' R#supertext {- `, F+ M3 s/ P8 E: o
position:absolute;
6 a! i$ z# ^$ z' cleft:0;$ z# T- u: J* ^' A, ^9 `" _
top:0;8 ]8 |) m& s% x) t& `& E% {+ b
visibility:hide;' r, f' Z2 M! Q) V
visibility:hidden;
# d0 m2 n0 j+ |% f* L5 k8 D9 U0 S}
: ?1 k! }3 Y& E1 @8 `</style>
! F4 e- G" x3 w5 A; R* r" d<script language="JavaScript1.2">
; p/ g& G4 x' ` m<!-- 改变下的字体的大小。颜色-->
. }+ i+ w4 ?' O/ w# t# s- ]var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ o E# e1 O) N' E3 Y. X
var hidetimer='';- z( I1 {0 V* E4 g: E% z1 ?! ~
<!-- 改变下的弹跳速度-->7 A) b5 l% [$ X' ?4 T$ x
var BallSpeed = 20;
! U7 t- W2 g4 u! Z# x7 |var contentWidth;: Z1 b* |" h5 G$ Y* R
var contentHeight;
3 x/ L: V( S( W% u6 Ivar maxBallSpeed = 50;
, T, @4 T0 S' u) S9 n5 L1 q4 ^2 b& A0 _4 q' ]( z
$ |% P- X, U' u( A8 Z% W; M0 H! w
var xMax;( {. C, v& N, G& \/ K* i2 N7 b9 D# Z
var yMax;
( U: N7 N" M& K: U+ ]var xPos = 0;
. |% C) A' L9 P- {% Jvar yPos = 0;
( y, Y! K, |( S, T% Lvar xDir = 'right';
- i8 l; W$ K) N8 i$ t, Tvar yDir = 'down';# D } m/ x* K, a; q* c
var superballRunning = true;/ k4 Q& K3 ?$ ] P0 @5 ^& S
var tempBallSpeed;7 W+ U/ D9 e) ^+ Q
var currentBallSrc;
6 m6 n2 J O; N' Zvar newXDir;& h. K" f6 ?5 v" D: |$ {
var newYDir;
0 h( ^% K& u# z e2 O
' Y% M0 ~" X$ Q" S* s9 u u( ^2 [$ \function initializeBall() {
& q3 p* K( r* |" U* _/ g0 u if (document.all) {+ g' h- H0 G, ?
xMax = document.body.clientWidth. p8 g# D/ C- [. {7 X- p
yMax = document.body.clientHeight
& _, H2 k# N! o' T8 @2 A- ^+ v: A9 J document.all("supertext").style.visibility = "visible";( d" b+ ^$ Z" u
contentWidth=supertext.offsetWidth
) V) T$ @' q6 c6 K0 |- R: H# K contentHeight=supertext.offsetHeight2 p' p5 J1 T. h- M- d
}
) M0 r: W" A' {5 `% o, X else if (document.layers) {
: w0 W9 ]: @+ O8 U7 D. h0 w xMax = window.innerWidth;
0 _( j) M- ^; ?6 q& Y) k3 {' K; T7 c. G yMax = window.innerHeight;
5 C% O s' G2 K8 C contentWidth=document.supertext.document.width
% y2 ~) j: w1 L4 P8 b* c contentHeight=document.supertext.document.height) y, f9 d; }: d
document.layers["supertext"].visibility = "show";
# E1 q/ S. v: v- p }$ p/ _! u, K' r2 ~$ A
setTimeout('moveBall()',400);
8 B, O+ A* [# G1 C if (hidetimer!='')
' ~# r* m0 a' U3 f setTimeout("hidetext()",hidetimer)
9 Q4 y2 p; V" [# N. O- i }$ Y0 B/ \& M( c# Q& a/ f# `
+ U9 S1 Y: i7 B# n4 i6 C8 a
function moveBall() {, U& `5 E5 r+ Z. ?
if (superballRunning == true) {
t9 x+ s7 u: }/ T& B calculatePosition();
7 C4 a7 T* v+ B" r2 { if (document.all) {
7 ^1 A0 U; T; G8 E+ b. Q e0 x" F: E( o document.all("supertext").style.left = xPos + document.body.scrollLeft;
L- i2 V) i9 k* L5 y$ N$ ` document.all("supertext").style.top = yPos + document.body.scrollTop;
+ G; z9 t; ^# O# ~( T3 }, e }6 r: d- g& H E, `8 G
else if (document.layers) {
. P; [# W3 o& D$ I( u2 y/ n document.layers["supertext"].left = xPos + pageXOffset;# B, O6 H+ ]- T( c, L [
document.layers["supertext"].top = yPos + pageYOffset;- x4 H5 k7 \6 k1 W5 A" h
}! G' V, ]9 e( c* R( S! L5 }; }$ E
animatetext=setTimeout('moveBall()',20);
3 a% X2 u8 B1 m$ A }, U V& A* Y! {: x# H. _6 M
}
% Y- S6 _9 ]/ t$ C3 c
2 L$ b. G/ c4 y/ v" |8 Y/ h/ _function calculatePosition() {
- j! ?% J! y: e9 k1 t if (xDir == "right") {/ G- ^& y0 b7 M; [
if (xPos > (xMax - contentWidth - BallSpeed)) {
( Y0 O& t" h, D) m$ Z+ Y5 w xDir = "left";
! z9 ^9 K+ L# b/ J9 x }/ j) H$ P5 M) R0 L! Q
}/ D9 ^$ {8 g, Q8 `! O3 b
else if (xDir == "left") {' r4 ~" C: V6 m
if (xPos < (0 + BallSpeed)) {
" U) O; k- ]7 o" M }8 R xDir = "right";* C+ ?; A/ L l# a5 F6 v8 M8 V+ F
}. D$ ?) P+ n$ [
}
% W- {: }; L& l: |1 C B1 I if (yDir == "down") {
r+ R! o8 q0 G3 ~* F, C if (yPos > (yMax - contentHeight - BallSpeed)) {
+ t5 A: Q' b4 s yDir = "up";( f! ]& D0 o/ D+ x0 R
}# K# H4 r, ]: _
}1 q6 ~; s+ E* O9 c( z( R$ n
else if (yDir == "up") {0 S: Y, x$ @, b- f/ n X
if (yPos < (0 + BallSpeed)) {
1 k2 t$ P3 d" M& o! e yDir = "down";
. P* c& r- u$ Z# S/ @ { }) w N8 z; j7 q# K
}( q3 d( t3 R1 _5 `$ k
if (xDir == "right") {
3 b. k9 r' |' [2 |5 T; L xPos = xPos + BallSpeed;
0 b6 c% g. ]# q }
7 X" V2 C" f' W8 ^0 s, D6 M; U else if (xDir == "left") {2 o# `: J9 w# f5 ?2 h+ N6 _3 t' \
xPos = xPos - BallSpeed;& X E2 C: S/ ?; m) Q: N0 @
}$ w) o. `5 k4 @! i- ]
else {( U3 h" l8 Q( ^8 I
xPos = xPos;
, z& o3 G. u" z$ k7 `( X1 r }. c& [' e# d9 ^; [* L: E
if (yDir == "down") {% o. p2 Z' b: G7 |4 C8 a
yPos = yPos + BallSpeed;
4 o4 M& ]* {( } }
- X% f0 a' C5 D9 O3 k else if (yDir == "up") {* l# ~6 O* S) e V% x3 [8 }9 u
yPos = yPos - BallSpeed;
! d' K# E' F3 ~ }
) w9 W3 J# ] J0 D' [ else {
6 n# X& x! ]- }' @4 V0 N9 S- k yPos = yPos;; Y5 c& C- D3 |
}
. l7 u9 |: Z8 S( h8 k' r1 c+ ^& d }7 ?3 Q6 y+ s2 ]/ Q$ T# _% H% ^
7 y3 ]* O& a7 w1 @
function hidetext(){4 f0 B# Q" w1 G/ {! j
if (document.all)
# S R3 I+ \2 L K( g2 Lsupertext.style.visibility="hidden"
5 k9 C, V6 X2 ]6 \2 P! h7 q( Celse if (document.layers)
& W- ?8 k+ W2 O* R! @- `document.supertext.visibility="hide"
( n% c, m7 f5 A( wclearTimeout(animatetext)
) \, i+ v6 U$ z4 h* {" K}
! y" b" u) Q4 l I1 P$ G3 N
8 K- u% f1 p6 r& Z" _if (document.all||document.layers){
( f4 d8 a" `- N0 N$ wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 _7 H( k& D/ E' e5 g& X0 y8 V5 U, bwindow.onload = initializeBall;
$ l' c1 q1 b6 e ^0 k: swindow.onresize = new Function("window.location.reload()");6 s" @2 v# |/ e3 H) e
}6 E& @- j- M, ~1 a" L5 R q+ g! M
2 t& M4 T; M" F7 t
</script> |
|