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

|
网页之不断弹射的文字-特效
<style type="text/css"># ~/ j! }2 J" n- p1 p
#supertext {
! v3 y% @ K6 i& Pposition:absolute;1 ]5 G" G, j0 C9 o4 K- c8 |# f% U& n
left:0;
9 R1 A4 C+ m1 ^0 k' m0 F, A: j8 |top:0;
$ g( }$ [ O, G+ L4 E. \visibility:hide;. s% @* k) J* D; ~2 m
visibility:hidden;3 u7 S# K3 T- r' Y9 l
}
4 N0 |4 K/ E/ q' E+ ^9 F, x</style>
+ \8 s% o( Y1 g: e<script language="JavaScript1.2">
0 O! \4 r& G Z0 S" ]1 R<!-- 改变下的字体的大小。颜色-->
: s4 M) Q0 {. v2 @ @; {* ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 |2 E x- n8 E+ R3 Y/ n c3 J
var hidetimer='';
1 z2 F9 a7 x8 k/ e$ u7 {4 s<!-- 改变下的弹跳速度-->
3 L8 P1 [) s4 N; Evar BallSpeed = 20;
, e/ ?( _1 i) ]: d" _, b% j) yvar contentWidth;
& x, q/ R9 H+ ?; _2 Vvar contentHeight;
9 d0 v: p; m1 Cvar maxBallSpeed = 50;9 T. q7 o+ p- `9 W( N2 P
8 `% m9 Z# P$ o( {& O8 B0 J# \
8 M* a, D7 @; C( `( Nvar xMax;. V! g1 M1 m O9 J1 c% R
var yMax;0 ~* ?. R- f& P( d, }! W1 S
var xPos = 0;
6 a) u, g4 j! Q8 A. T5 \var yPos = 0;
" Q7 b( D7 w) |6 c4 U: j1 Svar xDir = 'right';( O. a) Q q. Q4 G* g
var yDir = 'down';- ~ }0 }& D6 A% ^$ M0 ^8 p
var superballRunning = true;* L( \& U& s0 p& m- {
var tempBallSpeed;
3 P5 v2 K$ u* P8 B9 }var currentBallSrc;
5 d2 v0 S- [$ T5 h- `; \ [' o; ?var newXDir;
1 W v9 y- ?1 I' v1 l5 Wvar newYDir;
* p5 Z; }! D7 s. v; G! q. v/ d% M( o4 f0 w. ?4 d
function initializeBall() {
" F+ F+ F; \4 Y if (document.all) {, t, k, O$ a- ^- j$ R. r- p
xMax = document.body.clientWidth
6 y5 o' b: Z; s1 D9 z5 w" x3 ` yMax = document.body.clientHeight) l8 i! Z8 Z2 }% _
document.all("supertext").style.visibility = "visible";
7 E% a4 U% }/ G3 ]0 @2 s% b contentWidth=supertext.offsetWidth
+ b! F: }) _3 S contentHeight=supertext.offsetHeight
% z4 m5 t/ f: b+ a }
2 ~$ R3 Y d- k) b! c/ e else if (document.layers) {
) e7 R; ]2 Z7 @. g; R W xMax = window.innerWidth;2 g. K$ }: b" K% d0 i$ a! a* O
yMax = window.innerHeight;4 G& L" M& x8 u& F5 y
contentWidth=document.supertext.document.width
+ P* w$ R7 {, b' S# `; Z contentHeight=document.supertext.document.height3 k! h! t4 e+ q% w, ^2 M
document.layers["supertext"].visibility = "show";
; D- V- T; e/ F4 T- Z( `# t }
% x1 k8 G- Z- I* Z setTimeout('moveBall()',400);
; N# v6 M- U, _ if (hidetimer!='')4 V: ?8 [+ f4 Z8 h" E' U$ o0 ]7 q4 m
setTimeout("hidetext()",hidetimer)
v, [( j* L& p$ m }
2 k, H& }2 n' A6 E8 ~
7 K5 O: [' J) v) Z; }. g+ k* \function moveBall() {
5 b4 B8 Q7 p( ?# r( z3 `6 O; X0 v if (superballRunning == true) {) A* F5 S0 x4 ~: j9 J% j( G$ z6 [
calculatePosition();2 b$ F$ `. P! U2 g! ]3 |% Y
if (document.all) {
. J( J; _# I; \9 ^) ~7 g& G document.all("supertext").style.left = xPos + document.body.scrollLeft;
& @- S* P8 f. Y& }. w( g/ ]" R document.all("supertext").style.top = yPos + document.body.scrollTop;3 K5 C( j, z4 L$ x2 \
}
( K* L$ ~7 I' j K9 k. ? else if (document.layers) {# W4 T+ b& D& S) u3 b
document.layers["supertext"].left = xPos + pageXOffset;
* z! r: a" M2 p! Q: u/ V document.layers["supertext"].top = yPos + pageYOffset;: }$ S2 [5 [* D6 N' c% g
}
: {% v% n3 t6 ~) @3 X animatetext=setTimeout('moveBall()',20);
' M1 S( W. p' ?( A }
% R4 C; e8 @0 p* R5 e3 f& P }8 N! N$ |; f( K6 d c7 [! l8 B
4 a& I/ E0 n7 `5 f! S1 z# L1 Nfunction calculatePosition() {3 i* z8 x, V; H( n) o$ h
if (xDir == "right") {
! r9 C8 a$ x2 _6 ~9 \ if (xPos > (xMax - contentWidth - BallSpeed)) {' O- ]; I* Z! W& n$ C7 k4 t
xDir = "left";
6 l' h( Z N: S$ |2 J H2 j }
: e) K# i b; E7 b }8 Y$ [ Q9 b! \, A; u5 d% [4 N/ ]
else if (xDir == "left") {
" A3 J/ ~. s: { if (xPos < (0 + BallSpeed)) {, N) Z4 f! x& T4 c# X1 `
xDir = "right";& c. x- J# y0 D' O9 {' z" T
}4 X+ f' H8 v% p, L
}9 J1 V+ v6 I& m# W; ~
if (yDir == "down") {
2 t. }# m- w! g; [6 | if (yPos > (yMax - contentHeight - BallSpeed)) {. s9 G A# R- {) Z3 w
yDir = "up";7 K6 f) |) R2 h$ _8 ]
}7 f' M/ f1 N$ N0 p" F" o
}
& C0 n8 k9 p2 j) d' e, _ else if (yDir == "up") {- i: t" v% ?$ }( u
if (yPos < (0 + BallSpeed)) {) R) l6 V8 J& {$ R4 H* T' |
yDir = "down";$ U9 b1 N. h$ U) N* V
}; Y/ O1 Q* [& h/ g- V) D6 y- }6 ~
}# q3 x/ n( |# j e- y, C" X
if (xDir == "right") {
5 d( c- _) H, X( p9 h xPos = xPos + BallSpeed;
1 x& ?" o1 P6 m- h/ K }
# d- B% L( {& e( d" x6 d else if (xDir == "left") {
/ Y" i' \# H) Y, Q; o xPos = xPos - BallSpeed;
s; }0 ^# B* [3 { }
3 T) X8 \0 v1 u/ C% p: C else {4 a( N: r. P! W; z a% `& K% S( q
xPos = xPos;- }/ J7 D1 Q. C o0 x
}' A5 V8 o, G: p& u& p
if (yDir == "down") {
8 {$ q# ?3 q' g; a9 |7 U; y yPos = yPos + BallSpeed;
* m8 R: G% f2 v2 ]7 f* Z }
* L* R2 A9 f, h else if (yDir == "up") {1 j6 u& f% E1 n8 m% _4 M; O" g
yPos = yPos - BallSpeed;" O6 }7 r+ U5 P1 c6 d/ ?
}1 Z( H( @% j6 ^
else {
* C" H3 |2 G( t) o yPos = yPos;
$ ^+ v, l! D* K5 W }
# y3 o6 J! D. a+ ^# h, U# R' W* I8 f }* o7 Z, Z0 l3 G9 c. B8 r7 N1 e
8 H: ]* y `' p" C. K* ^- `) C: @function hidetext(){% ^3 \1 _" ^! N! i
if (document.all)
" R* [* `" H) ?* o9 xsupertext.style.visibility="hidden"
' H) c, M" b' ]7 g$ c) F! M/ kelse if (document.layers)$ ~ _# Z( v0 |# t5 \
document.supertext.visibility="hide"
" Y1 s6 J5 B/ d) t- u2 {clearTimeout(animatetext)
8 s. @9 [* A0 c}
" Q* c0 d2 R7 x9 f& q' |1 u
; \9 ~- B( A7 j- b0 y4 S6 @if (document.all||document.layers){9 ^* L( h# s1 B) f: A/ J6 m, L7 B
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 |. n4 y0 Z/ b3 q. i
window.onload = initializeBall;
`% h/ O$ Z# k7 Jwindow.onresize = new Function("window.location.reload()");
" ~6 F! g |* Q, h! R, T9 ?* f}. _/ W: r/ c0 M' F, N
- G3 Y/ f- x8 b7 P</script> |
|