返回列表 发帖

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

<style type="text/css">' o, u' k. ?9 r, c( _
#supertext {: v& }; p$ o# X1 X1 h
position:absolute;  v0 M0 d0 K/ U  y
left:0;" n: K" p- W$ y- M- |
top:0;
: N2 c* R# }2 L/ j6 P, m  S8 Jvisibility:hide;: a. M# A; b1 I
visibility:hidden;
+ ]% i  j# j9 q. d6 g. ?/ N4 W# r}
7 o  d% s: t- S2 W6 M</style>2 t2 Y! _2 o; ]; @; S3 m
<script language="JavaScript1.2">
7 ~1 ]) u8 [% b& S  e<!-- 改变下的字体的大小。颜色-->- e5 a. G5 g1 E& P& z; ]
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" f  `" T/ O; S; Rvar hidetimer='';* H8 I; ~: L6 @) A
<!-- 改变下的弹跳速度-->
" n" u+ s" a) H" V. h" F8 Fvar BallSpeed = 20;
3 h4 t) Y3 |# \3 \var contentWidth;
" X- S0 p) b' j  }& N" `var contentHeight;4 W" E  k3 s: [% U! `7 j5 x9 P
var maxBallSpeed = 50;
. d1 {$ T7 K0 e% W. `/ w0 }2 b# F) g2 L& k  p; v% B1 d! W. F! }

9 @  O( A# k( F, Q' K0 B: P1 svar xMax;* `1 k3 E$ @) H  D! C
var yMax;
, k  |3 S  J7 ?+ t( W0 q2 M  Dvar xPos = 0;
- M' ]9 ^4 M- |% X& W( S5 n( xvar yPos = 0;
# d& R8 L3 W7 ]9 q( Wvar xDir = 'right';  u8 {6 G7 E1 i$ z
var yDir = 'down';/ }4 _! X! u. y" T7 {2 e( W
var superballRunning = true;
. K; J+ g$ Q8 U5 @  u4 m" d+ avar tempBallSpeed;% o0 x# _( @. n+ c6 {% b
var currentBallSrc;5 F* h! Z4 _3 y
var newXDir;- x+ n2 Y" P% \# l" N, \2 p
var newYDir;/ C+ R. H: N$ B) I5 O
, t5 m( `/ |7 C/ }8 v; D
function initializeBall() {
. K+ q8 z4 ~5 ?7 h% n   if (document.all) {
) }1 `% ?3 s/ Y( O/ ]      xMax = document.body.clientWidth
' \* s$ v( Y# [- h# a" B; i3 Z: k      yMax = document.body.clientHeight( V5 h9 A+ ]/ \6 p8 }
      document.all("supertext").style.visibility = "visible";
7 j7 j: o- [) R8 |& D% n  o0 C      contentWidth=supertext.offsetWidth( U. B/ O' p2 ]) f1 i1 V) a: S( `
      contentHeight=supertext.offsetHeight
. Q4 `; V7 d4 _) t  e" [( H      }0 I, s) f7 r; Q6 T! G* s  v' m
   else if (document.layers) {  K% y! N+ l& v6 R
      xMax = window.innerWidth;
# C  M4 S$ j4 U  u& A5 y      yMax = window.innerHeight;
% Q$ }7 E2 R6 {2 G$ s7 O      contentWidth=document.supertext.document.width
% {/ h3 N9 A- m# [      contentHeight=document.supertext.document.height8 B6 Y& ?6 W2 G& a. t
      document.layers["supertext"].visibility = "show";/ J8 _) L3 j- d2 ~; W. `
      }7 Z- ]4 D$ f6 z2 z  q: Q
   setTimeout('moveBall()',400);9 t9 a0 h0 H' l. W, Y( g
   if (hidetimer!='')
' @/ ]* L$ r( ?) k   setTimeout("hidetext()",hidetimer)9 Q% g6 k5 z3 g% e
   }
0 v+ s& y$ g* u! `; c6 Z- X9 A3 ^0 q; c& j, X$ ]4 q
function moveBall() {- R. o1 D. K+ Z: u- H
   if (superballRunning == true) {
- p" V7 G' F& `: _- `5 `: f9 S      calculatePosition();
8 g% k( S8 k& w$ E$ i      if (document.all) {! h" N. V6 w$ y4 y. T
         document.all("supertext").style.left = xPos + document.body.scrollLeft;9 l9 q0 n  X8 D* H* |
         document.all("supertext").style.top = yPos + document.body.scrollTop;. V; a; M& y. M
         }/ L8 f# K: P9 w* H- D1 k, o8 s) B
      else if (document.layers) {1 ]; H- x! ?; k' w. Q$ k. b
         document.layers["supertext"].left = xPos + pageXOffset;9 B5 w2 R& D8 {& a% K, s' q4 g
         document.layers["supertext"].top = yPos + pageYOffset;. i' o7 g" D4 ^- I8 Z. Y+ O
         }- ~0 Z5 u  O- ~8 J4 N
      animatetext=setTimeout('moveBall()',20);
$ F! Y$ u# \# r3 S; C. i( m      }1 q, V! _# ]" z& Y/ E0 ^8 a
   }1 p( j; K" l( m
& h+ a+ p$ K  O  D1 `3 Y
function calculatePosition() {
  \4 E( i, W. `   if (xDir == "right") {
# g. `+ D. N- J  k/ g      if (xPos > (xMax - contentWidth - BallSpeed)) {0 G. G) I7 q' d" m
         xDir = "left";. `5 j; ~' r  z
         }
# C9 Q* ]6 B  s. `      }
' Z% ^9 j; d' P3 x! y* E1 q2 \6 [, G   else if (xDir == "left") {. `! ^1 D# ]3 M3 W
      if (xPos < (0 + BallSpeed)) {
# j0 {6 v0 b; m+ g: r         xDir = "right";
" G- a# Z- U* t$ [& ]' g5 A  J" E         }0 S' i7 t7 Y$ Z2 }$ D4 ~
      }
' c2 e9 @3 V( W9 p   if (yDir == "down") {6 z! x0 y& Y- U
      if (yPos > (yMax - contentHeight - BallSpeed)) {  R* p; N& U) X' n
         yDir = "up";+ ~" w; H5 K7 M) C, x6 W
         }( U2 w0 l5 R0 `+ ~( A
      }; h3 r$ x) Y7 ]
   else if (yDir == "up") {
( H0 l6 A9 D" S/ I      if (yPos < (0 + BallSpeed)) {# F. x2 {2 ?$ u# k7 d
         yDir = "down";
5 B  b& h) P; x4 m; J) A         }
+ l* Q1 f$ H/ D  {7 G      }
- I. p4 ~% b. o: K, I2 N) D   if (xDir == "right") {# V0 E9 \9 k9 ?
      xPos = xPos + BallSpeed;% k! P6 @5 i- ^
      }
3 J$ ?5 l: z# [( R; e, Z* S8 u: N   else if (xDir == "left") {
" u( t& P. L+ a- p4 P/ b# o+ X* h      xPos = xPos - BallSpeed;* A! `; C3 u! I" R& u( _
      }
/ R0 F: o1 ]* v, b   else {; T6 O' `7 s2 P# i2 S
      xPos = xPos;$ g, }: Q$ j9 z/ E
      }
, @% X% e( U8 i' A/ j1 O# t   if (yDir == "down") {, k* z4 O, p  V
      yPos = yPos + BallSpeed;
( S. I6 K" Q: r1 d* D      }# T% u8 \" v! K0 b# V
   else if (yDir == "up") {
4 ~5 I( n. q2 n3 e, R      yPos = yPos - BallSpeed;
: m) B( S0 ?7 g1 I      }
0 e$ s% U3 C/ |2 C   else {; y& P2 w: Z/ i8 g
      yPos = yPos;
/ {! ]& x3 ~* V. Q      }
$ {' m; Q+ S5 F. J6 |" P; B   }
. @  y% R9 ^3 A2 ]* ?
5 L9 i/ r8 h3 ^! h! Y& Qfunction hidetext(){
+ i; }. T; g+ x2 C) t3 n* v# N' Uif (document.all)% Z& W9 d: ~: m% `0 X# @
supertext.style.visibility="hidden"* n- _0 a/ ?& U% P' u8 Q) f
else if (document.layers)! o5 t4 }8 q4 M# \
document.supertext.visibility="hide"
/ f0 E! @+ ~$ D4 H& vclearTimeout(animatetext)
& i6 e$ g8 Y0 i; P}& ?! d  \# S- Q4 l) G/ K
, E" f' E& n; [) k4 U
if (document.all||document.layers){
7 k) n6 s6 H$ J0 ^4 b+ gdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')# s) j& x1 P. S# p: K& e
window.onload = initializeBall;
' d- u7 B  x2 ?; ]) M1 Xwindow.onresize = new Function("window.location.reload()");
& o9 w, u1 W& ^& }. ~3 B1 @}
3 g. A' T" Z9 P+ s8 R, N: ~" l, U2 H
& k8 p( J7 S% N. |- j</script>

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