返回列表 发帖

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

<style type="text/css">
. V2 F! z' w0 }) S#supertext {
" B8 y+ _7 ]- I$ gposition:absolute;' s) z2 }, H, c% s4 t0 v5 N- n
left:0;$ @* t4 C! ?& E5 E" W
top:0;
" G, \- \- h; x0 w1 n9 ?6 Z3 [( Wvisibility:hide;' ^. i# W# e6 [- U9 U5 i( ]) j
visibility:hidden;
; r, X. x2 _+ j9 b}
+ A% e( \' J2 k) f* z' l</style>/ A. H8 c4 P9 A0 X3 L6 O& R4 E% u! {
<script language="JavaScript1.2">* @, h  c: Y$ ^: e
<!-- 改变下的字体的大小。颜色-->- ~; n; R8 ~; Z: E& u& m. n: z3 g
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' ~, ~% E, y+ e3 uvar hidetimer='';
" X- L5 z6 N2 ], y, N<!-- 改变下的弹跳速度-->4 g( a4 I& X( b$ N
var BallSpeed = 20;5 m; D" j2 k5 H
var contentWidth;
9 _0 z( w& T0 Z1 _var contentHeight;
4 `. k7 H- b# B3 a: V. qvar maxBallSpeed = 50;1 g7 b0 P; X) Z4 @
  y& m7 a1 n& X/ e

  M5 c7 t; G4 p; @  bvar xMax;5 P# B# q$ H( M
var yMax;
5 X' d& R: @: Vvar xPos = 0;
1 a1 o& d1 N6 Svar yPos = 0;$ r' b* [6 o- Y% t! W
var xDir = 'right';+ m0 k! s, i0 ?7 h2 s/ o! y/ s
var yDir = 'down';8 D( H. d! P3 s/ a' {4 V
var superballRunning = true;
. D0 f  n( w, x0 I2 Svar tempBallSpeed;3 G/ T% `) I) D8 N0 p! j  s- W
var currentBallSrc;7 I8 R9 p0 k4 u1 S. x( i
var newXDir;
9 m7 w# J; M1 o( f) C! Hvar newYDir;* f* y+ T/ a5 D

) X. B5 I( y$ T; bfunction initializeBall() {+ Y# y- W. q6 }1 c: Q
   if (document.all) {
; [* g8 J8 u& F& j: \      xMax = document.body.clientWidth6 V4 E/ a+ |" M' _& f
      yMax = document.body.clientHeight
% Q3 S4 u" S& O) ]5 ^1 u8 X& ]9 ]      document.all("supertext").style.visibility = "visible";
/ Z0 f: F7 ?3 y- ?% I      contentWidth=supertext.offsetWidth9 S# F: d% A% c7 E  a8 ^0 c
      contentHeight=supertext.offsetHeight
: \& ~1 C6 |4 K1 z5 ]5 ~8 ~8 l4 L      }4 O! `  S; x$ x1 O" D. |
   else if (document.layers) {# g+ u) @; A! A
      xMax = window.innerWidth;
  K5 d1 O' n( e2 N- S1 h# I      yMax = window.innerHeight;
- m& x5 w/ x" K) |/ K      contentWidth=document.supertext.document.width
. e2 o8 ?2 o& L9 s' K& O      contentHeight=document.supertext.document.height, [+ d3 s$ N% ^; g! R9 |
      document.layers["supertext"].visibility = "show";. z3 l2 v* S# t* W. \4 I( W
      }
- C/ K) {) z: E9 V2 J   setTimeout('moveBall()',400);
$ J4 W" V) A4 N& l$ t) g- ^8 J0 F1 e- i   if (hidetimer!='')
+ R4 s. s- v: q+ X* K; _   setTimeout("hidetext()",hidetimer)% d+ J/ V2 S! i4 ]" @! ?* ]
   }
. i1 ]: d2 ]( h2 V4 ]; \, H9 s- G% l8 Q8 Q4 h
function moveBall() {
5 {- R1 H+ W) @$ N- e   if (superballRunning == true) {* R2 I( t$ J; O% Q4 d0 z+ M/ R
      calculatePosition();5 i. F5 d9 d  Z7 l6 D- |/ h2 [) `
      if (document.all) {0 i: X! d, m8 d# f/ [4 ~( {
         document.all("supertext").style.left = xPos + document.body.scrollLeft;2 ~9 v8 u, i2 R3 J' O; E8 D
         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 ~3 @5 ]& p: H/ o         }9 H/ j+ K+ w8 Q
      else if (document.layers) {, b+ u* V/ L8 X9 K' h
         document.layers["supertext"].left = xPos + pageXOffset;+ E" C2 V8 G( s( O: s
         document.layers["supertext"].top = yPos + pageYOffset;
4 K% m, l2 e% Y+ Q1 ]         }
1 j/ h& o- t& I* F# ]* M      animatetext=setTimeout('moveBall()',20);6 n8 C2 [! v; n; C# U) x% y) t- N
      }
" F0 T+ E; ^: y   }
1 [- Z8 @3 x2 a2 Y  J3 |/ }! C0 |7 c9 ~  P! f, J! D
function calculatePosition() {0 o! ]  ~% _( o1 Y: P! V
   if (xDir == "right") {4 i+ D" Q! O* C2 g* K: ^
      if (xPos > (xMax - contentWidth - BallSpeed)) {  m3 p0 J5 w" `$ r, e  x8 O
         xDir = "left";
, s2 p% t3 C) u; M, l         }: D7 ?- `" L) ?8 p  R' l
      }% y1 e& Y2 t- q
   else if (xDir == "left") {" @: D8 `# @7 l& c
      if (xPos < (0 + BallSpeed)) {3 |# V! I, a/ g
         xDir = "right";
8 u' F8 c/ N% G         }0 Z+ L3 ^% S( X+ n/ o2 b# ~
      }
# c9 Y2 @& {1 X; {5 H   if (yDir == "down") {
, {; c% f# S# c1 H7 G1 q      if (yPos > (yMax - contentHeight - BallSpeed)) {9 t+ U- N! T+ u# ^3 h
         yDir = "up";
/ Q( J8 f8 a7 Y, ?         }* E1 V, c1 g: t! W" J
      }7 i% w0 n0 Y$ i3 o* V+ W
   else if (yDir == "up") {, U2 H. L2 w4 `" R- z
      if (yPos < (0 + BallSpeed)) {! I) O1 h, U+ w! r
         yDir = "down";
( u0 C( c* P% `* }; I         }$ U- Y. P* T  @3 n- p0 N
      }3 J) E2 E9 ?" ^7 k: U
   if (xDir == "right") {
6 ]( p3 `: T* d6 S' K8 w      xPos = xPos + BallSpeed;
- S9 V  ^# D7 @+ Q% \6 K) x2 Q& W      }
4 ]$ x! l% k( \: a6 z$ R" w. K   else if (xDir == "left") {
5 R6 k, }3 v6 k; e0 Y3 {: y2 \      xPos = xPos - BallSpeed;
0 L# c8 o9 W- t9 o      }
' N1 @$ T2 g/ Q" Q   else {" o0 X! t4 v0 g
      xPos = xPos;( S. y2 P$ p1 N2 Y, E1 R3 V
      }8 w/ o/ e$ Q9 a( e* T1 Q
   if (yDir == "down") {
* j& e3 W0 Z2 M; T5 m% Y( `      yPos = yPos + BallSpeed;4 E" o5 d" d. B' F: ]) c
      }- A! `3 h/ Q% ~5 ~
   else if (yDir == "up") {
' B/ L! S& S* K% c# X      yPos = yPos - BallSpeed;- r4 k) t; @4 O- k5 O
      }
; e4 [3 T0 m) x7 F* y4 H   else {& e, i: p+ x- r
      yPos = yPos;3 g+ C5 V' k/ Q1 e: @2 U+ V
      }
% {; o# o% b  q, @4 t2 z   }
8 c0 \! p/ l* K! W& l$ H5 ?# R. r' q6 Q1 @* \9 I" d  ~
function hidetext(){/ F: s/ e. m  ^/ V( _
if (document.all)7 l% @% B1 _# A( i4 f6 ?  X
supertext.style.visibility="hidden"
7 d8 \: R& G; q3 |else if (document.layers)
# k4 p1 R8 Z1 n* d& X) [. \+ L+ ldocument.supertext.visibility="hide"+ [  u% _4 [# ]4 g6 i
clearTimeout(animatetext)/ ^! R2 k- I3 ]2 }
}( _  T; h$ d6 n5 |1 |

, E+ V4 h* F$ V6 B2 L; A& vif (document.all||document.layers){% c1 C# P! I: E! M* ~" |
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')6 Y. m- o' v3 t  {
window.onload = initializeBall;
5 y5 W) d, c& B- Z6 D. c# q' Qwindow.onresize = new Function("window.location.reload()");
# p5 [, @5 D3 C" D) y}. }0 P6 [. [* f& O
. E, e+ P, A, f" g
</script>

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