返回列表 发帖

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

<style type="text/css">+ h& B3 O' }* `6 D& D+ `4 e
#supertext {  u: e9 H! o. ]  {8 q* a
position:absolute;6 {! v( P- A+ {- t! x; y# w
left:0;
6 l6 M( W$ V' a7 e1 wtop:0;
$ i% `( D# n) e( M; a# [" c- I- gvisibility:hide;9 S8 U- k) {% i( q  @! k9 k4 T1 ?
visibility:hidden;/ A* m, W! F3 Z2 ^  Q: R; d( s
}% a. {! |5 Z$ `2 P6 a+ A
</style>* y+ I, F! a- Q6 T# D% x
<script language="JavaScript1.2">5 V/ p& m% z, }! L5 x
<!-- 改变下的字体的大小。颜色-->
# w( h0 ?1 o0 G( G& ~var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. y& D1 l( I& ^! e$ f7 m! f% Yvar hidetimer='';+ H% h6 A* ]6 X/ ~( L1 J
<!-- 改变下的弹跳速度-->
% ?  m" a9 J) L# D9 m2 a  N& G) Svar BallSpeed = 20;
. J' \) p, [9 B$ cvar contentWidth;+ O8 [5 J: H2 O6 r
var contentHeight;
6 G1 L# j; }9 f4 z7 q5 kvar maxBallSpeed = 50;
7 z: f' B% `5 k& M2 ?0 r7 w4 H3 D# _
0 `/ _: ]1 x7 b9 P% x. i7 L- {$ ~
var xMax;
) E9 H: `. `! T0 C8 b8 wvar yMax;2 C. D7 t7 w; [- e. |
var xPos = 0;! b) Y4 d+ v3 p# b4 N( c
var yPos = 0;
6 X) X0 J: r; g' yvar xDir = 'right';
  I% C1 Y# z9 z  Y% svar yDir = 'down';7 J4 u  }3 f6 f/ p9 j
var superballRunning = true;* M  I+ D; [3 L2 O% d! u
var tempBallSpeed;
8 x7 c# U. `9 N. y; svar currentBallSrc;4 C: Y9 v7 t& e7 O" x) Y  O: w% V
var newXDir;, ]0 d5 m1 A) J, H
var newYDir;- l# R( e* Q1 [+ y% U! Q; P) L
% \, R+ X% D& m2 j) O
function initializeBall() {
, B& g$ w+ b+ t   if (document.all) {
8 }" \* }& T" t+ t      xMax = document.body.clientWidth
) c$ G  H. l. N3 ^# X      yMax = document.body.clientHeight9 L5 @: M" |& N3 u4 k
      document.all("supertext").style.visibility = "visible";
& Y+ _2 V9 T# r/ ^2 i; V! V      contentWidth=supertext.offsetWidth" ^0 a' `) q) f  X
      contentHeight=supertext.offsetHeight7 h. j: C. k) w( k0 q7 f/ F, D% b
      }, f5 Z# V$ M' ?5 Z4 V4 \8 H/ t
   else if (document.layers) {6 E4 W  x3 D( Y! C# k
      xMax = window.innerWidth;
9 w2 L( E, _" t4 Q. I      yMax = window.innerHeight;
0 q1 p5 k; V0 B& E% q9 W3 j4 S      contentWidth=document.supertext.document.width
4 G: N- w) ~; `      contentHeight=document.supertext.document.height
& Y! k3 d6 k; U. ]& z      document.layers["supertext"].visibility = "show";. [" |  H2 b' I- M1 n! p
      }" p( Q; _9 g; ]! w' d2 C8 Y
   setTimeout('moveBall()',400);
$ |) x) _  ?2 V# U1 k) H+ o1 x   if (hidetimer!='')
- |" y6 [5 ~4 r7 \8 G3 i+ i' K# H   setTimeout("hidetext()",hidetimer)) z4 D% k* W) S2 y) U& s5 q
   }
0 e3 C4 {! m0 K, ]5 U* u! w+ T+ S5 A8 {; @; O7 `
function moveBall() {
# k3 ?$ K; q1 ]- z( ]" J   if (superballRunning == true) {
$ ~2 n! i3 P. F+ _      calculatePosition();: T7 ^* F9 w3 u; E4 l! ^3 ]1 ~  u
      if (document.all) {
$ A& k* a; {' S0 A0 P5 b3 o& P         document.all("supertext").style.left = xPos + document.body.scrollLeft;
( B9 r7 \( u/ m$ h6 a( {7 B         document.all("supertext").style.top = yPos + document.body.scrollTop;
0 H0 H; b" A1 {# I6 P         }1 b9 c6 Y$ G3 j* e" E
      else if (document.layers) {
- t! m9 d; _6 M6 v         document.layers["supertext"].left = xPos + pageXOffset;- `7 o3 U/ ]( q* O5 @9 D% ]0 f
         document.layers["supertext"].top = yPos + pageYOffset;
$ _% N8 o$ [9 R9 [: ^- ]         }6 Z$ W% p2 ]5 z7 W
      animatetext=setTimeout('moveBall()',20);
! q* j. {' h7 V/ k4 f5 M7 L      }
1 D; n4 w: q! M5 d; d   }
0 B6 E2 i, W& m2 C1 X  D7 Q" ^1 W; v9 O4 U  J4 K
function calculatePosition() {
5 r4 c7 o; T- o; F   if (xDir == "right") {0 O* {$ o- P; w$ M
      if (xPos > (xMax - contentWidth - BallSpeed)) {: y, u; U$ y4 `; }2 E
         xDir = "left";; O; J; a" Y  a' \
         }4 Q1 z5 E2 |$ c4 U
      }
2 p* i0 k. C, ~' x+ P$ ]7 T   else if (xDir == "left") {1 r7 T6 E3 c. O4 V& n4 Y
      if (xPos < (0 + BallSpeed)) {
1 ^) `& E- P3 X1 ]- j0 F         xDir = "right";9 c8 c. R. @+ N9 y$ P1 D. K& U
         }% P4 z% p" @9 f. |. Z8 |: V
      }4 j7 d$ J# j3 b: D1 z  M
   if (yDir == "down") {& n  Z9 `; j9 ?  H" f! K9 ]
      if (yPos > (yMax - contentHeight - BallSpeed)) {( |' v1 _" {6 R- W
         yDir = "up";
5 ]/ S8 u1 M0 W0 j         }
, l6 ?* h+ w- O) o- T7 g' d      }5 e2 y8 o* U& z: n  U
   else if (yDir == "up") {
& ^: I+ S6 S  W& ]7 _, X' U      if (yPos < (0 + BallSpeed)) {
0 X" l2 X2 k5 D* E$ O         yDir = "down";' z+ K. y& V4 h- c* ~: }
         }  l: l1 J+ {) j7 N) w4 @# l
      }
. E- ]+ ?0 x6 _2 \6 p   if (xDir == "right") {6 Z; v4 a) V" A9 ~" O
      xPos = xPos + BallSpeed;+ f2 m: Q! s2 ]) g! y5 P
      }( j6 c$ V9 o' V: J7 U
   else if (xDir == "left") {
6 h! L' C# A  n      xPos = xPos - BallSpeed;- c: F2 Z, e  Z" w% r. Y, L
      }: w- Q+ _6 p1 O  B. i* h( A5 O- p8 m
   else {
8 Q0 _& H; S2 d      xPos = xPos;& J& a5 t; p9 I) G
      }! s! L% r7 E9 x2 e) U* H+ i
   if (yDir == "down") {
( }+ W" K# a) i      yPos = yPos + BallSpeed;
# b: x+ t2 _: ]% J6 Y' u      }
! e: V1 A! n3 A3 s1 e1 ]3 o   else if (yDir == "up") {3 Q; I' S4 z  g: Y. t
      yPos = yPos - BallSpeed;# q- }( X1 B6 K! j7 D& M- b# S
      }
: l. X& T# g4 i0 D; X/ C1 ?   else {
& o4 T8 b" w( z$ O2 X      yPos = yPos;
/ {! K. |7 R$ m! J      }
9 L4 w$ B/ \" m   }& y5 C" c3 D/ _$ p6 N/ Z

- {& n2 |/ s  ]& W! i2 ?' Pfunction hidetext(){
6 p5 ^! W3 F) P. Z, ~if (document.all)+ S; _) k1 n$ q, g
supertext.style.visibility="hidden"
% Y; K/ I6 h5 ]. i# y, k4 Velse if (document.layers)
9 l. l6 C% w$ ?2 T6 j4 O$ idocument.supertext.visibility="hide"7 ?/ ?# x2 L, B5 `, |, W, C
clearTimeout(animatetext)9 {$ m: \1 D3 P# l/ D
}
3 v" D6 W& v5 \) ?4 n% ~0 O/ i0 F5 Z1 S& C' j3 x: D$ s% z* K3 F( V
if (document.all||document.layers){
# J# X7 w( U6 S6 K* Hdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')( A9 |& J, u, ~2 Y3 z
window.onload = initializeBall;
/ j- u7 I, e& c! G" p4 i* Iwindow.onresize = new Function("window.location.reload()");
' ]& E' b% L  l& n: C}
/ e4 ~8 Z9 B5 E7 T: M7 d; @7 k# d! ^, N, V, a& g
</script>

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