返回列表 发帖

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

<style type="text/css">2 n1 T# F" t) x; [) r
#supertext {
& Q5 D; a# e; J* Wposition:absolute;7 s2 Y0 y8 M5 \2 S# a8 P4 |
left:0;' _0 r  Y+ D" Z% l9 F
top:0;' R8 w+ H( Y6 o8 E# H
visibility:hide;. V: A$ v. ?) q) E1 A8 K1 W' r
visibility:hidden;
1 D2 z3 q0 F. _" x. ?}
- i+ _7 h: Y, U6 d9 y</style>5 p1 r- h1 y* l  p( y% \1 E
<script language="JavaScript1.2">
; v! j9 o4 e$ V6 J; T2 i% \, |+ u7 n<!-- 改变下的字体的大小。颜色-->5 Q2 }7 s0 e" C& c7 i. M+ k
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 r& h8 l3 V& tvar hidetimer='';7 U9 {1 T6 V- [, \
<!-- 改变下的弹跳速度-->
% \" _0 {: i9 H9 q% S% u  Yvar BallSpeed = 20;
. J' [  V* P+ Ovar contentWidth;. S3 N7 O4 j) D/ h" \1 Y
var contentHeight;
1 Y8 l: B  q; ?: I9 q# a" k. o( bvar maxBallSpeed = 50;
7 [8 D! R2 X' z$ [3 J8 l8 a$ }
3 r3 c! h5 O- N2 P! e
var xMax;/ S2 v0 |3 u" j2 g2 Y2 n9 v& K7 C) j- d
var yMax;
! G2 s8 @3 H8 _- U% n5 |var xPos = 0;) X( }. T7 V8 @5 n* y+ g) y: x
var yPos = 0;$ P7 {0 o0 _- l; g2 I$ j( Q
var xDir = 'right';
7 N- H, t/ ^: s- g& u7 mvar yDir = 'down';
$ x2 O! H/ s  J- E+ Avar superballRunning = true;
- r# B! Q2 J& m* l3 G# ^4 xvar tempBallSpeed;
; u2 x! p4 {* `6 Y$ s2 S2 rvar currentBallSrc;
% p( N) c6 W$ H) x/ m& J+ xvar newXDir;4 H7 G7 B4 B0 D& I
var newYDir;
) d0 y& J2 d2 U
' r6 }8 f6 i3 @6 Tfunction initializeBall() {
6 k. R) y0 ~; `2 t1 ]  \0 V   if (document.all) {
( O1 H; u& i6 V* S/ B; s! R6 x      xMax = document.body.clientWidth0 p) o& T8 d1 c) c; a- v' {
      yMax = document.body.clientHeight, l: C2 @( i1 p9 S# Y
      document.all("supertext").style.visibility = "visible";: k! W  A9 N2 ?8 ?
      contentWidth=supertext.offsetWidth
" D8 J/ }, t9 v6 O0 B- _      contentHeight=supertext.offsetHeight
2 Y% G! h. X; k( C+ N2 O) [      }
& a9 H1 E" r7 W" L/ V2 F' |   else if (document.layers) {% P( s- r) O  l1 d, L
      xMax = window.innerWidth;
+ _/ M: O3 @$ U$ |# L; ]      yMax = window.innerHeight;
4 E  o3 G7 r' a5 F% p6 f: A      contentWidth=document.supertext.document.width6 ?1 [8 n$ C, j* H
      contentHeight=document.supertext.document.height' l) z1 j/ d4 h$ o" ]  t
      document.layers["supertext"].visibility = "show";9 i& p' r+ M# W: o" G( H! D) E  Y
      }, g! n* p" t0 x* s$ \
   setTimeout('moveBall()',400);1 `0 l( h" k6 z0 k9 k9 H* g
   if (hidetimer!='')
% l+ t+ R9 Z; M   setTimeout("hidetext()",hidetimer)
' Y: O* t$ T5 J  E7 e! K8 [3 o   }/ I# U  z( |0 ~) s' P+ b- F/ ~% o" p

9 P5 ~9 C& S  \8 ]$ U4 f; wfunction moveBall() {$ k/ l7 p2 E! ?% t( }# {
   if (superballRunning == true) {& E" A4 s" t) P4 Y- e+ _: x
      calculatePosition();) m. T. a$ }2 E( [, C
      if (document.all) {
3 |/ B& m3 a& K         document.all("supertext").style.left = xPos + document.body.scrollLeft;
8 w( h& L" ~* i2 P; o) F3 s6 X" r         document.all("supertext").style.top = yPos + document.body.scrollTop;
0 W6 ^8 j8 D4 l/ F         }
* \# l% \/ i& U; [, F      else if (document.layers) {) k4 F/ `) ]; g) w. _
         document.layers["supertext"].left = xPos + pageXOffset;
$ p# E* [' O  U         document.layers["supertext"].top = yPos + pageYOffset;5 g7 \' S9 Q: M  p" ]
         }
3 Z2 o+ o7 ?* [; O      animatetext=setTimeout('moveBall()',20);3 L! J& |# ?$ A" \  x' d3 O
      }
( x* {- C& h$ l  `' r  H4 y( r   }* i0 U# k" }9 Z  s4 d

$ J7 f4 f2 V/ rfunction calculatePosition() {
$ g: K, p4 E. o" X& r* ^) w2 R7 N  }   if (xDir == "right") {
& y4 |+ E; h) x% S8 n      if (xPos > (xMax - contentWidth - BallSpeed)) {
& s* j9 {8 s% J         xDir = "left";
) K' D7 C6 [; E5 B         }
4 [& e/ |" |7 F" S      }
% x& }" L" e+ B' h" v* Y* {   else if (xDir == "left") {5 Y$ o7 c+ ]1 p  W. @
      if (xPos < (0 + BallSpeed)) {
' |! n: m! [4 j- `( o0 [         xDir = "right";
: u0 Y# O' u1 q6 j9 Z/ _         }# ~  m9 \, F3 F
      }; Q: e1 Q0 b: |% f! j8 J+ B3 q0 T
   if (yDir == "down") {& D, I1 I* m/ \8 y, N+ X( L" @
      if (yPos > (yMax - contentHeight - BallSpeed)) {5 ~- _8 Y- D7 N/ v( I# d; v  L0 l$ V
         yDir = "up";
8 c, O$ N  m2 \4 u6 [2 N$ d         }8 s* m2 I* i; {8 l2 j$ G
      }' b# X$ |' b" h4 {; u6 }% s
   else if (yDir == "up") {1 X3 e9 n0 h# L$ i% q
      if (yPos < (0 + BallSpeed)) {0 z0 ]; T6 l8 D) ]% b
         yDir = "down";
6 R1 ~& e, T0 o6 S4 @3 n7 H1 P         }1 z& i/ n$ E% T1 G! p- ~
      }
  _0 i, u6 T* S) X% t   if (xDir == "right") {
- s  L5 u$ @0 x; d+ f8 o      xPos = xPos + BallSpeed;; m. D3 W& J8 n
      }: A6 `$ T+ P) K1 k" x: L
   else if (xDir == "left") {8 S' ]5 B8 L; `
      xPos = xPos - BallSpeed;. R7 `8 M. G" f; g) Z% l7 N
      }
& Q2 o" ~, q+ ~: r   else {; X& @6 K$ t& Z* I
      xPos = xPos;
5 }' k, G6 b% _6 M      }# e/ K$ w; U9 P6 d* e
   if (yDir == "down") {
, w- j4 ]3 w2 j7 K1 B) T      yPos = yPos + BallSpeed;
" X9 n* x3 B0 O" W. Y& B      }) g6 q* b9 V( i$ s. K" G, ~5 v
   else if (yDir == "up") {
! I5 @- U$ ]( Q# S* f      yPos = yPos - BallSpeed;1 T% V% J/ s( h" ]* z
      }$ b; U/ ^, P/ S3 `$ Y$ s# l; P# S1 g
   else {
, u' L. _, o. [& P: O7 ^+ ?      yPos = yPos;
- `' x: Q, N! }, y% g' ]      }: J) t  N/ r$ d3 z
   }! y) c  [* ~* {
7 X- a9 ?( }  Q2 ^
function hidetext(){
' k& ?6 }! |& Vif (document.all)9 r# P$ X9 A( ~
supertext.style.visibility="hidden"
8 c0 b% `) Q. D% W2 x1 qelse if (document.layers)3 W+ i1 M- a& a! r6 ^; K
document.supertext.visibility="hide"1 b7 W; y  S7 q" q8 Q: ]' E. j
clearTimeout(animatetext)
6 W1 y- d" r  `1 Q2 U/ ^}. ?, @: t7 s& _/ g+ }& g# w4 g

  O! K6 p( T* dif (document.all||document.layers){
0 e6 S* j$ w  Tdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')" F8 o. Z4 A! P3 y
window.onload = initializeBall;7 u/ f5 s/ l! I
window.onresize = new Function("window.location.reload()");2 F' i5 G8 v7 m
}1 l/ o. w0 P* r9 N3 C& {, B
4 c7 P3 x2 j, ]6 ?( g
</script>

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