返回列表 发帖

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

<style type="text/css">
- J! Q; u# r; Y#supertext {$ q& c) t" a5 _: _, F9 s5 g
position:absolute;& p2 @  I/ k& y. d/ x
left:0;
* {+ A4 d9 x' |; w7 ]top:0;
0 Z7 }1 K$ u4 T  @  gvisibility:hide;
6 x5 @, h" d2 j& ]( r& Yvisibility:hidden;
$ m5 I! j+ ?8 R}
- s5 S: O' A2 T! f6 _</style>5 r: m! i4 B. r+ I' e" ]
<script language="JavaScript1.2">4 u/ ^( u, k: D) j4 h6 N( a
<!-- 改变下的字体的大小。颜色-->
" Z" M) T  F& @3 \  l1 dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* {  S8 Y# T4 |var hidetimer='';
. M* @* O* o5 ]! j8 Q, X<!-- 改变下的弹跳速度-->; E! G; u2 ^! B  J
var BallSpeed = 20;
# s2 v8 ]! ~, a% t: Hvar contentWidth;
% z' u) W/ v7 v) uvar contentHeight;
  |2 u* Y1 c' uvar maxBallSpeed = 50;
9 m8 r+ M5 n/ ?, g, M8 u
( F) k) L2 d& `) _0 g4 ]$ H9 c* z" J. k
var xMax;
6 S' Y) M3 ~, j5 t+ Jvar yMax;
; W  d! w' l5 f$ L& i/ Qvar xPos = 0;9 d8 v: u, g( K. x' H  V+ a
var yPos = 0;5 T! K% E% c3 N% [
var xDir = 'right';3 Y7 Q, R$ b5 j& H
var yDir = 'down';  l) B5 g6 g% `2 l/ S
var superballRunning = true;
: }+ C* ^3 a1 t8 j3 s7 ?var tempBallSpeed;
; E# D6 T* k: ~var currentBallSrc;; x- D3 Y" B- d& G
var newXDir;6 R% H+ w! s$ f  q
var newYDir;; j. O. N+ K, A5 \9 K5 s

& o! l; e  R! Y' b& xfunction initializeBall() {
! o  T# L" w# ^3 g( K! D% p9 S   if (document.all) {
1 b" D) b$ C6 u, T4 T      xMax = document.body.clientWidth1 K4 y* W& w0 l  M; ?6 e3 n
      yMax = document.body.clientHeight% v& _& E; h! ]- w  X
      document.all("supertext").style.visibility = "visible";
! M, b! a7 V8 I$ z! p      contentWidth=supertext.offsetWidth
4 h$ E0 ~# q" Y. R/ x      contentHeight=supertext.offsetHeight
: v+ F" o8 A: p* f0 W  D3 M      }
$ R4 g; Y; D6 h* ^$ s   else if (document.layers) {
: X  \* C' W9 S' f      xMax = window.innerWidth;, ~8 h9 y1 N& ]; X9 q5 a: d
      yMax = window.innerHeight;
5 P, h; [) E- u$ s8 _8 J      contentWidth=document.supertext.document.width9 m9 z* Z/ W7 N$ A7 @( z. r
      contentHeight=document.supertext.document.height+ d3 m" N' @7 \
      document.layers["supertext"].visibility = "show";
( C9 C; b+ M& P/ [9 x+ v# Y2 G0 \      }
% {5 y! C' Y, ~3 E' M   setTimeout('moveBall()',400);2 n+ M( s5 C5 ~% h- J
   if (hidetimer!='')6 Y! K! z) Y! Y  v# c7 ~! ~
   setTimeout("hidetext()",hidetimer)
9 R$ `; N# y; f7 K1 Y" K4 k   }4 R- y  J  s" W( b7 U8 Y6 b0 |- I& z! T2 z
5 h* P- e# V1 D9 p0 ~
function moveBall() {0 X  H( S0 t+ H
   if (superballRunning == true) {, \# j$ G/ Q9 T- `
      calculatePosition();
$ P( x% f7 S2 m; P( k9 |" t( o      if (document.all) {0 V1 E/ u7 f2 ?
         document.all("supertext").style.left = xPos + document.body.scrollLeft;2 ]$ W- S, a" E" p. W6 G5 e
         document.all("supertext").style.top = yPos + document.body.scrollTop;
- }) `) }# W* `+ M+ `4 P         }
8 y  J3 Q9 N; F6 a& T      else if (document.layers) {
1 y- t- t( e5 Z& Z2 T& l; Q$ i: m         document.layers["supertext"].left = xPos + pageXOffset;; N, W3 j# |+ @* m- g4 K/ M
         document.layers["supertext"].top = yPos + pageYOffset;3 ^/ K$ w+ g/ }
         }. @1 Q% q9 D% \
      animatetext=setTimeout('moveBall()',20);, l' i% A! w/ y5 q
      }: F: S; g1 W* t8 h; `
   }
* a% n$ X7 D9 C' ]" f
6 m, p! @. e! L* N& q% ^0 H, Y! ?function calculatePosition() {
+ X# |3 L% E# {9 f4 |7 S1 w# K. s   if (xDir == "right") {) O( ^7 `# l0 @* c) N# O+ ~
      if (xPos > (xMax - contentWidth - BallSpeed)) {
$ H! Q+ T& _, S7 q+ D         xDir = "left";5 t' p: `& t; u& U$ O! w0 m
         }
, g/ a- D+ J5 f$ w0 Y      }- M$ g' G# a  q+ L& o
   else if (xDir == "left") {# U  O5 l6 z6 A% B- t2 J
      if (xPos < (0 + BallSpeed)) {' `5 X, l; }$ U& j! C
         xDir = "right";
' K* @2 _( X. c8 q$ Y         }1 n- C! L4 A: C: t
      }
* M  X1 Q: a* g% K& H. d# |& k1 [   if (yDir == "down") {. P$ B5 U: w: X1 }) M7 T6 s
      if (yPos > (yMax - contentHeight - BallSpeed)) {. H$ t+ @5 N& ^% P, V
         yDir = "up";
3 G, D  |: s- ]% P" j1 s2 p% l         }
  ?/ e0 v# u$ ?. a, Y      }
6 u, w, A2 Y7 I   else if (yDir == "up") {
/ z+ g/ Q; Z. n2 n: W      if (yPos < (0 + BallSpeed)) {- v. [$ Z1 I6 F& x
         yDir = "down";2 d; {3 `; o$ ]+ o7 Z' K
         }
; y. l+ T; Z6 y+ N" Q, G      }5 Z, }. D" O. b/ w+ y$ X  |
   if (xDir == "right") {
# L& Z1 I7 e7 {! }# D! N      xPos = xPos + BallSpeed;
: w! B7 q2 i7 c0 W: r6 Y2 `- h! V      }
$ H: F2 H: C, x' B' `5 [   else if (xDir == "left") {
5 I9 M  `% i7 j* ]$ v      xPos = xPos - BallSpeed;
: N1 E+ N+ ]3 n8 L8 H      }
: _% X  E& ]4 \6 {. I! {9 X   else {
1 B- ]9 Y; m+ D3 M, }  l4 j- ]      xPos = xPos;3 }; v+ U' v; ^! e  g2 s+ a- u
      }# [, T" O' z* }
   if (yDir == "down") {" Q" t) L* W" G* o% `
      yPos = yPos + BallSpeed;6 F7 S* x" X# B/ @% x
      }+ V( i+ y; T/ u3 C) _; G5 [, b
   else if (yDir == "up") {
% t; y! z- B) E& l' Y      yPos = yPos - BallSpeed;3 p1 I/ z% w! Q* A
      }
9 n( ?. u# T' N9 V0 y! h9 t   else {
3 o5 u  l. w, L5 Q& W2 ^( t      yPos = yPos;
4 t+ E# d8 X1 E4 y4 \; ^2 J+ k% S. Q5 j      }7 ^( w( Y6 i; z4 G  D" O
   }
' M1 p5 l8 m9 [+ L4 d9 V
0 v) X5 I$ Q. T# P4 Sfunction hidetext(){
9 c. f- R- J) Nif (document.all)
, X# |  a6 c% fsupertext.style.visibility="hidden"- T+ A2 v$ [9 {( o0 q5 |
else if (document.layers)
# H2 n) m, a0 r1 r' ~document.supertext.visibility="hide"
' m/ v: B, D! E* j# H4 ^+ S1 J6 z6 TclearTimeout(animatetext)- p9 j/ f& ~3 i* H9 ~8 b
}
0 p+ [% m* N! `- u, ^7 |1 o+ y2 A  P
if (document.all||document.layers){
3 G8 [6 s9 r# N1 o8 K/ Jdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ b( k( C2 {; z5 i
window.onload = initializeBall;: V2 @; I  a% a% x
window.onresize = new Function("window.location.reload()");" z& ^6 `: Z3 i  c( I* ?0 B
}# `2 V# B2 ?7 G! g7 F& A. p

4 K6 Y8 ~  a2 G- o</script>

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