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

|
网页之不断弹射的文字-特效
<style type="text/css">
9 k2 Q3 `/ i! p& g#supertext {2 ~ r& p0 R* _* U
position:absolute;: a4 b7 W$ {) ~: S) G
left:0;9 \. ~% H0 v+ ]
top:0;
$ l+ M6 V) F# E8 w8 l: Vvisibility:hide;" L8 _- l" W+ W/ o& |: M
visibility:hidden;
8 w2 ?4 ~5 }& @3 F P$ p}% |, v0 ]: }8 l
</style>
# m. {3 m9 b1 z3 m0 I<script language="JavaScript1.2">$ G8 x5 U# w1 ?- g4 A/ K& ]% R
<!-- 改变下的字体的大小。颜色-->
- Y3 J/ X1 s( gvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( O U0 b7 ^7 t3 E3 jvar hidetimer='';. W- G$ l8 t; j5 X$ S
<!-- 改变下的弹跳速度-->
9 P/ @0 y( G/ M6 V* u: W- Ovar BallSpeed = 20;
& z6 d; d$ k( ^' S7 t% p" Jvar contentWidth;5 f* ]7 F: Z R1 `: z, g
var contentHeight;
" T# l0 F1 }& ]; c" \- f) U9 ivar maxBallSpeed = 50;( Z ]. X; ~1 `7 Z6 J8 O* R. k+ e8 l
/ W# n7 T( A% Y5 ? m5 g3 |" J" G8 A
! }! u" C1 K& u/ J1 y; ]var xMax; F6 r3 V- U, F0 E, r4 p( X
var yMax;
" W8 o* c3 S2 F4 \; W/ w. W: Q% Cvar xPos = 0;
. \7 ]5 @, I+ p4 h" yvar yPos = 0;
: O$ P9 s5 O! yvar xDir = 'right';( U) O x( @/ M0 t$ i* k& x
var yDir = 'down';' y, ?& w. k2 U
var superballRunning = true;
0 D5 R8 e4 P7 C: U5 o, q1 kvar tempBallSpeed;
7 z K& g9 a! H& \ Evar currentBallSrc;
w3 v$ [: \; `; F j/ p! c0 [var newXDir;; K% Z: c$ J5 ]7 M# P+ b5 M
var newYDir;
0 y; S1 G# n5 H& Y& m( C; G: a9 P
function initializeBall() {) V' K; u& j- X9 E- z7 g2 U
if (document.all) { b& L2 H& s5 f) u/ ~& R
xMax = document.body.clientWidth
$ S/ w4 b6 f" m- W/ Z yMax = document.body.clientHeight
5 T8 c3 @/ {) C- n* ] document.all("supertext").style.visibility = "visible";) k4 V+ H, x+ A7 `( E4 k4 H
contentWidth=supertext.offsetWidth+ o6 Q3 G9 F$ n7 Y
contentHeight=supertext.offsetHeight
+ N3 s0 D+ v3 j Y }
2 }* u, l! t( h, L! u' r else if (document.layers) {; K p" L$ w" n4 `) k
xMax = window.innerWidth;
! I( v) ?; W4 a8 G' { yMax = window.innerHeight;2 E4 `$ x% }, T U; w/ }
contentWidth=document.supertext.document.width5 G+ E' \+ `6 \
contentHeight=document.supertext.document.height6 f* d3 _$ T* P" ?
document.layers["supertext"].visibility = "show";
, ?# Y6 o m1 U# G/ x }0 W' I* M8 X( [' g
setTimeout('moveBall()',400);
% r: a3 {( |! O4 s7 Q( ~$ w if (hidetimer!='')/ V4 }+ N) r2 ]& j7 ]% ?4 S
setTimeout("hidetext()",hidetimer)
1 o R/ g* K E" H4 J9 Y2 g3 N }
* T8 Z: h% h! P# ` Y1 g9 i0 j7 o- b/ L% |
function moveBall() {
% f% b$ L( c: a6 s1 q) h# A if (superballRunning == true) {
% t+ B* z0 o, Q e calculatePosition();
, C4 U6 }# X) ?3 C! w3 U if (document.all) {/ @. n9 p' v* W. o% A& y( P
document.all("supertext").style.left = xPos + document.body.scrollLeft;
5 V {8 h' y) I k/ N2 H2 | document.all("supertext").style.top = yPos + document.body.scrollTop;0 d% ^. u) A$ r; ~7 d7 |9 _, Q
}8 M/ T# N1 f5 I$ \0 D8 z' V7 \* v
else if (document.layers) {
& J. C" Z0 E5 S& I" l0 ?8 d# }) | document.layers["supertext"].left = xPos + pageXOffset;1 X; ^) ]( t+ [* F2 Z
document.layers["supertext"].top = yPos + pageYOffset;
Y' K7 R h8 Q7 c& Q- C }
2 \ o4 i& X9 |7 T$ h( T( C animatetext=setTimeout('moveBall()',20);5 V7 X5 c V1 E+ i
}
& n' w3 p4 B) j. q, { }1 ^# [1 K( m/ |
2 {" U0 f+ s$ H: `/ C/ w, B0 U' Gfunction calculatePosition() {
. i' A8 {$ x g7 A, B ^ if (xDir == "right") { n5 l6 C/ w& O
if (xPos > (xMax - contentWidth - BallSpeed)) {' w7 a A, x# B0 l& C
xDir = "left";
+ h9 J. J0 T) o& F5 O% x8 e- L }! j* n* H9 R/ u( o2 ^' @
}
; o6 [* A; {1 r( D5 R else if (xDir == "left") {
$ Z" a$ |: W( h if (xPos < (0 + BallSpeed)) {
1 y# d5 E9 K; i3 T) ~: }+ O xDir = "right";
* }+ e8 x6 Q* p* |6 u1 G; R4 O, \ }
2 `1 N( h' g, g+ f8 Q l- J1 L9 q }3 A' G( p' v$ K) U4 ~5 W6 w
if (yDir == "down") {
$ ~9 g& G2 v4 Q1 A) b1 k# X if (yPos > (yMax - contentHeight - BallSpeed)) {& B. X$ s9 j" I' ]
yDir = "up";
, I9 U) `, ~ Z; Y3 p" c) q: @1 b }
# ^- Q9 ^1 D* H7 K. @$ N1 D! j! g" M }- t+ h8 G* X" L9 v
else if (yDir == "up") {( ?( l+ Z0 r% F/ N
if (yPos < (0 + BallSpeed)) {
7 \0 J4 q2 P: D yDir = "down";
2 J! p/ U) A; W, x% W }: \: a- X% a" C7 {1 @& G9 H3 Q. Q3 _
}
; _0 ?% r4 L3 Y! \# L p5 A3 } if (xDir == "right") {
) Y4 L5 j! Q, D1 ], e5 g xPos = xPos + BallSpeed;
! Q3 Q( Z2 n2 [; f A- _ }+ X/ S0 Y& ~* ~) c
else if (xDir == "left") {+ @1 V- m E: G' J* z) f! ^; Q, M! J
xPos = xPos - BallSpeed;
0 H" G' G a, K% E, w' ?9 } }$ W9 }1 H- {6 k8 P& R
else {
' ^. M. _: k0 U xPos = xPos;. a3 b, p3 h, r' {6 A8 h0 x& J
}
- `' Y$ \5 C! t4 M, E if (yDir == "down") {
4 ]7 {6 _9 N, ^8 D# F* E1 v yPos = yPos + BallSpeed;7 E7 G3 T0 H3 e
}# i& {, E+ e, R( }, H
else if (yDir == "up") {4 m X3 b+ s' K8 L6 A8 ?8 `5 V2 A
yPos = yPos - BallSpeed;
( t1 g2 E. C, [ }
5 O. [! i: u4 s6 I' V' v* _, h else {8 q* Q0 y: `1 @( h5 [. l
yPos = yPos;
6 b' c: V! y- N2 } }/ B# }4 _0 v* F% l5 y
}
! `, R6 V5 n# Y( p2 l
- x) _0 W" g' X; wfunction hidetext(){! l* F1 H' I, [# P# v
if (document.all)
% ]$ A" |; c- ?+ d9 I( _supertext.style.visibility="hidden") F5 c% k3 a; n$ ?6 K1 y( ?
else if (document.layers)8 F) n; i6 w' y6 w& n/ Q
document.supertext.visibility="hide"5 w" J* e @5 l2 @
clearTimeout(animatetext)4 j5 r* J6 O1 o5 ?
}
% w8 I$ Y. ^! c9 M9 T2 `) X+ ^5 B8 U7 W# |' h
if (document.all||document.layers){
! }8 e. X+ t* j) u' ]: adocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')# t @' Q Z. k* p8 |# F+ N
window.onload = initializeBall;
3 U5 h- ~. E9 [; L0 kwindow.onresize = new Function("window.location.reload()");
8 j% H+ H1 U* U ~! |}* s8 ^3 W/ W, U9 {' ?0 P5 {" K
6 B2 Z) L" A9 f1 Y3 I- N& L$ `</script> |
|