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

|
网页之不断弹射的文字-特效
<style type="text/css">
: i! }: C5 R& \( F* ~#supertext {* n/ |: |6 T* L4 N/ M8 r
position:absolute;
3 T0 B) U3 x1 m' J' C( Kleft:0;
' Q' l8 B) O3 o1 D; D: u3 `top:0;1 `5 L/ s/ B( y# m
visibility:hide;
9 Z, ^/ v5 J" d0 _( l: v v9 zvisibility:hidden;& u5 I ?# t& m
}8 s. Z4 o4 r, \- w8 p G; H
</style>4 S6 W* A* e% K( I5 o
<script language="JavaScript1.2">
" {1 @5 X& U$ u" _( L5 D<!-- 改变下的字体的大小。颜色-->2 G" I" }; W8 s& w5 x3 W
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', b6 E! B: [( T6 n) d: A: o
var hidetimer='';+ W c$ Z& \# H4 Q
<!-- 改变下的弹跳速度-->
3 j" j- | f6 b- y; jvar BallSpeed = 20;
; r+ E! |2 R# Z$ ]var contentWidth;. J: K/ ~ K& j6 ?" _
var contentHeight;7 K8 a: p$ ?4 o/ M( W6 f( m: A
var maxBallSpeed = 50;
. N6 f$ c, E! o
1 T5 z- G( `: z: ^4 a
/ F3 U1 f# Q' ~var xMax;
& e1 q9 y2 K c: ~var yMax;
9 ?( @1 e4 ~' k2 R' ^+ [7 j% Mvar xPos = 0; A$ W8 v8 n$ J+ g0 W: p5 ?% B
var yPos = 0;
. C, ~% J, z4 U, v! Ovar xDir = 'right';; t+ @" O2 d6 A" T( _4 H' g
var yDir = 'down';
% _- [$ ~1 I: _3 E6 Lvar superballRunning = true;
9 W' g7 \' Q& Y0 D! Y( hvar tempBallSpeed;' p- L$ a9 |2 N+ t
var currentBallSrc;9 ~4 k+ L! g5 H4 \; V. z( ]
var newXDir;+ @+ ]9 r1 E" H9 Y
var newYDir;' x: _' B+ W4 d
. }6 H, I' L% @2 z
function initializeBall() {
8 x7 C, q( L+ f9 D( _ if (document.all) {
1 P) N) z0 H& c+ W xMax = document.body.clientWidth
# @0 E+ m( H# F yMax = document.body.clientHeight, a! t7 Z$ Q) r! a& k; E
document.all("supertext").style.visibility = "visible";
5 V, b. n2 n. W contentWidth=supertext.offsetWidth8 _ J$ I& g) z9 A2 E! t2 L+ Q1 w
contentHeight=supertext.offsetHeight: D3 v: w6 Q" V) o1 H
}' I" Z. o5 [& a" k B/ `
else if (document.layers) {
1 T3 J" L- b. o c4 v0 G& }+ r, \; k xMax = window.innerWidth;
: w* y5 d2 w Q5 C8 R0 ^ S yMax = window.innerHeight;9 b o% O6 u% n+ R- h
contentWidth=document.supertext.document.width0 `9 d0 S6 ?3 x' Z; P' a
contentHeight=document.supertext.document.height
' F/ y4 \# i F document.layers["supertext"].visibility = "show";
: t1 M. i/ S0 B }
1 L- `/ {" L! @6 u3 e9 C setTimeout('moveBall()',400);6 P d6 d+ Q+ M& G; ~* l
if (hidetimer!='')
0 D7 J% d1 m' e+ Z% L% l1 o/ U5 v S setTimeout("hidetext()",hidetimer)
T' f8 L! n$ o! ]# | }
0 q8 o" I- s9 Z; r4 G' j7 ]5 h p, L+ d# t5 c: g
function moveBall() {
7 a9 n" m9 n, _) e V8 ?! F if (superballRunning == true) {
( f9 w8 U' J F1 Z+ S* _/ ` calculatePosition();
' [( E. V8 }9 d2 a; | if (document.all) {
+ J D+ M& h5 @7 E# y1 \ document.all("supertext").style.left = xPos + document.body.scrollLeft;3 h$ b D0 q. a
document.all("supertext").style.top = yPos + document.body.scrollTop;
1 R( p Z% B2 H+ i. r2 \: u0 [2 F }
0 M6 W& \9 R' L6 q else if (document.layers) {: W% b8 ~" ?. Y- q J1 M1 X. i
document.layers["supertext"].left = xPos + pageXOffset;0 ]8 \2 [& q9 h y) |( o
document.layers["supertext"].top = yPos + pageYOffset;$ D( [$ Y; b V
}8 `: N+ e" x. w0 X) i# e
animatetext=setTimeout('moveBall()',20);& g0 t$ ~- Q- u
}
+ h: s, W2 L: @. x }
2 }- l) b6 S3 N( F" f; [! m+ Q: ^, u' X6 ~4 q, }
function calculatePosition() {" u3 L( q$ @4 t4 T) h4 F' ?
if (xDir == "right") {
8 _. |) b4 }& R6 [ if (xPos > (xMax - contentWidth - BallSpeed)) {
& ]6 l" P8 i3 h: o7 i* ` xDir = "left";2 _8 O( t2 ?1 v( m. `
}
: E& `3 @. v* U; ]2 I5 N; n( c }# D! A: Y c- r6 }
else if (xDir == "left") {0 u; K8 Q" g, H# N z" P& ^
if (xPos < (0 + BallSpeed)) {
( T/ N+ i" T% O xDir = "right";" _) U h w, [+ x! T7 ]6 s! U
}/ o6 `1 C: J/ x2 U3 X; w3 z
}
$ S7 O7 K4 _. R) ^ if (yDir == "down") {
& g* A; E% V0 C$ p7 L if (yPos > (yMax - contentHeight - BallSpeed)) {" E8 o7 s% U: d8 j0 ?) c# u
yDir = "up";" V2 h' z' M3 N8 Z( F1 b
}$ f9 M3 d) M1 \% v2 G
}
5 B( W" A' b2 r! O( c, E" J else if (yDir == "up") {6 S7 l4 g: G, I+ u5 b# Q
if (yPos < (0 + BallSpeed)) {
$ z5 ~9 }; Q, h$ v) D+ }, W, a yDir = "down";$ g$ `; v a4 Z7 A2 f
}6 V: M% M4 P$ e( n6 |
}
# o- _; W6 Z" t# E0 R if (xDir == "right") {
, N) C; a- D/ j' [' { xPos = xPos + BallSpeed;( z% o B+ W( h& G$ o) ^% R+ ~
}
! N6 N* ?* e' T" x0 Z( X" \; N else if (xDir == "left") {
2 t8 S/ Z" I. } t( i- Y# [ xPos = xPos - BallSpeed;- r2 R& J. v7 r6 u
}9 J9 |$ U$ u' u9 V2 C
else {
1 ^. I# u1 i+ a) @: L* a7 S; V# _ xPos = xPos;
7 x6 C" q% \. ?& `: ^7 o3 v5 k o }
; h7 `5 q7 j. P& O, r1 @( ` if (yDir == "down") {; v: M5 U1 Q% I3 a% H1 N5 x% `$ ~6 I
yPos = yPos + BallSpeed;* O: `; B4 E& H" u# s
}
7 a: w4 E" @7 Q8 ^' h else if (yDir == "up") {" @ Z% n6 X' T* z4 F
yPos = yPos - BallSpeed;
7 t/ s% t S: X# V- F4 X }
* n& P n& N5 |4 {7 L6 H1 n else {9 P% X% w$ ^: ~; k4 h+ k
yPos = yPos;% _% E3 I7 U" J3 z2 s0 n* G5 w# m z
}
7 ?; ~$ X h% u2 ? }
/ f2 e( ?2 [" n2 i' }9 z. p7 p6 P" n0 n2 Q8 d% h
function hidetext(){# W, H% `* X3 I+ x+ W$ p: z
if (document.all)
- m0 j. _1 d, P4 ~supertext.style.visibility="hidden"& Q4 V2 e( t: T @+ n
else if (document.layers)
. F2 x4 e) s) |6 wdocument.supertext.visibility="hide"! a" V* r! Q# S8 M
clearTimeout(animatetext)
) M0 Q' R1 [ ?, k}
4 b# A' F8 L" q& Q5 V, Q1 \# V/ R w. b( p5 R# t6 g' u) ?
if (document.all||document.layers){
5 Z" z& z. M5 d( Ndocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 u- o4 F# ^9 E$ x1 ?4 l+ x1 b
window.onload = initializeBall;, ^! x, u5 Q2 g Z
window.onresize = new Function("window.location.reload()");1 s' g* J! o# }% V
}
, t- m2 E l/ \$ g- x5 \
7 N2 M3 U' k- s: P. s; }</script> |
|