返回列表 发帖

网页之不断弹射的文字-特效

<style type="text/css">) i: e) D7 t2 S: r
#supertext {
5 e; k* I) J; X" i% G4 vposition:absolute;6 B4 D5 [$ g9 ~
left:0;
+ g5 {: h3 l0 v6 s0 ^top:0;3 r! q' U( W6 U3 {
visibility:hide;0 _" l3 a) ~+ p
visibility:hidden;' ]$ `* f: ?" j& K/ U7 N% t0 a
}
) D& V+ d( _' M& O' j+ V& A7 R# o+ F</style>+ u* T/ v& s+ `! J7 h9 D; ?
<script language="JavaScript1.2">* u$ N, K3 a6 G4 ?
<!-- 改变下的字体的大小。颜色-->
8 R! R5 Y7 h4 L' Avar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* H( U, b* ~% j+ d# q# w" Wvar hidetimer='';# K) w+ I4 Y0 u& q. M
<!-- 改变下的弹跳速度-->) v6 A8 t( G% a% o! t. |
var BallSpeed = 20;+ n* B4 i$ c; r' |- Q. O) C
var contentWidth;
" C+ G2 \$ y3 e, |' x5 svar contentHeight;% l5 H  R  u: p5 v# d: |# Z' O4 a
var maxBallSpeed = 50;
( W# X5 i9 Z( z; `3 d: {& w" o: b) g/ ~

2 L9 C2 r. n; p* P& tvar xMax;" s% g8 i" ]% h  V0 i8 O
var yMax;5 {1 x  `5 ^! R/ n8 ~
var xPos = 0;
- M9 W3 u- D6 n3 |4 t4 a; y9 Nvar yPos = 0;
) T, `* [9 I/ B- s% Y' A/ m) V0 M1 svar xDir = 'right';
. @- k% e* Q1 W1 t5 Tvar yDir = 'down';
  c0 v- o1 W0 Q: {4 [) i! uvar superballRunning = true;
& q0 Z2 `( K3 y4 p& _var tempBallSpeed;
1 D& h. }" R& P( \var currentBallSrc;
. L% o% _: K8 r& o. ]" p+ B( xvar newXDir;
4 p9 d6 R0 W+ y3 P# ]) P4 y  Dvar newYDir;7 y8 o* }+ n! h0 x  B- R% U
# |1 G- p) j0 O6 X' {
function initializeBall() {" [! F) A% D+ M8 E0 ~) i
   if (document.all) {
- r6 l4 w/ p1 G) T      xMax = document.body.clientWidth" B1 f# J3 |$ {, k8 ~% i5 ?7 r- A
      yMax = document.body.clientHeight
/ A+ ?0 \$ F2 l# V5 r+ k$ |      document.all("supertext").style.visibility = "visible";
3 F% r8 c# P4 y      contentWidth=supertext.offsetWidth9 J, s0 h- e3 ^9 _3 d# N
      contentHeight=supertext.offsetHeight' T( K$ y1 P8 m6 L+ |. Q& f( a: g
      }
6 F$ W% W4 U0 ?) `8 C  P   else if (document.layers) {8 t' X9 A( ~) F7 @9 Y% }- G
      xMax = window.innerWidth;
( L2 f$ v$ d) z  I2 ~. e      yMax = window.innerHeight;! Z0 u8 \6 @( v. b
      contentWidth=document.supertext.document.width
: z% D5 d1 W# q; ?* R3 `' {% j( z- b9 ~      contentHeight=document.supertext.document.height
# P. y* I, w0 w3 ]# ^/ R# }      document.layers["supertext"].visibility = "show";
2 @. \7 R' p9 d: f# Q0 j7 @; ^      }! H/ a$ C5 S7 E7 ~
   setTimeout('moveBall()',400);7 T) ~6 V& o- W  t; h
   if (hidetimer!='')  e& i% ~. N# M9 f
   setTimeout("hidetext()",hidetimer)1 I. H5 z1 F( H
   }" [* |+ a0 j* E6 O! a' R
' [6 R1 |7 H; ?4 {- u; Q
function moveBall() {
. t* U# s8 P2 c" O0 V9 U   if (superballRunning == true) {! V7 E- U1 g0 m: O" V. l" Z
      calculatePosition();9 [# w# j! Y0 J# z% Q3 o; _
      if (document.all) {! C* R# y8 ?* m8 |9 R/ o* `
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; N5 r9 Q7 s  W7 Q) a1 w         document.all("supertext").style.top = yPos + document.body.scrollTop;
9 a) Q; q1 _7 y4 V5 s         }" L0 |/ W  i; K$ s
      else if (document.layers) {; `/ x4 @6 g( q& [& i3 d
         document.layers["supertext"].left = xPos + pageXOffset;
5 M1 B7 h; N; Y         document.layers["supertext"].top = yPos + pageYOffset;
( A$ S1 c# \1 o% L         }
# y( K: D4 E, C! g/ H& B      animatetext=setTimeout('moveBall()',20);% r" G9 b$ |9 ~$ ^. m2 k
      }4 S6 C% I; L3 f0 I* N; S, }5 _  r) X
   }
+ Z) R: B; y& s
- V' N6 R5 P' _- pfunction calculatePosition() {% q3 ^( E4 `. h7 @2 n
   if (xDir == "right") {
% L$ r# t) j: @' }, R, r      if (xPos > (xMax - contentWidth - BallSpeed)) {) j, C$ U* R3 u2 q! t" V; u8 c
         xDir = "left";
) Z( K' E: Y. w* @: ?6 ^         }
- _; U: @' L% A- v# _4 E      }
3 E7 E8 }, P" F9 t& Y8 S  J   else if (xDir == "left") {8 h: i# ^$ g: B% U! H1 O  \
      if (xPos < (0 + BallSpeed)) {' t* H- T4 s. a- B! q( y
         xDir = "right";9 ^# P& b/ d0 q1 E0 A+ @- ]
         }
) _' r+ p3 o1 v      }6 _9 w* C; F3 X* N# D  z6 g9 K
   if (yDir == "down") {+ t; ]; j6 R1 I, d2 \4 a( ?* \
      if (yPos > (yMax - contentHeight - BallSpeed)) {
" l. Q/ t4 ]# e9 R         yDir = "up";$ ~. P) ?5 ?" T. I" _- T
         }! i- O5 B! ~8 z
      }: S+ y3 K9 w! k! u% A& C" p
   else if (yDir == "up") {  I2 y$ p% X+ N/ c" m9 R. _0 e- X
      if (yPos < (0 + BallSpeed)) {) K% |5 g) c! n( }3 |1 L( b8 Y
         yDir = "down";
9 ~+ o$ [# N& E( @6 `& k3 \         }
  g) H) G+ U0 S0 I' ^      }
% l: W8 n# G5 o. ?8 G+ s   if (xDir == "right") {0 ]; d6 V* ~8 v- B  A
      xPos = xPos + BallSpeed;
6 b4 D8 y4 U6 N( ~* ^3 l* J, X      }
4 x" t5 \) w, n. I7 C   else if (xDir == "left") {6 u4 k# ]% M0 n: i0 f* q, w2 v
      xPos = xPos - BallSpeed;
4 g. O7 h1 x9 v3 _      }, R" }% W) o) l- L
   else {
) B0 j, @: J! Q: V4 C      xPos = xPos;+ {& y' S, S5 b. ?" o
      }
9 `0 w" M& W0 D4 S' t2 D6 _   if (yDir == "down") {- j4 Q. L" w0 z4 E/ |8 b4 s' @
      yPos = yPos + BallSpeed;
7 P8 k1 I- K4 x- k0 j$ {/ B      }
. V- o% z3 C+ h9 y' ]7 m' u   else if (yDir == "up") {9 q. j+ P3 C* ^/ R+ L4 D- m
      yPos = yPos - BallSpeed;$ |; Q& N/ \, D
      }# I" v+ |8 W; b; q2 C
   else {$ D) m% z3 h  Q0 ]5 V, f
      yPos = yPos;/ |# p4 ]* ]: Q
      }1 I/ T0 b/ V' P8 h/ @1 \$ k
   }
! s. g* E3 u) g+ w7 U$ U: N0 I* K$ j  B) @0 B) L6 M: d  N. R
function hidetext(){
/ B1 ~6 f6 t" e/ G' w# }if (document.all)
# K7 q" E, V" Rsupertext.style.visibility="hidden"7 p4 O' C- d2 k1 m! o5 ^' Z
else if (document.layers)2 ?" Y% y$ f! ?# V# q( J
document.supertext.visibility="hide"
0 J$ I4 W- c7 h: ~2 Y( ]7 DclearTimeout(animatetext): m# R3 U( w7 N* ^3 Z' W9 S
}
3 H" E" F$ u4 _0 H: I; W) t, s1 g" D( d. X7 K
if (document.all||document.layers){
* n' E  Y! n, [6 H2 V3 {document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& }; p% d8 x: C& g: ]
window.onload = initializeBall;
9 U0 h+ a& O5 }* q& Pwindow.onresize = new Function("window.location.reload()");& t# R# t3 z" l. \$ k. _
}4 L" _0 }9 `) }4 R5 N  K2 ~
+ E" \4 |  Y5 s6 J6 P
</script>

返回列表
【捌玖网络】已经运行: