返回列表 发帖

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

<style type="text/css"># H) m9 |5 v9 s, a' w. z1 F
#supertext {& k6 C% K& d2 F, ?) w( |8 d; x
position:absolute;
2 G" P. E! G2 x: i: _; Oleft:0;
4 {6 w3 u' Z" s6 p& Ctop:0;! ?" U) q/ U2 a/ a- z; v8 r
visibility:hide;
. {4 i* s$ N, {# F7 V6 \6 qvisibility:hidden;3 w! ]3 n1 e+ G# N
}( J* y- q2 `& z5 T5 y
</style>
: u  i" e  T& Z. J4 M<script language="JavaScript1.2">
1 T" J9 g' p+ @# ^+ _, \% u<!-- 改变下的字体的大小。颜色-->
3 U5 }: X% K( N9 Y! x1 Kvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': k- O- a0 {( t1 R
var hidetimer='';+ U  p) T0 _' [9 N
<!-- 改变下的弹跳速度-->
/ Z) Y+ B) b, T" c! I5 y, l$ mvar BallSpeed = 20;, }" X& K6 P8 R3 Q4 J$ u  \% D
var contentWidth;. ]- F% k, [) n) J; y- A
var contentHeight;
. k% j7 E7 Q5 T: Ivar maxBallSpeed = 50;
! \! \6 ^$ S5 L; ~* @; [. y6 a
# b( t8 }2 ~" w$ O& X/ K  K9 L; B& q( S" m; ?/ G0 L* n) ]# B
var xMax;. R* G& g& ~  ^$ \$ ~* C; t
var yMax;3 D1 i( C, b( m4 |7 u+ e
var xPos = 0;
; `* h& c' v2 a! V; rvar yPos = 0;
% X$ ?* z: k- T* q, Nvar xDir = 'right';
* @" ?3 D( {1 l# Hvar yDir = 'down';2 T! z1 N/ U+ R
var superballRunning = true;
+ L% U! }) w) T, O" ?var tempBallSpeed;' E! t; J7 O3 y  x$ X; C
var currentBallSrc;
# M2 z+ e9 l4 i0 g; p$ B2 `var newXDir;
* n* I5 M3 p, u3 V" Ovar newYDir;) ?/ z% h9 i# ?

+ B% Q, H# X$ A* H" k; @function initializeBall() {
+ t) A3 {$ A8 f* Z   if (document.all) {
" r4 c6 `+ O& P      xMax = document.body.clientWidth
' N" f) g5 Y* O! f) `) K; G5 H" o( V      yMax = document.body.clientHeight
4 ?3 g! w' n! \8 A% i$ D( k6 C      document.all("supertext").style.visibility = "visible";
6 c% e' g+ a/ g/ q+ v9 C6 b      contentWidth=supertext.offsetWidth
' z- c+ \! D' I& F: t      contentHeight=supertext.offsetHeight. u6 I: t- e  T8 {
      }" L/ H/ N" `6 c  Q3 s: r1 T  m: ~
   else if (document.layers) {0 T& ~0 x( C9 l" @$ G' ]* Y
      xMax = window.innerWidth;5 n; T2 w8 Y6 U$ Y2 O* e1 ?+ J0 p
      yMax = window.innerHeight;
. B8 g) b. y- [& Q( P8 f5 w1 a      contentWidth=document.supertext.document.width4 F  H9 D5 U, [8 x1 Q
      contentHeight=document.supertext.document.height2 s2 [8 L  ^, o3 l+ h/ E3 h
      document.layers["supertext"].visibility = "show";5 b$ X" s/ u& U: h% a
      }6 J5 b9 s8 U$ D0 p
   setTimeout('moveBall()',400);$ Z$ g8 S+ [) J3 z$ f
   if (hidetimer!='')- R; ~' c, w# }8 D: A. h8 x
   setTimeout("hidetext()",hidetimer)
) T: K& Y$ P5 N) |, `" @1 e, D/ c1 U   }+ h/ x9 }9 i! C

- V+ @$ T* \& {- d! Q# V: Kfunction moveBall() {) ?- e% k& w3 q( u6 @" t
   if (superballRunning == true) {
9 v5 Q6 M8 `$ L9 y8 |6 V+ y      calculatePosition();
& `9 L3 s* V6 D( \1 Q) O! q7 i      if (document.all) {3 }2 I- ~  g" I+ Q. M* p
         document.all("supertext").style.left = xPos + document.body.scrollLeft;% K# a. |$ {: `# H7 A
         document.all("supertext").style.top = yPos + document.body.scrollTop;
( Q! o& g8 e; {+ }2 B         }
/ F! T8 |) p, E) a7 {, a% }      else if (document.layers) {
0 K1 J& ?1 P2 }* O* O) {; l% g         document.layers["supertext"].left = xPos + pageXOffset;
4 Y! H% m. N: a         document.layers["supertext"].top = yPos + pageYOffset;
1 l( C/ e4 ?! t: x% x; E: R6 i         }
. V( [1 b9 G) n6 r      animatetext=setTimeout('moveBall()',20);& s, B. M& [. _: y  X) Z
      }* }2 E  O3 i' k$ h# A! K* [
   }
9 G- f0 p' H1 C1 _& p; z* w8 x% A+ j: ^7 ?1 {  Z0 b
function calculatePosition() {
; I7 _4 q) d0 V  a3 i   if (xDir == "right") {* ~0 h3 l: Q+ b8 {
      if (xPos > (xMax - contentWidth - BallSpeed)) {
" b. k, D) C9 Y( i! ~" R/ G         xDir = "left";# K' d; q+ T& t% w4 Y: Y0 W! n
         }
/ A- j* W8 p$ d8 \7 A: ?8 A6 c      }+ V/ R3 }1 T' E8 K3 d' X* c, g0 V
   else if (xDir == "left") {9 Q8 b; x) u0 Z6 E1 G" H
      if (xPos < (0 + BallSpeed)) {6 ^$ K1 n: L$ Z+ D; I
         xDir = "right";* D- I0 @* D6 @+ @
         }+ O, q8 Z% C' P  S& m2 l
      }
7 I$ j' m. b, A4 r5 v   if (yDir == "down") {
5 w! l2 Q" X; x* R/ O      if (yPos > (yMax - contentHeight - BallSpeed)) {: u* M$ R: ?0 {1 a/ p, b
         yDir = "up";
4 J7 `( t- `. z' g' ^( E         }) D8 q6 L- B4 f) V+ S8 q
      }
% p- K" X* j- M   else if (yDir == "up") {
: i% M- b2 J2 a. f0 e9 d      if (yPos < (0 + BallSpeed)) {
  s) w8 l$ i0 D5 k4 D         yDir = "down";+ |# u6 O, p6 v9 R
         }% `3 ]. T' O$ p0 N
      }
9 ?6 D3 y5 L  j7 d! Y+ h   if (xDir == "right") {1 C, u3 H- s& b2 x
      xPos = xPos + BallSpeed;
: B, f* t* r* ~$ g8 P8 [      }* \1 l, Z2 Q1 o: {
   else if (xDir == "left") {
9 D7 d2 e1 v; r$ Y. B      xPos = xPos - BallSpeed;1 D, Y4 T: S" G& O; k4 P
      }' f9 S- d4 ^( X8 U( i; @
   else {: x, D* P* E( {4 C
      xPos = xPos;
4 q. Q0 i! y" X3 _& N      }# V4 y/ m0 e. E# A
   if (yDir == "down") {/ s2 k, h" [* M; W: v7 }
      yPos = yPos + BallSpeed;
: V  @! T8 M" B3 C5 C* Y      }) x8 \+ ]4 I) w  ?3 N' z) N, M
   else if (yDir == "up") {
& s# g+ Y# x& E- O      yPos = yPos - BallSpeed;( x4 J6 a1 F5 }  H8 c
      }
6 |0 u! @0 E4 |% l1 G4 P& T   else {
5 e2 s2 \2 J, f% G9 |) G      yPos = yPos;. d6 g+ e+ o. L+ `& V7 c3 ?
      }
# Y5 A1 G8 r3 O- f  S; K: x   }
9 f: s( P5 P2 [& g% Y7 F' c
: k1 x: ]4 e) P; Z  s( D+ bfunction hidetext(){
# p  V) k# z  t1 Q; C3 K1 \if (document.all)
) u; \3 [8 f9 r% Vsupertext.style.visibility="hidden"
6 h- o6 S5 q+ l0 z; p2 S3 Yelse if (document.layers)
, o( ?2 S( q! Idocument.supertext.visibility="hide"+ o; @, n' J2 R8 Y
clearTimeout(animatetext)
1 f1 \' y& _! x' M5 W% X6 w: J}
+ w7 u* K) u  K6 t" V- O2 c1 C' l2 a% u# t
if (document.all||document.layers){
  t' H" f* t: M' Zdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; C0 D9 G3 P: _$ vwindow.onload = initializeBall;
* ~: t7 i9 R2 Pwindow.onresize = new Function("window.location.reload()");
5 W' Z7 V) y* g7 P2 q1 [& j+ i}( r4 a4 \7 T- \, N3 r; X+ y

' O% {3 E1 G7 H5 U* V! Q/ q7 _</script>

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