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

|
网页之不断弹射的文字-特效
<style type="text/css">
, C! X% e3 O/ I+ r" k#supertext {
& O* E8 y; @0 _- Bposition:absolute;
# r( e3 I& e9 { e. _left:0;- |# x) [8 R' j' x4 N+ Y" Y
top:0;
- L. g5 s6 ?8 Tvisibility:hide;4 C) W: C2 `% d
visibility:hidden;
# x: V w, {4 ]8 d2 ]7 P+ p& E}9 D$ e/ |! x, m3 ?% B, O6 J
</style>
" f7 ?& s3 Y5 V' D+ _ [. W' o. z<script language="JavaScript1.2">
u2 q# S. P }* J- n# H% a% u- i<!-- 改变下的字体的大小。颜色-->, c) a4 F& p% f$ p
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'* V5 l, a" f c: Y I
var hidetimer='';
@. R* |& ~# l7 X& l: J3 A5 U<!-- 改变下的弹跳速度-->7 X0 o+ j7 m' b/ m8 _
var BallSpeed = 20;
9 C: z: w/ a$ I/ P w. Wvar contentWidth;2 \* ]0 |& y8 y6 F/ M$ ~
var contentHeight;
1 G) \$ ]7 X- h! x0 N% K+ }var maxBallSpeed = 50;
1 J; g! F0 A/ d: }/ I: |: {8 A; h- H9 N F) h
) Z$ d! O' k! e; e
var xMax;
" ?% \2 P: D6 F& ?var yMax;
X- u' M J, e2 `8 X! avar xPos = 0;
2 u' M; \! m0 V1 O. ^! z0 nvar yPos = 0;
; d& w; d: |$ U- h+ Pvar xDir = 'right';
$ M) ]1 L: V4 i; k) r Ovar yDir = 'down';
6 ^6 M# X* F' z7 rvar superballRunning = true;
, |" g' `7 z ?" hvar tempBallSpeed;
* A4 d( @& {% G1 ^0 Z& O3 yvar currentBallSrc;: ]5 @$ a' h f6 {/ [# d+ Q9 u. h
var newXDir;
: l" l1 O8 x9 o& _& N5 ~1 cvar newYDir;
, x5 A4 B- n% q2 O( c: z1 q+ }! c/ s, E l' @
function initializeBall() {
0 Y2 T9 e' E, w# E) X Z% y' x, N if (document.all) {- }7 n5 \7 R+ P7 F; E
xMax = document.body.clientWidth6 |" `+ o+ n& u/ X- O. {, v' L
yMax = document.body.clientHeight6 u5 A. Z. S" y% ~. M, i( y2 j$ D7 C
document.all("supertext").style.visibility = "visible";
- L, X, r8 j6 ?4 w, S contentWidth=supertext.offsetWidth2 ]7 d2 S9 N& [$ H0 R
contentHeight=supertext.offsetHeight0 R o. o# Y/ ?: J9 t/ }7 J
}
' U: I _' M& A5 k. C: S3 u else if (document.layers) {
# g; [# o/ g4 t: Q2 @ xMax = window.innerWidth;
: G% y; E' v+ W8 _9 u yMax = window.innerHeight;
; b( z: K! ^/ p W1 U contentWidth=document.supertext.document.width
) X4 z, H( _5 Z2 C contentHeight=document.supertext.document.height, l8 }$ [1 p/ d
document.layers["supertext"].visibility = "show";1 ?# s& g$ q5 I+ v
}, e* y' ?: P4 c# g. ^
setTimeout('moveBall()',400);( K4 G. S7 g1 e; S3 j- n% S
if (hidetimer!=''). K0 c1 M& m( E
setTimeout("hidetext()",hidetimer)
% Y1 h, Y# T1 ?! L2 C; U }: }6 ?( G2 F% t+ _* s% r
1 s1 u9 F7 H. K7 o9 `& f* ifunction moveBall() {9 d5 l8 q9 w- U2 a( g
if (superballRunning == true) {
# V" m4 q l4 L& [* w& o. P6 ^; ` calculatePosition();7 G( {% W. P; F2 u4 J
if (document.all) {
/ g& W: r; r5 D$ o( ^! w2 D document.all("supertext").style.left = xPos + document.body.scrollLeft;
5 ^; s, f6 i# U3 ]; t: ` document.all("supertext").style.top = yPos + document.body.scrollTop;
2 s4 A s2 _5 R3 Y& [+ [9 T }
( F, u# I5 r' w A8 z( J else if (document.layers) {! {2 z2 @3 j+ r2 d9 @5 W
document.layers["supertext"].left = xPos + pageXOffset;
9 T8 V& k# Y0 b$ f document.layers["supertext"].top = yPos + pageYOffset;
8 Z5 q) J( G& u$ T/ b1 ^% J } N2 W( U% K6 E5 ?6 J/ l
animatetext=setTimeout('moveBall()',20);4 R# Q( n5 w/ H0 n
}
0 k" s3 E/ _3 v; [- A- n }
5 l# v1 U& E- o' I5 [3 W2 F3 o
2 o. H0 j* }' Q/ D+ Cfunction calculatePosition() {- s3 I6 T6 y2 Z f
if (xDir == "right") {
, V( j! y+ u( z& d1 x if (xPos > (xMax - contentWidth - BallSpeed)) {3 ~, B1 r7 j; k' h) I, T$ Y% y
xDir = "left";
8 V( {) u: R" G4 B6 t* Q }8 h) S5 i& x$ W0 C; X$ j
}
0 d6 i0 W! }1 e+ j' v! K* @$ p) W else if (xDir == "left") {2 z( W' w* Y" t
if (xPos < (0 + BallSpeed)) {
1 P' N/ B1 q/ r B1 c; z4 Z xDir = "right";
. _$ G& Y# w9 C, ^ }
/ p: H+ \2 {( j0 D$ u, p% d }
! X6 t$ O6 H9 W if (yDir == "down") {0 _! |4 z' Y* a! H! ?
if (yPos > (yMax - contentHeight - BallSpeed)) {
0 O& `$ ^' Y; v. c yDir = "up";1 D2 h @( \' s: w0 |1 D3 Q N
}
" R1 ^4 v0 E6 i; v1 m7 |) n9 y: V }
# ]4 |: o! ~, n! ]/ y: u8 i else if (yDir == "up") {" A3 F6 A2 N! i% ?4 _
if (yPos < (0 + BallSpeed)) {
+ K6 I" Y# B( T$ h! ?- J yDir = "down";
1 L- [! b* T' Z }" F. `* w. Q# O8 S
}
G$ }7 j2 `1 d+ v6 { if (xDir == "right") {
; L. [. \! k2 }9 C( h( C xPos = xPos + BallSpeed; Q1 B+ ^ K; Z, H) s! F v* N7 F: @
}* X/ i9 h! m, K9 w
else if (xDir == "left") {
& Z" v7 R! q3 K/ U xPos = xPos - BallSpeed;
# M. Q3 Y% C: L& F9 G8 E }
5 I5 \! a( ?" W! x- g- T else {
6 |' c+ X, J- q" m xPos = xPos;
3 X- p% ?9 V6 s% x; b4 y4 R+ p* o }0 s# R+ I, f6 ^3 X4 b3 q3 l1 G
if (yDir == "down") {
! d, r; W @: Z2 _9 a6 c; { yPos = yPos + BallSpeed;* B* ]! x8 l' n1 ?
}
& o1 p7 _& j) i3 h7 R" w0 ?% V0 ^ else if (yDir == "up") {
+ |0 J" L! U( C' |$ O yPos = yPos - BallSpeed;
) [! M7 ^8 N; _+ e$ r7 B }
- f+ H! C8 d; z( ]9 ]# b1 K7 ^9 { else {
- }2 y3 S) y8 Z& U6 S1 Z5 C' M yPos = yPos;+ v! N! M2 h. [. A. [1 O
}& s: \( V+ D' X; p
}1 S0 {* {3 m/ y7 V; i
) Q, G: G' U$ F6 E
function hidetext(){
% o' w- k4 e: }if (document.all)
* v! X: `% D3 F1 S5 |4 Lsupertext.style.visibility="hidden"
9 d5 j% w& y: U9 T5 U0 g I3 Yelse if (document.layers)) [5 T% w# W9 z) d2 Z2 \
document.supertext.visibility="hide"
$ I5 q/ G5 `# ^8 j* kclearTimeout(animatetext)0 H+ E& t5 n. @# W% j
}
! E- B. Q8 { O) e" I0 E7 z( j/ X) F# v" c' b
if (document.all||document.layers){5 ? a; y5 x# x" Y8 V; j
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
q& T) X" D9 t( @0 L; Twindow.onload = initializeBall;
/ ~& i U" l$ L/ S' E8 [window.onresize = new Function("window.location.reload()");
/ i6 V t3 I# L# N- H2 r}
! s8 d/ X0 n' J0 ^: R J
* y! X- T6 f" W</script> |
|