返回列表 发帖

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

<style type="text/css">
0 Y6 C( I0 \+ Z! k; ?#supertext {: j5 S$ g5 \* E
position:absolute;
3 A7 s# }5 s* u3 Hleft:0;% e- a; F% ]3 x: a/ a
top:0;- C" ~. w2 h+ k: M! y
visibility:hide;
& a% J3 p3 K1 Nvisibility:hidden;& W' s# `  j# p- \# X
}
7 P" i: T0 d2 y# \</style>7 m9 [8 a  a4 n" U
<script language="JavaScript1.2">, Z. U6 A: B# S" v, S7 t
<!-- 改变下的字体的大小。颜色-->
) R2 ^: U% l* t* ]! L+ bvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 s, d# i4 Z& ]( B* n
var hidetimer='';
( w( ^- B2 X( R: c' `3 q<!-- 改变下的弹跳速度-->' I5 e0 q, Z3 f0 V3 @( L: u
var BallSpeed = 20;  M9 h0 g6 ~5 e7 f
var contentWidth;) }. t; Z6 v& T  R$ A4 {
var contentHeight;
: d7 V$ z$ M/ h7 w0 @7 F" hvar maxBallSpeed = 50;
5 O5 K& E1 s. T: F: S% E/ i3 J( |, S0 K/ [% r) n+ u+ g3 d3 T( o

, L! `1 c" U( T1 D" z  L; gvar xMax;% D# m, I6 h% |1 w, E
var yMax;5 q3 P- Z9 G3 u4 [
var xPos = 0;
' l9 E- f% K* Avar yPos = 0;4 F. d, |* m% S& Y7 O  U3 c2 D1 s
var xDir = 'right';: n6 D* ?- C  @  V
var yDir = 'down';% P- D$ m0 ~5 V7 Y
var superballRunning = true;* p. n: ]- q# f7 v
var tempBallSpeed;+ q0 H9 V! Q1 [  p
var currentBallSrc;
0 b$ J, I& q+ G( A4 E  J  cvar newXDir;( m6 h: p* m. w' Y$ T
var newYDir;
3 B3 P% }0 a; u2 N7 W8 E* z. p3 n; [1 a
function initializeBall() {
8 w. I- }0 F( I   if (document.all) {- v& T' P' \$ ]- {  g& C0 E8 T& |
      xMax = document.body.clientWidth6 C- c1 B7 t" H2 U) ?/ b7 m
      yMax = document.body.clientHeight" }  {4 I$ t1 @" \% V0 X
      document.all("supertext").style.visibility = "visible";
+ p  Z9 \# K2 T: Q! o+ R      contentWidth=supertext.offsetWidth
8 B3 T  V2 i9 c- V      contentHeight=supertext.offsetHeight
, @, E# Y5 J, C& ?; @7 A  W      }
, C, S. f: B9 h/ T! z   else if (document.layers) {
8 A* w3 s5 C- c      xMax = window.innerWidth;! t% q; d1 W; F* W" b  O$ j* _
      yMax = window.innerHeight;+ J- [. [; i& M0 S8 B8 X8 S
      contentWidth=document.supertext.document.width6 A' t& x& U3 r
      contentHeight=document.supertext.document.height
& c# X0 M* i8 P" [; R8 b* [6 Z      document.layers["supertext"].visibility = "show";
2 e3 m6 Z7 D' S  M) j9 h      }) v% |+ ?+ O: ?8 B9 s( q
   setTimeout('moveBall()',400);* D4 n7 G' O/ T
   if (hidetimer!='')
% T$ J0 [) Q5 g   setTimeout("hidetext()",hidetimer)3 e& I  r1 G  D
   }* t8 D3 Q4 u. V; D" c

& \: E6 y( ]& Kfunction moveBall() {/ y* J8 w! M' o- S8 n  L5 T
   if (superballRunning == true) {. h+ g9 i" R- |( \% _
      calculatePosition();( V' h! ^4 L5 w$ J, z
      if (document.all) {* v' S. K0 z: P; j! l: a, c
         document.all("supertext").style.left = xPos + document.body.scrollLeft;( d. T. W3 {" a( c$ ^
         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 t! I$ m. L) D3 m         }" c  @  A+ p) T/ E3 O
      else if (document.layers) {+ s$ ?- l  h9 l7 H4 ~
         document.layers["supertext"].left = xPos + pageXOffset;
) g6 A9 e+ S, v( Z3 S: A         document.layers["supertext"].top = yPos + pageYOffset;! H. t# D) q8 o3 v0 Z, V: d
         }
  x* _: i, r( N: P) N      animatetext=setTimeout('moveBall()',20);/ A7 U' z- s4 s( V+ S' e
      }0 A( J) `' P0 n* m
   }, J6 Z, Y! }& h7 W0 V
7 |( x4 a3 P) y
function calculatePosition() {
  K; ^" n% W# e# _9 Q   if (xDir == "right") {9 b6 k" F- c% _1 d3 M7 `
      if (xPos > (xMax - contentWidth - BallSpeed)) {% m4 e& t% i, D8 C1 n( Z
         xDir = "left";
, Y% d: x0 H5 L/ J         }. p1 X9 \7 A8 ^: D$ t9 n. c4 _
      }
; t2 K8 k/ B& J' `   else if (xDir == "left") {
) @+ C: |. T& s( {- g  d      if (xPos < (0 + BallSpeed)) {4 l3 C1 ], W9 A. P8 F
         xDir = "right";3 s3 o$ J- d3 k% R
         }" e1 l- f% V( i. c+ o9 T
      }
; r0 F+ p: b0 R, h( H2 n9 W   if (yDir == "down") {$ `+ [5 J/ [: W* g; T  s
      if (yPos > (yMax - contentHeight - BallSpeed)) {# O5 z5 r6 i5 v; z4 x
         yDir = "up";/ D+ t$ T( U: D2 l( U! o
         }3 V0 w3 k' m2 @! @0 g  S
      }" O: x/ q+ q/ b, \; r+ J, c
   else if (yDir == "up") {
' H( k& ?, [1 R. z      if (yPos < (0 + BallSpeed)) {) J' [; u8 E' `+ e, F
         yDir = "down";
% n9 Z) h1 f9 L/ z) \) E% ^. g         }- J0 l/ w0 e. ]& s8 O& O
      }
8 }0 _8 w! w$ N7 x2 m3 U$ }   if (xDir == "right") {  R1 @! c" e( `
      xPos = xPos + BallSpeed;
2 s  L% a! _: N) @: i. K      }
3 L+ Z; l; x4 v9 E6 y9 i' f5 T   else if (xDir == "left") {
; t  l4 U  Q5 d( i# f* Q2 }3 X      xPos = xPos - BallSpeed;6 d$ L7 L) c( @  Z- f
      }
, l# h- h# d# @* `0 N- }   else {7 c7 q. ^2 M' b, I: Y% d# I
      xPos = xPos;
' y5 M' ?( U) g& ~7 W' C/ l$ l      }
3 L- g% @0 C% f$ I7 I. y- Y% Q9 d   if (yDir == "down") {% T1 N+ r$ }4 P, u% f. t
      yPos = yPos + BallSpeed;$ ?# K' e; c5 u9 Z
      }
: N$ V  A+ S0 {   else if (yDir == "up") {
/ c* j% c9 I; W7 V      yPos = yPos - BallSpeed;1 q0 [% ~# ?# z+ w7 I* L* C
      }
7 K  n& u! z1 \3 h5 }   else {
  m, u0 g; [' z- F* S3 R9 g      yPos = yPos;
) f9 C  q9 e3 O+ Z1 s      }
9 `6 O. H1 y) t5 F9 F: ]$ ^# N   }) ^. n$ q+ e* J; C
, t( r" q7 K3 ?* w4 {
function hidetext(){
! G0 \6 q. H8 `if (document.all)8 q& j7 t$ P& V7 }
supertext.style.visibility="hidden"
' [) `4 f, O* E+ B% j2 oelse if (document.layers)
3 V, N- V0 ~; odocument.supertext.visibility="hide"
0 {! g. ]5 A8 ^- b5 \clearTimeout(animatetext)- X: a1 Y% V* S& K8 a5 {& U+ E: V
}
, \# s  D8 ~1 f. g9 c! u8 d, t( G, V4 W( H0 ?
if (document.all||document.layers){
5 A4 @7 _' V& V$ @document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')( j% A7 u" A/ }
window.onload = initializeBall;+ v: Y2 W" w) N7 \6 @  t. P: n( j2 e4 ]
window.onresize = new Function("window.location.reload()");3 E1 e6 s" n$ ^# n4 D6 v
}
( C; ^8 g2 _" ^# Z
& ?8 k% G. f' g, @</script>

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