返回列表 发帖

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

<style type="text/css"># q. ?* C" C% B+ B0 X
#supertext {
1 x( j  }& w# U, fposition:absolute;% E$ V6 [) w6 V6 v- T" O
left:0;, \. O8 W, h) h7 J
top:0;
1 v, T' `$ [# l$ n5 A2 u+ Rvisibility:hide;6 n; s; Y9 O1 {$ a9 ^" r; j( ?
visibility:hidden;
) ^0 Z  l6 x* \( {9 i: k9 G}
2 ?/ z& \9 P# g2 V2 J, w0 Q  z</style>$ a4 H. f7 f* }9 k
<script language="JavaScript1.2">
7 z5 \: y/ x- D4 U<!-- 改变下的字体的大小。颜色-->
9 x1 P( M9 p% l! d: u  f! ~$ k( M5 Ivar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 V& e# q5 D1 F& ~2 ^" z' D0 |
var hidetimer='';" E7 C& ]4 G, ^1 B' ^2 G$ a
<!-- 改变下的弹跳速度-->
8 A' q7 G/ j- }6 s$ Vvar BallSpeed = 20;
1 v, j, J9 T& G5 p) X* @5 f4 T+ Qvar contentWidth;
4 D3 Y3 R$ I' O5 _$ H1 V6 Gvar contentHeight;
( w  G6 m, ^5 N2 q8 Avar maxBallSpeed = 50;1 v, d* H  b9 n& |  L: ?

7 ~  x# T7 w; g5 R5 K6 Z2 ~- P) P2 I, |. N0 R7 j
var xMax;
/ Q$ r) }/ Y& M; }5 W1 F" w9 ivar yMax;6 }( g. S* f, V
var xPos = 0;
+ E! l  K1 N4 e# ovar yPos = 0;
" _" p; V$ b$ x+ f8 B3 Zvar xDir = 'right';
3 l8 g, S- V8 x- U8 L! {var yDir = 'down';
# `$ M0 |; `; z* P4 Lvar superballRunning = true;9 F( ^4 [7 {4 O' F& \: K7 o" C
var tempBallSpeed;
) R( m* ?! Y0 E+ `5 Fvar currentBallSrc;
+ t& `3 S- a) y, x" ^& Z' [' }var newXDir;
( A0 j7 E8 {/ u! L( O7 svar newYDir;
2 b: w+ t7 H/ Q' H" w
) H# }( X, B- L) Yfunction initializeBall() {& ^: H9 h; ^6 b
   if (document.all) {0 f) L) k6 X8 O5 |8 c
      xMax = document.body.clientWidth
& `* U: V2 h4 w. F) Q      yMax = document.body.clientHeight% `$ a" j: I# `' a3 S
      document.all("supertext").style.visibility = "visible";
' o$ J7 u' Z2 {: H8 N  l) S& Z7 @      contentWidth=supertext.offsetWidth
# C- R* _0 u6 r- O" A  L0 C      contentHeight=supertext.offsetHeight! r; p- D2 l9 V0 A
      }
& P  L9 J* y6 X& s! `2 t5 ]   else if (document.layers) {
' ]  H+ `6 @! S. S) o$ R      xMax = window.innerWidth;
+ {" @" b  p  q& U1 a" S      yMax = window.innerHeight;* G4 X9 |1 w* }# A; e  s
      contentWidth=document.supertext.document.width, s- T3 I; a, p! y3 Q0 ?
      contentHeight=document.supertext.document.height+ w# K; h; Z3 ]/ G" a9 E
      document.layers["supertext"].visibility = "show";0 Q6 h+ w, X" U7 s0 W+ s
      }' a% N2 a3 g& p/ D$ J1 y6 M
   setTimeout('moveBall()',400);
. ~: l7 O2 {4 U0 X( V! Z: X! c   if (hidetimer!='')* @  j" x5 o  @. _! c- n- W, h
   setTimeout("hidetext()",hidetimer)1 R* x1 L! G0 U2 O, |+ i" K
   }' V" f( `3 d2 H' \. C6 a

1 {. ?5 D# h3 f/ k- n; Ffunction moveBall() {1 f+ @& L* d+ Z
   if (superballRunning == true) {
' I9 X& C# g+ a$ I" p      calculatePosition();$ U& s( n* D7 F% P
      if (document.all) {6 c7 g  T3 N7 I. ?0 e+ I- k
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
% T9 z' M. ~  w) k3 g         document.all("supertext").style.top = yPos + document.body.scrollTop;
% V9 }: f- }9 i3 G* q0 `. E* _         }
! H1 L  m1 W- ]1 A* `# b      else if (document.layers) {
* r  V# _* h& J         document.layers["supertext"].left = xPos + pageXOffset;, ?4 y7 a5 \. B" a+ f% ^
         document.layers["supertext"].top = yPos + pageYOffset;! }0 ]) d' n3 U' U4 j$ L; k! _
         }
& G( h+ o' U& y+ F      animatetext=setTimeout('moveBall()',20);
3 b, J& t4 d! e      }
4 N$ Z# T2 g. q/ P7 y   }
1 U/ Z% p( {0 t4 z: l5 c+ v- X7 {7 h0 m; \! Z5 `8 ]% V5 o7 ^
function calculatePosition() {
2 g2 K; M6 D+ N   if (xDir == "right") {/ a* K' t5 e4 R- D: T0 B
      if (xPos > (xMax - contentWidth - BallSpeed)) {
- [7 w- j9 S+ _$ G, ~. ?5 f& }         xDir = "left";
4 L( s: U. r& d" l         }( a; o6 q4 }" u6 _, s, [- j7 i  w5 i
      }
! s$ \3 X8 O: x% \! x3 \  _   else if (xDir == "left") {
# ]/ N  B7 _# k' Y      if (xPos < (0 + BallSpeed)) {# d1 ^5 s; h9 B' J3 d
         xDir = "right";- i& Y3 Y3 w/ D! k7 O
         }
" @. l$ A- W$ M9 K+ V! _      }2 T( p" C+ n: w
   if (yDir == "down") {
5 f7 @7 H4 d% Y/ _& R( o      if (yPos > (yMax - contentHeight - BallSpeed)) {
) g9 Z. K  }' U, i3 c         yDir = "up";1 o4 t) }: Z; a7 r& C3 q) {
         }) [4 z; k9 {/ n) h/ o% S4 D
      }
3 `% H4 t* U/ s( L   else if (yDir == "up") {) E5 j. }7 _4 ?; C- Z6 [
      if (yPos < (0 + BallSpeed)) {
" b* x, }5 d- ^3 p6 J! C         yDir = "down";9 e. V  T% n. l/ N+ c- v
         }
9 u$ r3 b- F8 G: r/ V" ?2 W      }9 t; x# D8 W. H8 @
   if (xDir == "right") {
- d- @' u: J/ a      xPos = xPos + BallSpeed;2 X. K# U3 ?7 @! C+ w" n. ?
      }
. g) c4 `0 M( c7 _$ v   else if (xDir == "left") {0 p1 w, [6 _  @* q1 ]2 R
      xPos = xPos - BallSpeed;
; ~) |; o# A$ B, o! u( T8 f' c      }
  @# }7 \/ a* Q$ J   else {
6 I0 S) j; Q1 I  q      xPos = xPos;" d1 P9 z* k5 u+ B4 L9 c
      }
4 F7 z, ?. I4 B& d" l+ @   if (yDir == "down") {4 N! U0 v/ q+ X6 q
      yPos = yPos + BallSpeed;5 Y" f% g( i- K0 u2 \( ~2 P
      }
6 w4 `* ^2 n- ?+ D   else if (yDir == "up") {
% ?7 ~! ~% S" l: L' K6 s. k      yPos = yPos - BallSpeed;
/ P8 Q, q: L( C/ o, t+ x$ [      }4 \% b5 b3 t  ?7 S# H
   else {& [0 W2 f7 p; O1 s" i  d
      yPos = yPos;" w+ Y2 {3 i& E- }
      }8 r. X5 m* I# k' h4 W% W4 C/ _
   }
/ V& |; f8 ^) `) _0 @. j0 e0 ~2 ?- K# p9 ^) Z" b' r) ]. E
function hidetext(){
+ G4 n: M$ G* ?) P) P- I+ N, {/ @' G$ h; Tif (document.all)& S& r  J  a+ A2 U1 E- q# C5 t
supertext.style.visibility="hidden"+ c  g" F3 M) U8 g6 t! I2 b3 L$ V
else if (document.layers), F0 w5 n3 Z# `% ~, |7 C
document.supertext.visibility="hide", F2 q- \. H7 d6 j$ c. l0 G  p
clearTimeout(animatetext)
0 u2 ?/ {; }: o) o4 r}# k0 D; T4 I7 j1 g& a: E6 X
  N- o$ ]4 w' |/ @
if (document.all||document.layers){; Q1 C' [- a/ |1 |2 I3 Y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# k, k# r* C! D) B. w( @window.onload = initializeBall;
5 {7 t4 j4 U/ I% S  v# uwindow.onresize = new Function("window.location.reload()");4 K7 v0 c+ m0 K& L9 N: c
}
+ L% \( c" R+ f5 U7 e6 l" ^, G* `+ u- s: v* f9 v
</script>

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