返回列表 发帖

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

<style type="text/css">% p5 e( A5 h+ d
#supertext {0 _4 C4 R9 \$ F9 F
position:absolute;% L  R7 K  I7 H& ~6 u0 C
left:0;
  W0 |  |. l; b1 l# _0 X% ktop:0;- K$ m/ V! v/ m# X) z& D* f
visibility:hide;
2 z7 D2 j+ s. Z5 v; l6 X7 W' {2 avisibility:hidden;% o/ ?. I$ c$ M2 s  P2 Q
}% V! G7 \1 \  Z* |+ s. `
</style>
* h, G* H# [. ]# d- ^" h<script language="JavaScript1.2">
' \: X4 ]4 X# s' e' G1 r" k; Z<!-- 改变下的字体的大小。颜色-->
) Q3 f4 f; `- ^. J8 Ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': P6 Z. v% n6 y+ K) E
var hidetimer='';
' C5 a5 ~( T8 `1 S<!-- 改变下的弹跳速度-->
9 x: R( {0 o5 |% H% k# ^: Qvar BallSpeed = 20;$ ^- z6 O# G( H& {5 b6 f1 u9 c
var contentWidth;
5 u' H+ o/ x4 b; hvar contentHeight;0 }+ O9 ^* S$ s0 F- R, c1 M! E' G
var maxBallSpeed = 50;
, P3 K. g7 i: ?! u/ I6 f  r/ L1 L; v# l& J# \+ g5 o' u) d9 N

& U! y' [+ \# Pvar xMax;
0 e4 c: `7 F; }. pvar yMax;
/ j0 j! s+ W2 \4 uvar xPos = 0;& Y6 d, e' z8 K2 T, l# K/ v# [
var yPos = 0;
; d. ~. q, T  B" O. lvar xDir = 'right';
8 {2 e0 \8 t. x, }var yDir = 'down';
) |5 q3 ~; j3 x0 v5 N. yvar superballRunning = true;1 Q2 }7 q0 ^' V7 S
var tempBallSpeed;% Z6 |1 Q0 Z3 c4 u& d
var currentBallSrc;. U  b' y' m3 W+ b8 R7 n
var newXDir;
1 D+ p4 V2 V# a/ [+ b$ G% Xvar newYDir;  w% Z+ s- ~7 l% g1 {# d% V
) K3 w1 L' F$ g7 E" `/ ~' ^. V) Y+ O
function initializeBall() {+ n0 W' K. h9 k8 v# W2 V  [5 d
   if (document.all) {( f4 f! y* |& n5 Y. X) b
      xMax = document.body.clientWidth
2 c. h2 B+ I0 M5 o4 l5 ]! ~+ j      yMax = document.body.clientHeight
$ \( n, v* }/ ?7 v/ C      document.all("supertext").style.visibility = "visible";
, M! F9 x1 G- X  J2 O+ U1 Z      contentWidth=supertext.offsetWidth
* J/ e& L( x3 H2 B, y. ?/ X      contentHeight=supertext.offsetHeight
/ o# ]7 |6 a5 ]" H. a" @      }" c3 v" i2 l% |. l+ [: `
   else if (document.layers) {! [& Z/ h& W9 F3 U% n6 l
      xMax = window.innerWidth;
% C9 A' z; h2 X" [8 n" D      yMax = window.innerHeight;
$ N2 }  X4 W9 s1 K      contentWidth=document.supertext.document.width; W% F5 I( z( R6 v! Q
      contentHeight=document.supertext.document.height
+ ?* X) \. V# Z+ F1 p. H9 q6 c% c5 ^9 w      document.layers["supertext"].visibility = "show";
, @; j& t* _3 i      }
2 K$ u& D: I; v; }& i% @   setTimeout('moveBall()',400);
/ t  D; I9 E. q0 F: l) a; X+ f   if (hidetimer!='')+ F" h/ n0 L" n
   setTimeout("hidetext()",hidetimer)0 B4 x8 c; R. Y; H
   }. n4 N$ T. u; {$ Z4 @% c
& H! ?! m4 Y9 K! ^: Z1 |  w5 \
function moveBall() {  N  K( d  }6 {
   if (superballRunning == true) {3 e. f% [8 c! E) Z4 s& G% X
      calculatePosition();
4 S% h; M' B2 x$ j! J      if (document.all) {" Z4 a' Q# A9 E0 o- f( D  b  W
         document.all("supertext").style.left = xPos + document.body.scrollLeft;9 @* {7 ?) W, r/ l3 h7 o7 E
         document.all("supertext").style.top = yPos + document.body.scrollTop;; Q: |9 ?  F# Q5 m) @& ^3 ?& |% r
         }7 W4 }9 B9 Y7 {$ I" U, F  h4 T  e
      else if (document.layers) {
, m( b* U0 b# N( E  }0 z+ H         document.layers["supertext"].left = xPos + pageXOffset;) |4 I( D- N( K/ ^' x% t; D
         document.layers["supertext"].top = yPos + pageYOffset;& |$ H0 [) E5 c& n9 |
         }
# ~+ [2 b& P  [* E, R. m; y6 c/ P      animatetext=setTimeout('moveBall()',20);
8 {2 n9 F' {' @7 a) a      }
' \4 t3 ?: Q7 K6 ^: [   }- C* K- h5 J2 m4 |4 D  i
9 N5 W0 z0 `3 C- J+ k9 U& M; n
function calculatePosition() {) \5 a3 C, R9 u( [. i( l8 @# v- P1 V
   if (xDir == "right") {7 Z' q# x6 l' P, g
      if (xPos > (xMax - contentWidth - BallSpeed)) {
+ d3 g% W& a5 h: s         xDir = "left";
7 j& G) c0 q4 c" v' Y& V         }
/ u" V1 ?5 w' J6 p, V& Y      }9 p: E; N/ Z0 j
   else if (xDir == "left") {) M' O- l3 l: g6 z
      if (xPos < (0 + BallSpeed)) {
' K; J  x7 M7 y3 `         xDir = "right";
8 ?# z; c& B2 {" L$ k3 e4 n         }
1 b7 ?5 ~- G$ V. V- r, o      }
- N' f) @: A4 W# s5 s- z  }7 g   if (yDir == "down") {
" |" m/ c7 x! i& t& J      if (yPos > (yMax - contentHeight - BallSpeed)) {
" B9 ~9 u- ]) Q; E1 f7 ?; p         yDir = "up";$ q5 D) e: x" M4 q- ~! y, B, H
         }
' M0 z* H1 O) ?! S7 l      }8 N! R6 d- l( x; z
   else if (yDir == "up") {
! R: U% f# O: V% G) Q. a      if (yPos < (0 + BallSpeed)) {
; c; V: E3 S) x8 l* O& o         yDir = "down";% o0 c' s& U% R) E5 j+ K% S. s7 p
         }) }* |6 N, Y$ {2 `' B3 B4 U$ x
      }3 D' j/ R4 \1 a/ F+ X& O
   if (xDir == "right") {' p0 Z8 a+ w8 M* e* ]
      xPos = xPos + BallSpeed;0 e' L- b  O. i
      }
( [, I% B+ d8 ?) L& M; k+ T   else if (xDir == "left") {
; O  I5 S# X* A2 O5 N2 j      xPos = xPos - BallSpeed;0 P2 z/ ^: v8 c6 S* ?5 S4 f% I9 S
      }
4 w" X) q; x0 E  Z8 p8 @( t   else {$ M9 ?: N, o- B9 x8 I
      xPos = xPos;
2 H/ R9 V$ y. V0 ~; p8 ~) l' y" d7 O& R      }3 m# @& f# f& u
   if (yDir == "down") {% J7 u% T. T2 W1 z' G( D2 e
      yPos = yPos + BallSpeed;
; R  W/ X  A7 S+ L- k0 k2 q      }
- ~8 k0 |# H4 a0 ?7 u% x   else if (yDir == "up") {, D0 W0 \4 t4 w7 T5 t) z
      yPos = yPos - BallSpeed;
- X' [- S* _* n# k0 ^      }
3 D4 M' G/ n2 ?   else {# G! h* J4 p0 Z% J/ B9 Z
      yPos = yPos;: S% B: @& |4 w$ Y! R' _+ y& c8 R: f
      }3 C( n- B6 w$ o
   }
% e( u7 G4 K& u
" e! v  O- a2 O9 ifunction hidetext(){$ J8 m8 n! ~# ^8 D
if (document.all)0 r$ a! R# W7 L7 N* U
supertext.style.visibility="hidden"
+ j* S# T. n$ U0 j: Relse if (document.layers)" U7 g* v5 `' p, k) i: }. s
document.supertext.visibility="hide"
0 g2 U0 o/ B, y. X! {+ wclearTimeout(animatetext)2 A! E5 D+ h' z/ l; i8 G; `- T
}# c$ m9 ?1 e( c6 T. o4 n7 [+ t

1 Z0 L, ~/ d" g8 _( V* ~" ~. f, n$ Dif (document.all||document.layers){
  T5 X3 a' W, L* ^# ~, d+ rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 h3 E% C3 _# G1 }( I# B5 q
window.onload = initializeBall;, d3 n. @1 \! O' H3 o: m
window.onresize = new Function("window.location.reload()");! h! X' D! V: a! u. q! n% K" p5 X! v) Y
}
3 l* @  t4 W, f' c1 A5 v) U+ e$ x; c% n2 Y- C
</script>

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