返回列表 发帖

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

<style type="text/css">" P8 Z; G* I2 f3 p' c. L, {
#supertext {9 I) ?, i3 a+ K# ?9 ~
position:absolute;
* Q  \9 \. @( X+ M4 e* dleft:0;
! d4 m2 s1 C: ^. w7 b* W2 W, l# N4 _top:0;: ^# T( v, q- [- Y
visibility:hide;' ?! w  m; A" g$ Z
visibility:hidden;
/ h( I4 W5 Z: T, B}9 k8 L! e3 J$ _' l) B% U
</style>
6 M7 ~* q8 h' j5 `8 G, ?& J- D<script language="JavaScript1.2">3 I: A' W9 y. f( X7 U
<!-- 改变下的字体的大小。颜色-->8 {- C5 s: F. |( ^$ k3 V+ y/ f
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'( X7 E$ Z% ]& G8 r/ O7 P. G
var hidetimer='';
/ n4 w5 C  ~" Q3 @; p  `<!-- 改变下的弹跳速度-->
" c4 h- w- L" t1 c" Q( Gvar BallSpeed = 20;; y& @/ Q+ N0 I* R8 x4 J
var contentWidth;
2 o* g8 \) c& @4 }var contentHeight;
. {& n) t6 ]2 `: Ivar maxBallSpeed = 50;/ Y) P- f+ a0 R4 p. o

7 x% `' E# ^4 N" {) M5 ^( r( k4 \* s+ Y' d
var xMax;' L7 L8 s2 D# [" q
var yMax;
+ Q4 n( [. a- d3 J' V/ ~var xPos = 0;
/ L: K: m2 k5 ]# d9 c0 Hvar yPos = 0;- A3 Y5 o" W0 y/ u4 y+ H
var xDir = 'right';& C: \: y, }# h2 B5 j" J- g" G2 d
var yDir = 'down';' j0 G% Q$ e: {  z5 A5 y
var superballRunning = true;
" r0 ^* {6 P/ T3 f; s3 \var tempBallSpeed;
2 B4 h* W7 U4 O* O+ h0 d6 A$ qvar currentBallSrc;0 u; t* h: o4 ], A6 f
var newXDir;
" r7 Q4 C  l' jvar newYDir;
  D; n, n1 ^+ o) _3 V) D: \% v2 D) s  e( ^8 b( o" G1 a
function initializeBall() {2 c! Z+ \- V( m
   if (document.all) {; b. S- ]3 Q7 O, \/ a
      xMax = document.body.clientWidth
6 M% f& ^. Q& h# L! Z      yMax = document.body.clientHeight
% w' q- z# i: g5 c( V; ]; x      document.all("supertext").style.visibility = "visible";" g* S4 T" g# Y2 \  ?4 I
      contentWidth=supertext.offsetWidth& }- p( r/ Y  f7 \; r
      contentHeight=supertext.offsetHeight
/ g, S) f& [1 o8 d      }6 l: t* r! O' H- Q
   else if (document.layers) {; ^+ M3 O. M/ x7 j& o- h" t
      xMax = window.innerWidth;
3 t8 e* A# j5 s. V$ U      yMax = window.innerHeight;
3 i- n: h1 ]6 F0 ?% S5 ?; F/ T      contentWidth=document.supertext.document.width
* X8 Z$ {8 _) A" O0 S, I3 V# n      contentHeight=document.supertext.document.height/ c8 k  F* E7 v& i! \
      document.layers["supertext"].visibility = "show";
- D- @1 O! j8 \  D' }6 l# t/ e+ a      }; R: `7 p. ], c  ^
   setTimeout('moveBall()',400);
% L/ [% F1 N. B   if (hidetimer!='')! i* H9 [* Q# n
   setTimeout("hidetext()",hidetimer)3 O% p$ p0 h- S* O: i6 y
   }+ Z5 i9 r5 V$ o

2 G7 h, \. M& K" c' J% k- H- I6 U0 s: Yfunction moveBall() {& J4 q# M& L& j  F
   if (superballRunning == true) {
! ?; M% k+ b0 J- _& k* C      calculatePosition();
" t8 c/ |1 y6 G: G( J      if (document.all) {
- l: r. n& ^1 a. m         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" k4 A' X  ]# E  Q" u3 s: |6 v& V2 C         document.all("supertext").style.top = yPos + document.body.scrollTop;
5 W. O7 j- `, z         }+ G+ H5 ^% b% Y5 ~% \
      else if (document.layers) {. f$ _9 R& B  R4 o6 V# ~
         document.layers["supertext"].left = xPos + pageXOffset;0 P$ R0 @. }4 C- c% W# X+ M
         document.layers["supertext"].top = yPos + pageYOffset;, y4 O. v7 R( t  N# M* N6 B! ^6 V5 z, _
         }
8 f% m& e! S: p      animatetext=setTimeout('moveBall()',20);
! A9 b5 p) F: l, a" c* g      }8 x5 T. G- x$ S& V. h# G" a
   }
) w0 v7 t. q: a% \# D; I6 X& L. C, d% o; g, z$ W# P$ H
function calculatePosition() {7 B3 w' n2 q; I; ^- m% j* }
   if (xDir == "right") {
. G7 @$ [7 e" h6 f      if (xPos > (xMax - contentWidth - BallSpeed)) {5 P# W% a" R/ c, l
         xDir = "left";/ s' W0 Q+ a& T1 ~0 c, k
         }7 a( e; v0 ]2 v) O$ w8 V  S
      }/ d/ t; v! F( L% w1 N) O7 t
   else if (xDir == "left") {. T9 @# i" K  I, _* `4 o: S" e
      if (xPos < (0 + BallSpeed)) {. o4 R2 z# Y& Y
         xDir = "right";
2 ]9 F1 Q) b* z6 X& h5 w4 `         }8 q. V' g1 b0 [8 D* }9 w8 |
      }
" w" o# p  V  l! \   if (yDir == "down") {7 L% {: _6 O, |# t2 r) q
      if (yPos > (yMax - contentHeight - BallSpeed)) {; q' T! s* d4 t
         yDir = "up";: D, A# b" f4 p% I) C
         }
) j0 h  H; S0 }$ P      }
% @3 R% q+ B9 ~% _- ?' H# D   else if (yDir == "up") {
9 c& B2 {  s1 x6 A) V; ~# p      if (yPos < (0 + BallSpeed)) {
! \* _% O, U; n" C' C% Z         yDir = "down";. t5 r% k) M0 j& C: L
         }
' s# R. T- [# U* C  @7 ~      }* V7 W* S0 C; e' [( M4 {! x
   if (xDir == "right") {
% ]7 i  u( r+ O+ Z      xPos = xPos + BallSpeed;
7 Q; d- M4 a$ u      }
- z& e, X) K( x( R   else if (xDir == "left") {! \" c0 A9 k% {9 t5 Y) B( I
      xPos = xPos - BallSpeed;# e* }( D0 E' e! Z2 H- E( d
      }6 T* b3 k5 h& k" w) z$ g
   else {
. Y, p: W# c% J6 e: t5 c8 a      xPos = xPos;
1 o1 J9 G3 s" p3 c' J      }  b3 q) J& A( _+ t
   if (yDir == "down") {0 G. i, y2 K9 a' i2 X0 k: ]
      yPos = yPos + BallSpeed;
9 {# c. {$ [  z- w4 V" y      }5 _& ?; A9 W% a$ Q) o- g
   else if (yDir == "up") {
/ A; p/ k1 d: v, V3 r, s+ g! @      yPos = yPos - BallSpeed;) o0 [8 Q3 q% Y, E8 C9 a: t5 u) h
      }1 _' p& U. }  Q4 C! ?! T5 t8 [
   else {; D+ T  O7 K1 H( w: Q+ g% k& Q/ V  b% g
      yPos = yPos;8 F" Q$ z4 H* k- e: v  p0 g
      }/ t6 }& n$ T9 `6 H/ S8 w; s
   }
4 M$ Z( _! V2 ^$ I' Y  ?# F8 N! w- z$ z* ~4 S5 W
function hidetext(){
. x5 ~  i9 `8 n. M' _if (document.all)
8 W3 d6 E2 l1 Q8 Esupertext.style.visibility="hidden"
2 y8 `; e+ F; Z+ J+ X5 welse if (document.layers)
; }+ S6 q7 B' K, q) D3 o. sdocument.supertext.visibility="hide"5 |6 a: E5 o8 J  c$ q" T
clearTimeout(animatetext)
! |" W( t/ l) c6 V}) W* Z3 i: k! n9 E! O7 h

# j5 k9 p& S& i+ v6 Q# w8 S2 Tif (document.all||document.layers){, |% b) Y5 |0 i* {4 G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 X6 c1 S. O/ [' [3 z+ }
window.onload = initializeBall;  A9 o' S" N0 L6 u5 ]9 `
window.onresize = new Function("window.location.reload()");
2 X7 G7 T7 t2 ?2 ]) l- g}
& p1 P1 F3 e7 X7 I+ Y/ J  h# a4 O2 D- D5 d/ s5 q2 I* m! w7 X; m, `
</script>

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