返回列表 发帖

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

<style type="text/css">' U3 H9 ~$ T: H
#supertext {5 w8 U6 u. E0 w* c3 }$ H+ l6 }
position:absolute;, Y6 f- z3 c+ [7 `
left:0;
7 B" W# Z3 V3 s. L2 jtop:0;- I- t+ u* Q! P
visibility:hide;
/ m3 }& \5 G4 q# ?visibility:hidden;' W! ~. }6 l: b; q) ^% T! a
}+ W: _, D; X+ }% R3 W
</style>
* |7 Y6 v  |& E/ i- R<script language="JavaScript1.2">
& i4 c2 w- N. ]; S<!-- 改变下的字体的大小。颜色-->: P: b. K: Q+ k4 X; o
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
  e7 N# Q# v2 B) Uvar hidetimer='';" F- [. n% n& u' N$ Y2 E
<!-- 改变下的弹跳速度-->
5 \6 H' d. F) Q, Bvar BallSpeed = 20;8 C: o3 S8 I$ z$ X% x( P
var contentWidth;0 ^$ B9 s( }: H
var contentHeight;
0 S, p+ ^$ q" Y( r* ?% S$ |var maxBallSpeed = 50;
2 Z8 D. r6 z; ^; m# X$ F2 D' {! d% h& z" P2 y7 m

3 j5 M  n9 ^8 W; ?- V" \4 P% \var xMax;) |  k+ w9 Y; n' [
var yMax;
6 o' ?9 Y: z4 t7 b0 vvar xPos = 0;. d2 D( l! x8 y5 c3 T3 s7 C/ d/ M
var yPos = 0;# d7 n  s9 K9 ?/ B( G! I) ]9 A' a% H
var xDir = 'right';- x% L& N" n) P+ T/ x0 l
var yDir = 'down';3 e! o) ?, c8 t+ x/ N9 l. J
var superballRunning = true;
5 _0 f) h7 a' t3 U; N2 Q6 G0 _/ ?8 F5 nvar tempBallSpeed;/ H+ f* e8 t  F: o0 N# u/ v
var currentBallSrc;' a* U9 |! b% c
var newXDir;- U" N, K5 z+ C# @2 W
var newYDir;, z' E' M) P8 j  Q4 N" a
1 `8 g$ o: M$ U. M9 ]5 q
function initializeBall() {
: }/ T  H% S! z+ w* k7 I( b% c+ R   if (document.all) {
8 R6 g% E4 m; |2 e$ r      xMax = document.body.clientWidth
& Z5 e# G# ?/ h* d      yMax = document.body.clientHeight
* w& l3 C/ u4 e: U      document.all("supertext").style.visibility = "visible";
2 Z; p* y0 h  |+ H4 E% x0 i      contentWidth=supertext.offsetWidth
6 g7 ?& l. Q) c% f7 F6 c      contentHeight=supertext.offsetHeight
2 r5 ]9 [6 z2 l% B: g0 ]. {      }
5 S6 R; C9 h! {7 C% A) P   else if (document.layers) {
# {( T# x" Y1 G, K      xMax = window.innerWidth;1 M% g3 T; i- o2 b2 X8 y5 h3 O
      yMax = window.innerHeight;
% k/ o/ A/ G3 K; S% T$ @  P      contentWidth=document.supertext.document.width
3 h0 F9 p7 w5 P: P5 x$ f      contentHeight=document.supertext.document.height
2 ]0 @1 e* o( i- O( m: {. ~# D" R      document.layers["supertext"].visibility = "show";
/ i# c& a6 z4 |( a; {( }      }! ?7 Y8 p! O1 o8 _
   setTimeout('moveBall()',400);  U9 S8 Z2 p% v* X
   if (hidetimer!='')
# X+ i5 F$ h, t3 b+ E8 Q2 p3 K   setTimeout("hidetext()",hidetimer): W( S: h8 N/ q5 q
   }
# u  E; e6 g  D4 d
2 Z) S  Z0 h+ k( F" F. rfunction moveBall() {
8 ~, f3 d! A7 [' f   if (superballRunning == true) {0 A  a3 ^: R1 Q$ Q
      calculatePosition();
5 N* Y( r- x7 A% {" B4 t) _( u      if (document.all) {
$ P9 C) I9 L6 c0 e         document.all("supertext").style.left = xPos + document.body.scrollLeft;9 [4 \3 \/ z& I' m
         document.all("supertext").style.top = yPos + document.body.scrollTop;
0 F, [; H6 a- ?' x         }
  F+ G6 ~1 w; \1 n, H      else if (document.layers) {7 D- q9 R* E( i5 ^' g) w" X
         document.layers["supertext"].left = xPos + pageXOffset;# [" I1 C/ W- U! S0 j8 s
         document.layers["supertext"].top = yPos + pageYOffset;
/ w- r' K$ j9 |+ i$ J2 Z" j         }
% ~3 ?# {; u: H      animatetext=setTimeout('moveBall()',20);
( Z9 H1 D& [5 r" x" [7 P, Z      }
: P% c& p1 E5 ^   }
) e8 {# m: G' B9 z9 _. S
) R! h* w. |: G  E% s. J2 O$ Ffunction calculatePosition() {& X) Q" j. D1 I3 g( d. `4 ]& E
   if (xDir == "right") {; l  L2 F6 h- j' t
      if (xPos > (xMax - contentWidth - BallSpeed)) {
' o, H5 k7 K& `/ |. L/ t         xDir = "left";
- \( d8 ]7 C5 H9 @         }* G6 {! v# c% M. V
      }+ u% v+ c5 y1 R" y  h$ p
   else if (xDir == "left") {
" u7 K  g/ g: i2 O7 `      if (xPos < (0 + BallSpeed)) {
% H- ~8 \+ i' _* t( [& O         xDir = "right";& r9 V0 W% ]: |# y  x5 l
         }
7 u# y3 s3 z; a6 c, D      }
7 p, q4 ~! V1 R9 P   if (yDir == "down") {) b! F0 f8 b1 [, Q4 Y1 |
      if (yPos > (yMax - contentHeight - BallSpeed)) {
6 T3 L1 {5 k; l! x$ v: J" s& e3 g         yDir = "up";3 x: O6 @" m' H1 i( \/ X( r2 x
         }
3 U  u; z; o/ }: U      }
( {/ s( i) ]& l% x% w' T   else if (yDir == "up") {) @4 m1 p$ J3 k( Q9 t; z$ @
      if (yPos < (0 + BallSpeed)) {
' u( z- U; ]( J$ |( O3 R- o         yDir = "down";
6 C/ s- g4 V: y: F7 K% k* V4 y7 P! n         }
2 `9 c0 V0 ?0 b0 W: b% w3 u      }6 N" P& o/ J* s/ U( h. I
   if (xDir == "right") {
1 C4 A# e- m; f$ p) N  t- i      xPos = xPos + BallSpeed;. O; f. s  J$ X& t7 ~% x" a) [. b
      }
+ k5 d, G2 E; H' N* R7 \6 C' F   else if (xDir == "left") {
' b9 X( }" a6 _      xPos = xPos - BallSpeed;
# _0 y  ^$ M4 g7 ]2 i3 h; t      }  w* }* s6 j8 j5 t; c
   else {0 F* V0 z! b+ G0 w. }$ f
      xPos = xPos;' b$ C% b+ y& k
      }' U- q* q$ P; n7 y6 u
   if (yDir == "down") {# B3 O& @/ Y9 G: d3 _+ R
      yPos = yPos + BallSpeed;
% y! n7 j# B4 e- N      }
3 X" |4 [3 g# E1 d9 A2 M   else if (yDir == "up") {# m1 O6 H# I5 S& q- M
      yPos = yPos - BallSpeed;
" @9 V& G. P9 y/ G, n8 z0 M      }
0 f9 C0 U. }& d$ w3 A   else {( a& ~% [8 ?4 s# Z9 @
      yPos = yPos;
! h+ ~% a* l$ M0 C0 I) {; T      }7 }6 N. {7 I( L: H
   }
5 n0 M/ C$ a% |/ ~- m! v
+ Y7 f  M/ P% O; r; vfunction hidetext(){
0 g; H3 A) x6 l( X+ }0 [, b- Fif (document.all)
3 o; p: b! e& O% s+ V- z! v$ Csupertext.style.visibility="hidden"
: o' I3 U" ~! N9 M2 delse if (document.layers)( n5 c7 E, H& e0 ^6 c
document.supertext.visibility="hide"
6 N8 [- y# Y: Q) _( ^clearTimeout(animatetext)7 E" Q# u- B% [# R7 u
}
- C: T  D. T' Y* s( C# k; ]8 R9 b, p4 u! {
if (document.all||document.layers){
8 v: P  H/ {/ q# K/ O5 Odocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ l7 M" A$ _& a$ X  swindow.onload = initializeBall;
) e/ _8 G# T% |* c5 E: Kwindow.onresize = new Function("window.location.reload()");
/ R- @) H0 L9 \}
$ r7 B" t2 m8 f* `* E9 T
/ n: l- t$ H8 u$ c& `# W</script>

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