返回列表 发帖

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

<style type="text/css">
# F, ?  K# ~$ n4 v7 B#supertext {( z: {# }, @  u+ I7 C. D
position:absolute;( W* l7 f7 l& h& r2 s  h
left:0;
: v( q) k$ p* htop:0;8 h+ }. i" A5 ?
visibility:hide;
" j* Z$ M; T$ j# q, P- x/ Qvisibility:hidden;5 X/ m, ^2 p/ g$ [$ _  q# b- P
}
, g/ A4 B% L  `9 t# s6 L2 I</style>6 s; }' z! O& g/ C8 ~. e, T# T
<script language="JavaScript1.2">
2 v$ o$ H0 _3 y( M<!-- 改变下的字体的大小。颜色-->
+ f0 l4 T0 X. f+ W! _( C  B1 K: pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'! ~% Q5 _# u+ E4 \5 @  }0 H
var hidetimer='';
7 W  Z2 V" H* ~5 t: [  h* V: M<!-- 改变下的弹跳速度-->% q3 s9 w7 w2 J4 X
var BallSpeed = 20;
" y0 z7 J0 E  k8 W7 I4 pvar contentWidth;
8 n4 V: T. E; L1 _) }var contentHeight;! ?5 ~9 L; }4 G* x# D
var maxBallSpeed = 50;& z5 r' B9 C$ Q/ o% R
) d% }: r0 J5 r+ R  o

  H2 N$ }8 D6 E7 n7 Jvar xMax;6 u6 w' c; D/ S/ M, N. o' C* h" ^
var yMax;
6 X' I0 q7 ~& H* ^' [' xvar xPos = 0;7 Q& }- L& }' k" g) s3 d
var yPos = 0;5 \& q6 o, |( ~2 _& }: k# S
var xDir = 'right';) _6 W+ `! v' q/ O% f
var yDir = 'down';, J7 t3 ?4 R1 P: }8 N
var superballRunning = true;
/ Y( V+ u# ?/ c& g; R/ ivar tempBallSpeed;) V) E4 K7 X- S1 B
var currentBallSrc;
) l1 `' S' T( H" [' D7 t2 K4 avar newXDir;
% r/ _. A( [( ?: Avar newYDir;
( E7 a& w7 P. m: l. e. N* o: [; ]$ J: h* R8 d0 K
function initializeBall() {
7 y5 s# m+ E' ^9 l$ B4 S  l   if (document.all) {4 \: n- f/ t0 l) n3 X5 l# b
      xMax = document.body.clientWidth
+ ^1 R' c4 M+ M6 f( g" {      yMax = document.body.clientHeight, [  K) g  e& O8 ^; c9 r0 x* C
      document.all("supertext").style.visibility = "visible";
  w7 Z! a2 H" \9 }5 _4 G      contentWidth=supertext.offsetWidth! [/ {  }/ F" O/ X
      contentHeight=supertext.offsetHeight9 p; r  I# C6 t; d6 o
      }9 B1 |! D3 W1 t5 h4 N! g
   else if (document.layers) {
7 \3 D9 u% x+ U7 g      xMax = window.innerWidth;! \2 Z8 G) ]) s# q, R4 O
      yMax = window.innerHeight;
& r" h" c% D' h# k1 |      contentWidth=document.supertext.document.width6 [4 x4 u/ q3 |8 H7 u
      contentHeight=document.supertext.document.height
/ v$ c) a/ C. @7 z7 t      document.layers["supertext"].visibility = "show";
: R" p* E8 W- q6 j! h* j      }
" e- X  n& B$ l' s! g$ X# F7 F: K  u   setTimeout('moveBall()',400);2 m& y3 J( d: Q; B8 v2 X" J
   if (hidetimer!='')
: H, M1 G- w: p) x$ P  f   setTimeout("hidetext()",hidetimer)( W+ t! B" I2 y4 a; U# n
   }. I/ D! f. g7 Z. e+ P

7 }7 s6 W; X# q: F8 x* |function moveBall() {1 [3 J8 ?& {, P6 k* Y& z( Z
   if (superballRunning == true) {
' R. {4 _8 n" L( p+ z      calculatePosition();
. C; |* L% P) T/ N% A' m      if (document.all) {
! p2 J/ y% L; S( g+ X. o         document.all("supertext").style.left = xPos + document.body.scrollLeft;! Q8 J% e. F% D+ a- T( _0 [
         document.all("supertext").style.top = yPos + document.body.scrollTop;1 ]4 o7 G+ G3 O" X! H2 v6 E
         }% X, k/ P" K5 o2 E) X6 ]- O2 i
      else if (document.layers) {5 y% z$ {- h% u, Q6 ?
         document.layers["supertext"].left = xPos + pageXOffset;
( o9 }3 d9 T' i  E; s& W6 t         document.layers["supertext"].top = yPos + pageYOffset;
( o7 J: {3 `8 u$ N         }5 D4 I; ~+ b+ Y' q' [
      animatetext=setTimeout('moveBall()',20);- c; m: y5 o. i6 h4 K2 f9 I
      }' K# E6 h7 K3 ^& E4 W
   }
3 c( c# a8 q; b0 n
4 Z' ?. ~' w7 L( O- ~function calculatePosition() {
4 l/ R& g; P8 P* o   if (xDir == "right") {8 t, Q4 ~9 Q1 x4 m) E% h& x# I
      if (xPos > (xMax - contentWidth - BallSpeed)) {9 F( c6 O: _4 P, _% y
         xDir = "left";4 w7 l0 ~* k3 B
         }
4 S5 |$ j1 o) |) n1 z" n: _$ j      }! X- r! ?7 h7 [7 o! e2 q6 t
   else if (xDir == "left") {
# O1 b& L8 F% b" Q; A7 Z# ~      if (xPos < (0 + BallSpeed)) {/ B, q/ U$ m# K' o8 Q; \4 k% [( x
         xDir = "right";* S* s) M' a$ e$ G1 S' k
         }
! V8 x7 g9 q; Z% y+ q      }5 o2 R7 e( o/ d3 s1 Z0 K
   if (yDir == "down") {
/ K$ x% t' S1 h3 }: t      if (yPos > (yMax - contentHeight - BallSpeed)) {
1 f6 q- K: U' n! \         yDir = "up";
, u6 e8 \+ i+ j         }
0 p, K* w2 z1 \. U, D6 r      }$ x' [, M" s8 |$ t
   else if (yDir == "up") {- |, r3 u: A  S2 B) p
      if (yPos < (0 + BallSpeed)) {' W: z2 ^& V' S# O1 \
         yDir = "down";
; ~6 V! D2 I7 q& i4 B         }
+ w5 \+ k. X2 Z5 W" ]0 R% Q& t' C: h" ]      }) D( V- U' G$ Z
   if (xDir == "right") {! g+ A) N  {5 w
      xPos = xPos + BallSpeed;/ I" t/ R3 t* c
      }4 _/ _) Y" q8 }+ T! q
   else if (xDir == "left") {
9 d! A1 a3 Y; J5 Y) k; B; D4 }# G3 j2 f      xPos = xPos - BallSpeed;
) K! b  ]; K4 m" N4 a# H5 O" T      }
; s7 p: H; x2 Q( S# E% C; e  }   else {
- A' |7 P! x5 T9 O/ g      xPos = xPos;4 I0 j6 S; R  A; U; D
      }; M& y$ A6 k! o3 K! M& O2 w
   if (yDir == "down") {+ G5 M# P0 S3 ?  u; y' }
      yPos = yPos + BallSpeed;2 ^; q0 b& ^" l# y. A( Y: _# r$ z
      }( G- u# J! a4 ]6 }, W3 C
   else if (yDir == "up") {
+ e  S! j( i2 j. h& y      yPos = yPos - BallSpeed;% C" ]1 e& Y2 r
      }
- q2 x  N/ r: Y6 ?+ @   else {
% C4 d- u: I% u8 D( q      yPos = yPos;; n7 O- ^: `' S& n3 h1 s
      }
# L0 ^. Y5 _3 Y3 c   }
- a+ t& M1 Y( [# F8 g3 T0 [& n. k0 j, o- O6 D$ z8 B  A9 C' \- y  I
function hidetext(){; `0 R; r8 S* W: O; N
if (document.all)* U, G& y/ u9 ], F3 f
supertext.style.visibility="hidden"* Z2 H2 j$ j& V
else if (document.layers)
+ q* Z; D% M) ~+ l; tdocument.supertext.visibility="hide"4 e6 B( l( U7 B: h# w
clearTimeout(animatetext)2 V. M$ v7 A3 d9 _9 O( K5 `
}, S4 ~; K0 s4 U% r( q0 {

2 Y) t& G* h" _! i& pif (document.all||document.layers){
; k! v8 t% P% k4 }/ hdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% B# k9 D' A4 |! Rwindow.onload = initializeBall;9 O$ r* f' D- \. ]
window.onresize = new Function("window.location.reload()");
9 f+ R1 ]( f+ S2 g2 b) H}
2 p& T" Z0 e* t4 r7 U4 V. R1 G/ o5 b  O  a! Y6 a
</script>

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