返回列表 发帖

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

<style type="text/css">
- O0 b9 B4 Y2 d5 ]5 x6 [! }#supertext {5 ?; C4 [0 D6 k/ m5 H
position:absolute;' e* ^* H4 v) o8 W8 b; W
left:0;
1 e- c6 f" A/ {0 o5 e0 V% atop:0;$ }6 k5 J; ]  @" a
visibility:hide;+ f  ^. F! T2 Z7 z! ]0 E
visibility:hidden;# a/ R2 C) t: Y, j5 g7 b3 ?
}) c7 Y; ~: C% t
</style>
: X; |$ u* [! f2 C, s# E! u$ O( }<script language="JavaScript1.2">
* S2 u, ?4 c  _" J/ R* l; A" u<!-- 改变下的字体的大小。颜色-->( J0 Q# J7 |6 K' B* f; `
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% O  H" G% P8 Ivar hidetimer='';0 p9 x% U, R( [; S% s3 G6 g
<!-- 改变下的弹跳速度-->
7 g" ]# A3 d" w; X+ ^# hvar BallSpeed = 20;
  l! P; D$ _) L8 ]1 F: jvar contentWidth;
5 ^' H! Y1 e% a' \+ cvar contentHeight;$ M, G* I( J9 g0 o
var maxBallSpeed = 50;
# Z( A4 a2 J+ i0 N
. x6 m, B9 e+ z5 A: Y9 x( y+ H5 @( y) P
var xMax;
' `  G* N: X( y$ ~var yMax;
6 o! E; M1 j, m* P8 Jvar xPos = 0;0 x5 X7 M/ K7 u- H- ~
var yPos = 0;5 P( `! b( |# Y1 y
var xDir = 'right';
4 p- r) v3 W" b' [8 c  g3 f0 Uvar yDir = 'down';
% R* z1 r! I# F5 ivar superballRunning = true;: N" |, q# y- ^) e
var tempBallSpeed;' s7 ^7 c$ X# L. z
var currentBallSrc;
& |1 ?1 [+ m, L$ Y- c1 l# `/ y5 avar newXDir;! r7 g- T+ O* s5 t9 X
var newYDir;
% Q4 j/ \3 _! b6 B" H6 d, c
% {. t" p! @. i8 Tfunction initializeBall() {! ?+ n- a+ i" e# J& [& e6 x
   if (document.all) {" i% s3 X/ m- u: ^" {. i2 w' k) k
      xMax = document.body.clientWidth$ I  C* \. D8 ^1 o* A8 F# v
      yMax = document.body.clientHeight0 U0 |) d5 x( |( i" Q
      document.all("supertext").style.visibility = "visible";% d+ q9 H0 p1 d  k( L; m
      contentWidth=supertext.offsetWidth
' c7 T+ T  s; K6 {0 v$ I      contentHeight=supertext.offsetHeight+ P5 a/ G# I! D5 Z, G6 j! ?- ]
      }
0 L3 E4 R8 V" a* d0 m1 X2 _6 g& H   else if (document.layers) {
. n8 D9 q- S. T0 t* S. ]      xMax = window.innerWidth;
) y' ]4 J# p9 n, V, z+ J  @" ^      yMax = window.innerHeight;# y# x+ z! @$ @* }" O9 K- q4 r
      contentWidth=document.supertext.document.width0 ]% J2 f$ B/ K& {: [8 J+ c
      contentHeight=document.supertext.document.height
2 d# a" \+ W; H* A# l; M      document.layers["supertext"].visibility = "show";' ^- B6 ^+ }( r0 @& Y& S
      }
: v, _# ^: K% O1 p1 T   setTimeout('moveBall()',400);7 ~0 e2 h7 w  y: W  ?9 V+ D7 N
   if (hidetimer!='')  k6 N* _9 i: s- }5 f# \# [! U
   setTimeout("hidetext()",hidetimer)
; {5 P2 m, ~& y   }
2 U! M2 M# R( {$ s0 t5 `0 m# `% A
. Y# \2 {" @# U1 i6 Z" Q% bfunction moveBall() {
% U  R2 P1 L6 L1 o3 x4 M   if (superballRunning == true) {
) b' U- `- P: j) u1 ^: y# P3 n. b1 L      calculatePosition();
2 I7 I- s" H! Q& `      if (document.all) {1 }( F3 G2 U" X5 g+ Q
         document.all("supertext").style.left = xPos + document.body.scrollLeft;# _9 D8 \3 V  f
         document.all("supertext").style.top = yPos + document.body.scrollTop;' Y8 O9 q. j0 B+ B  w  H+ z
         }* W# X5 o9 G& R) s& M7 l# p
      else if (document.layers) {* B5 F  l" ]/ [& d% J
         document.layers["supertext"].left = xPos + pageXOffset;
: Y  X9 N# A( M0 F& M         document.layers["supertext"].top = yPos + pageYOffset;
0 K8 ^1 T; m3 F2 E8 ~$ ^         }
* j8 U1 A7 h. m. I8 ]6 F6 K3 K) O' G      animatetext=setTimeout('moveBall()',20);
# C6 R$ \8 [7 g! h7 i; J$ D2 r      }
3 s' @# S# O5 e# d$ e1 h. k$ x   }
1 l2 E' `2 B6 d+ z2 @( Z; [- P2 P: |4 {, l( z
function calculatePosition() {, o2 O! U4 S# B( m! Y; @
   if (xDir == "right") {
8 [! g$ ]- ~; S1 e      if (xPos > (xMax - contentWidth - BallSpeed)) {) p5 w5 ^. h. I  @& ^; A; y
         xDir = "left";
  G3 b' ^0 P  D1 m! G0 x  V         }4 O8 m8 C) Y- e- b4 l
      }
5 G5 X0 b6 a) Y: f9 d( O% U   else if (xDir == "left") {
) {. ^5 [3 z+ f8 E      if (xPos < (0 + BallSpeed)) {
2 ^2 }/ L2 ~2 }* Q! Z/ @         xDir = "right";
- h) M4 u/ ~1 |8 r; T4 Y. ]6 H         }% W% ~, H$ Y/ A' N
      }% T& j! P$ U7 x- C( l/ ]
   if (yDir == "down") {& W1 H% r0 s/ F) ]5 [
      if (yPos > (yMax - contentHeight - BallSpeed)) {
. a$ w1 B! A; D! n8 G         yDir = "up";6 D6 W1 J; w% S! L. Y* `5 W1 q
         }
% `+ j2 R& R7 Q" X- D. V1 `      }. n% V  m* B! Q  I( s( x1 |1 R
   else if (yDir == "up") {
" e7 N6 S7 `0 {. P, [* y( d  j      if (yPos < (0 + BallSpeed)) {0 I( q' C4 _" L3 h" G6 v
         yDir = "down";; M) d& P7 I- @: l! D
         }
2 ?2 |; w0 [- i0 z7 ^0 H# Q      }- g$ I" P- n" }# i7 L+ a
   if (xDir == "right") {
( C3 a" c( J) c  c1 O      xPos = xPos + BallSpeed;% Q' p9 H; o. m
      }. ?& h, q- ^, X  V
   else if (xDir == "left") {# l; r# w, R9 U9 Z# _2 I. A3 R1 M5 ~
      xPos = xPos - BallSpeed;- p  @: o1 |4 r: T, I$ [6 ~
      }; x+ h) R8 t& M- W- \" G1 c
   else {
. Z" u; [1 k2 D( V      xPos = xPos;9 p6 E  G$ r7 w+ N
      }
8 a! n( l7 ?  w- f   if (yDir == "down") {
2 h: I/ H5 e/ ~1 v/ \% s! V3 x$ ?9 o      yPos = yPos + BallSpeed;
6 z' e, S/ t! }- \4 F      }
2 c8 B+ a& R: d, b   else if (yDir == "up") {  k$ F$ G" O5 g2 V, @1 i8 B# s
      yPos = yPos - BallSpeed;
! P( S6 S+ }$ _) y, f5 V      }
" s  G/ y$ i" \6 C8 @   else {
  u, l5 p- r- O/ k; V' t      yPos = yPos;3 d  U# Q6 q0 H3 C
      }
  O+ Q  a( a, G  |. |   }; F1 \  x5 m* P) J% V

+ P2 R" ^; j# e. \) E/ jfunction hidetext(){
$ `  t4 ?( o% Y  O% n. d% pif (document.all). e% r6 q+ ^4 J# A
supertext.style.visibility="hidden"
$ [. F, k- K7 {" T+ {else if (document.layers)
0 R3 }# b5 w- h6 W/ {document.supertext.visibility="hide"
1 s" U; L5 l. |2 N- q9 Z6 ]) ^$ bclearTimeout(animatetext)9 H9 F* _4 p( g0 q" \: n7 H4 J2 k" c0 o; U
}
0 `; ]% x# ?8 L6 K& i/ r3 E
9 v% @9 |/ H) Nif (document.all||document.layers){5 d$ t4 h  @, j4 R- M" K/ C! C
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 w: u( W* F& Q, v3 U( k6 uwindow.onload = initializeBall;% {# [3 ?$ y& `. Q4 n
window.onresize = new Function("window.location.reload()");
( v& S) K/ k* n}1 m- r! E& w, n

/ U& h- H$ I0 p( B& d9 ]& A  E. d  q+ ^</script>

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