返回列表 发帖

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

<style type="text/css">% B# j  c+ }/ ]; ~( o2 K' w
#supertext {
4 g" h) v/ C7 J2 h) ]position:absolute;' \3 h, C* ^. [4 L
left:0;
' f$ k, M7 U/ M1 C  Qtop:0;
" _* W0 y( w8 N0 G: f) g" kvisibility:hide;
9 ?& m) c" C# cvisibility:hidden;
  U  k# ~3 |8 k, Y; ^2 k}
4 l" k; T2 a6 c& P% V</style># D. \. T( N5 A: x' p9 ]
<script language="JavaScript1.2">6 b0 D/ d6 J; @( m1 i
<!-- 改变下的字体的大小。颜色-->" j9 c- E% ]' z3 f. b
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
  g2 ~! P2 T  c6 L0 ^6 nvar hidetimer='';- r. m! d2 F. A" O$ Y% D
<!-- 改变下的弹跳速度-->6 }3 ]9 Z! i7 G; l9 `& k4 A+ S
var BallSpeed = 20;% x; l( k& M2 f- S3 S8 @
var contentWidth;
/ T6 g+ }2 a5 e$ mvar contentHeight;5 G  w# X2 E( o1 a9 w$ s2 `& f# X
var maxBallSpeed = 50;
9 I; h$ Q6 E, S+ N( N) v0 ^/ W% I, m9 D; [" `9 F
6 {, Z( }5 s5 I, N2 S0 s( t0 Q
var xMax;6 u. s# S6 l) E7 n6 r' z( e( C5 |
var yMax;# \" {( D( K7 L: x* Q* J+ v
var xPos = 0;1 h  Q0 n/ F' K) \3 x" x
var yPos = 0;. Z+ w  m! B( B& G8 y
var xDir = 'right';
  g) g% s8 m$ m. z) g1 _; \/ ivar yDir = 'down';+ g0 J7 F. ]. ~+ d. I5 N
var superballRunning = true;2 z$ l+ }& L3 ^3 L& n
var tempBallSpeed;
& l3 [. G8 j, W$ ^8 M/ D( h8 O8 f# F) w; Zvar currentBallSrc;
; u4 e( B7 S. L$ ?6 z5 B- }4 Rvar newXDir;
# T( O. u7 `0 Lvar newYDir;( \& X- O" w. C  ]  }1 j( @+ s
: G3 ]$ r9 C0 H! F. J. h1 K  r3 W
function initializeBall() {
1 t+ k/ _( f. g( _   if (document.all) {
6 k7 L: E& |7 m) V3 }      xMax = document.body.clientWidth: h: y  y, X! z; _5 m( H
      yMax = document.body.clientHeight% b1 I; R. _. z; h
      document.all("supertext").style.visibility = "visible";
9 Z: d' c) A1 _; ]$ v      contentWidth=supertext.offsetWidth
  X+ j! F1 Q- }8 L      contentHeight=supertext.offsetHeight
: R4 {. q, T( [& c: i% |      }/ @7 ~" h: ^! I5 i( ~, Z( H2 [3 g0 M
   else if (document.layers) {
3 f, q! `9 \' R1 V      xMax = window.innerWidth;
; f3 }. p5 Z: ?: x( t9 E      yMax = window.innerHeight;
% y$ |  Q0 v) ?# b; x* w1 @      contentWidth=document.supertext.document.width/ z, S4 @: t/ C9 S0 k) P2 m
      contentHeight=document.supertext.document.height
9 o7 L$ e0 y6 a2 D" b4 Q) ~! q      document.layers["supertext"].visibility = "show";
( I3 y5 H$ W2 O! i# t/ \4 |- f7 U: y/ S      }2 }* \' }1 ~  i; [! V8 L
   setTimeout('moveBall()',400);. P- a, y' m6 R% b
   if (hidetimer!='')
' B3 _! W; ?0 a( ?   setTimeout("hidetext()",hidetimer)
3 s* J4 S0 q0 Z8 i- n% ~6 y   }5 P9 m6 i9 C$ X, }
% n9 o( e$ w2 [; C; b" \0 H7 R
function moveBall() {! [# G  _" C2 [3 O
   if (superballRunning == true) {
: b& ?) F& D- u5 Z( j- `) T      calculatePosition();8 }& ~* X  A# v4 W: |$ _
      if (document.all) {. V# e3 K7 A: |) t) |( K. w
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
% D9 J& B) R' `' h$ p         document.all("supertext").style.top = yPos + document.body.scrollTop;
3 x) _# f# R+ v$ n$ M. `, n5 P         }9 |  F. x  A- U' p$ B
      else if (document.layers) {1 u$ l$ }- P3 ?# F- Y9 Q  G
         document.layers["supertext"].left = xPos + pageXOffset;3 B+ D0 e' W# `  d0 P
         document.layers["supertext"].top = yPos + pageYOffset;
9 M0 I3 O7 o  K% x' j4 r1 E3 p: l( d         }9 Z1 L* L* D* V+ M" V
      animatetext=setTimeout('moveBall()',20);3 }8 F0 `$ ?: j; g, m& l: U) D
      }, r* D0 W1 |; c+ J, D' G$ a
   }( l9 R  k2 c' G# V5 p
8 m: L9 _, I8 _8 Z' b, x0 Z
function calculatePosition() {
  x, D, Z& ?9 M4 |7 y0 M9 c1 ~3 w   if (xDir == "right") {  o# I6 [+ S( _2 u: R
      if (xPos > (xMax - contentWidth - BallSpeed)) {/ z/ U& w) v8 C5 L$ m4 Y  V/ `+ e
         xDir = "left";
5 y) _2 Q& W# C         }
1 Y7 Q- t8 T8 g3 T/ }      }
% Q7 y" R$ m; U6 ^+ Q" a  j6 Z   else if (xDir == "left") {9 t9 t- X' m3 ~
      if (xPos < (0 + BallSpeed)) {
- e' `* W% J/ g. N4 }( }         xDir = "right";
8 r$ l; n/ i3 C7 d         }
: A7 z8 [! a$ r; m- U      }
- A; Z1 ?/ x: R   if (yDir == "down") {
* V+ ^, U. |9 a      if (yPos > (yMax - contentHeight - BallSpeed)) {
, v& \+ i$ h" l- L) i# f0 _+ F: x         yDir = "up";
9 Y; F0 w7 {8 s% X% U( ~: f0 H         }
' x8 B, \9 p# H; x9 R$ R+ n% ~0 W      }. E- \- ~* p' O/ g
   else if (yDir == "up") {: B" Q# z7 o& G* e
      if (yPos < (0 + BallSpeed)) {
$ A$ V0 j# s: `3 V; T3 x         yDir = "down";
3 K' u$ `5 j7 d         }( A: C- R1 C. D6 l+ C
      }
$ ~' _% G0 C! }* T) r   if (xDir == "right") {, F# m7 }% r4 z+ W. M9 }
      xPos = xPos + BallSpeed;1 O5 A! O7 }; X( C+ J7 m* m
      }6 |( ?% @; [$ f/ u9 t
   else if (xDir == "left") {
' H( m. l0 q; W+ h+ n& K      xPos = xPos - BallSpeed;% j- [. p" W4 T5 C, i" L& s
      }+ u& I2 c2 N# S& e. i4 n% r
   else {
6 D! M# ~8 n' c. }) w" F# P      xPos = xPos;
9 C8 M. B; D3 K# G% }      }
% I% R4 C$ {6 l6 K) o3 \' r( I; q8 w   if (yDir == "down") {
& ~0 A  @3 [+ L; g1 D7 F/ c% W      yPos = yPos + BallSpeed;) J9 ]3 S& R: `
      }9 |9 E" ^5 f- S/ e0 L8 X
   else if (yDir == "up") {
2 d  u! k1 [: [4 p" L' k      yPos = yPos - BallSpeed;; D7 J, d7 T( E3 H1 V& n
      }# P) u& f% I. a+ k2 t  v- s
   else {! g3 ?9 d% c/ j& `$ i0 B8 p- z: m: R
      yPos = yPos;
& @* h+ Y9 V  P5 s! X. {6 G      }+ H3 M: a5 Y7 g; H2 D
   }; J5 u" W4 s3 t% F1 q4 D) f2 j
" s) p3 A% j' K' C5 I0 X/ x+ k
function hidetext(){0 A" r  A1 P: |: H$ {
if (document.all)( ]/ x6 C, ]) z
supertext.style.visibility="hidden"
& M* y$ B0 {2 Y) velse if (document.layers)
4 l/ i+ F; {/ r/ W2 |  X; Bdocument.supertext.visibility="hide") Q* U- a% i" G# u% J
clearTimeout(animatetext)
* I, W; @6 D" O$ D, L  A9 z1 [/ |}1 f' P" i* p# a/ j) h

9 Q  S: _. @. yif (document.all||document.layers){
6 R# `9 Q9 O6 Z4 idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# N9 o5 q: V7 `& o! R0 U2 J3 Twindow.onload = initializeBall;
% q# T$ G- @" O. F3 U3 ?- u4 b: c* }window.onresize = new Function("window.location.reload()");+ Q0 i4 J2 H) g' n# x' U" ~; k& ]
}
9 o; M. h: d/ V7 ^# Z
. o7 Q+ P% }; a* l. P</script>

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