获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">
6 U9 S4 l" S' L, m/ e) a$ y7 A#supertext {
/ z) d" Q6 H" J$ Qposition:absolute;
( x0 ]1 @" \( rleft:0;% B8 i1 N, ^( F. }) k" m9 d3 Z4 S3 p! C
top:0;, {# G6 r6 \1 i9 {. f+ n$ m
visibility:hide;
3 X! F& n# }# U5 Nvisibility:hidden;! c/ F+ w7 c3 I5 n
}
  P, {, ]. V0 k" J. p</style>
/ F' f5 H2 \9 ~; ~<script language="JavaScript1.2">
+ p. V5 |/ }5 F) {* A, W<!-- 改变下的字体的大小。颜色-->2 x! g. }  e7 n
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 [- A; \* o2 O/ v! ovar hidetimer='';% h% }5 W0 F+ d- p7 y8 o
<!-- 改变下的弹跳速度-->' T* ~7 p5 R( u+ F
var BallSpeed = 20;. M  s- f3 z8 Y3 w
var contentWidth;/ A. L1 R6 g4 P# M
var contentHeight;
* T1 c( [; ^0 e4 X- }var maxBallSpeed = 50;
* E9 O; z- J$ T$ e1 }, |! y3 o3 \! Y# T( u
% r+ U( R# H/ P/ R
var xMax;
* ], h7 x& d+ V$ k0 ]' ?- ^2 nvar yMax;! {' J# f4 K$ C5 Y5 h* V
var xPos = 0;
$ x/ \( ^) y) evar yPos = 0;0 L3 ?: x% S; C, e9 y. o
var xDir = 'right';' o! F) ^$ I: J3 c
var yDir = 'down';
4 w8 J% i. P0 Z. Ivar superballRunning = true;
7 M0 V) w* P& h# n3 J* Ivar tempBallSpeed;. G1 q$ ~0 d7 R/ g" h( y+ N
var currentBallSrc;
7 _7 n: b& W, R* H1 e+ Evar newXDir;
$ X1 ?$ p! A: s1 Fvar newYDir;
+ ]9 r5 C0 v% k) Q5 }  w, a9 v' r+ j5 \, o6 ]4 N
function initializeBall() {
# M0 \; W- |1 F7 }) `/ q   if (document.all) {. o+ R$ y0 b6 r5 W, r" J
      xMax = document.body.clientWidth
/ [7 y3 ^* I- `5 y      yMax = document.body.clientHeight0 ~6 Z1 |- \7 X. V& C, F4 X% ^
      document.all("supertext").style.visibility = "visible";
# L. e4 [  f; l3 H& t8 m      contentWidth=supertext.offsetWidth
! `7 d, _$ x+ \8 [0 D5 z+ D      contentHeight=supertext.offsetHeight9 o5 c0 [' K$ e# c
      }
, S6 P& L1 P- g5 d6 ^% L' n- j   else if (document.layers) {6 @* V2 F! r: P) z  Q: ~; S
      xMax = window.innerWidth;
2 f2 I0 n& S# n1 Z1 ?; h0 m      yMax = window.innerHeight;7 ]( k+ P5 U1 C
      contentWidth=document.supertext.document.width8 t0 T" W7 \; N* a" w2 Q4 l% l2 G
      contentHeight=document.supertext.document.height
6 ^" A5 h% c; \1 _      document.layers["supertext"].visibility = "show";6 g% P1 D  [% W1 X8 z
      }4 ^$ I# [0 ]; _5 I, @& p9 o
   setTimeout('moveBall()',400);
' h' D% q+ w# D# b   if (hidetimer!='')# ]2 s' h6 d1 M) `. Z
   setTimeout("hidetext()",hidetimer)
: M4 _! s9 k3 |( S   }  K7 n: I8 ]- N1 w& y
8 I+ @! n+ \9 H$ t
function moveBall() {, r1 Z" p9 k" f# w2 R$ z; n
   if (superballRunning == true) {; o8 k' C- ^$ l
      calculatePosition();
  k. ^" ?& |% Q3 Z! G7 H- F+ X      if (document.all) {: Q1 {8 F# V) }" m( {$ V+ U3 a
         document.all("supertext").style.left = xPos + document.body.scrollLeft;" j+ V' F: Z# o: `: `4 h; N5 o* L/ A
         document.all("supertext").style.top = yPos + document.body.scrollTop;
, N$ Z9 h* r# d9 K         }- o" j+ T6 k) _: L9 u$ U& x" ~
      else if (document.layers) {5 l2 g: U2 Y0 W* L# C* D
         document.layers["supertext"].left = xPos + pageXOffset;
0 K. a$ y# P8 i1 v! c5 [9 [6 x         document.layers["supertext"].top = yPos + pageYOffset;% m$ _! m" g9 r: u
         }
: z8 |7 P6 ?/ c! c/ v8 B      animatetext=setTimeout('moveBall()',20);
' N! e( r# n  J      }' \: Z3 a2 b$ L! n! a9 i
   }  n0 J5 H# n8 D2 ?$ Y& {6 L9 S

, M% ~3 }8 n/ P" g0 D# Xfunction calculatePosition() {" z2 }( T6 M" u8 T
   if (xDir == "right") {/ e% h4 ^, r: u5 I+ o
      if (xPos > (xMax - contentWidth - BallSpeed)) {
- ^. _- t- [3 J6 w4 l3 P( t         xDir = "left";
- N" n! Q0 M9 D; u' g6 X0 [$ z         }: l; H8 N. k5 f9 x) a: Z7 ~
      }
# Q$ r* J% y* h# r" `   else if (xDir == "left") {- ?) Q9 M& s# w# _$ |# m" u
      if (xPos < (0 + BallSpeed)) {
2 M  \5 V4 |: z/ k         xDir = "right";! x* m& u+ S' q9 u
         }
( u& I6 G  t' l( F1 w1 D5 Q      }
- J& A2 r& y( g( \   if (yDir == "down") {+ H* g* g4 o# G- [- J. g0 |1 s: R: j3 \+ V
      if (yPos > (yMax - contentHeight - BallSpeed)) {
1 T: p0 ~- ^/ ~, O" \. v% {9 O         yDir = "up";
7 b1 }1 F& L6 F- J         }5 t3 Z) M" P# y  f; h0 k' ?
      }
* K8 u: H& U4 M" M0 I( ~# e  Y   else if (yDir == "up") {
+ c. U, h6 j7 j. C/ ?      if (yPos < (0 + BallSpeed)) {/ J) y( @, o0 |9 M
         yDir = "down";* @/ z$ }" V0 Z, _" u$ j" ?1 ]  ~$ d
         }
2 N3 \; d! ^: r, r8 z% U      }5 T! s, ]( B! D* z( C% \
   if (xDir == "right") {, M  p4 v( J& S& @% _- p4 _
      xPos = xPos + BallSpeed;
4 G8 a; j+ G( {- _5 o      }
: h+ i8 X$ F$ x+ g   else if (xDir == "left") {
8 ^4 G7 B, u, G, \      xPos = xPos - BallSpeed;* S) l" h) h9 a- n+ `. `8 G
      }0 K# v1 B0 J% n3 A
   else {
+ ?5 u+ m6 L7 O      xPos = xPos;
- ^9 d  r- h; _      }1 c/ U1 |9 t0 x/ G1 i' V$ l# h/ n
   if (yDir == "down") {. B' I% k  Q# ]6 k
      yPos = yPos + BallSpeed;
5 M% X' y9 p; M7 T7 w2 r% O      }
0 i" Z  i8 y, m2 g5 A   else if (yDir == "up") {
+ A6 T. v& E6 C6 K$ P( ~      yPos = yPos - BallSpeed;2 g" P0 T0 @6 K( z" r% P
      }* q! M+ G9 g" I, U, `9 D3 B$ e
   else {- \1 G2 y8 H1 ?  h
      yPos = yPos;$ y' U5 _$ j8 i- ~( j
      }. t5 ~+ e% u  @: i% R7 k6 H1 A0 Y  n1 h
   }5 j5 Q( d$ F' y7 m; l% s
0 y- s( @3 z8 o" E& G7 l
function hidetext(){
( I; M5 w, H1 F0 h2 w7 ~  Nif (document.all)
$ f# [0 Y# ~2 P- m7 gsupertext.style.visibility="hidden"
/ q! g4 z! M, ?8 S3 helse if (document.layers)5 {; [; P5 `# ?2 O. J8 v7 e
document.supertext.visibility="hide": z. h& i+ m  a0 C  s6 _
clearTimeout(animatetext)
! J" P7 e; L8 Q. J. X2 m) C}9 u- D8 C+ U( {; f

" Q( b, p' p7 T" q# R, {  \+ uif (document.all||document.layers){* S; W7 E, i( v8 {
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 Q) }4 ?7 b5 Lwindow.onload = initializeBall;5 V+ W: W  J7 W7 G& g! N
window.onresize = new Function("window.location.reload()");
8 P6 z0 s, e1 X% |) \}# r/ ^- \* [2 `

* R' _) S% b9 r* ?$ G. n& H* E</script>

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