返回列表 发帖

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

<style type="text/css">
0 P. P0 s( Q- ]  s" ^#supertext {
* s. l% O9 o2 \4 Aposition:absolute;
6 q% B/ x7 E; j; e; `3 n3 m. Z, mleft:0;  A2 }# s2 \# u5 X1 L) Y
top:0;# H. p3 K$ F1 e. ?# U0 |4 z
visibility:hide;
% T. S" l# N7 I) J2 N8 W# Zvisibility:hidden;  C" c* m  ~# J3 m3 s
}9 {2 q6 I% b: j" J
</style>
* B& U4 B7 T5 r; g. Y<script language="JavaScript1.2">$ @5 _' z8 J# @& C7 ?
<!-- 改变下的字体的大小。颜色-->
. b4 h( K- G' `  p  e. Zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'! I2 ~5 s; ?4 v$ r
var hidetimer='';: r; ~) d5 E& R: ?# j
<!-- 改变下的弹跳速度-->
& J& n, a/ h: Z, X3 kvar BallSpeed = 20;$ \* d! `4 C1 E9 K# B( L7 d% J  c
var contentWidth;8 Q( m2 T$ `" T0 p3 c
var contentHeight;
3 G/ y4 L3 @/ `( z1 pvar maxBallSpeed = 50;  w7 p0 }7 O5 X3 h. i
" I3 \7 L8 g; _8 y) t
) v$ q% H$ [) u; e( c+ ]
var xMax;" x- F) V* l& o" R7 R5 `1 p/ ]  K
var yMax;  b5 T6 o2 Y4 O) X+ F) N8 a+ E! o
var xPos = 0;
4 t7 h7 f8 S# l0 h8 cvar yPos = 0;
3 W8 j1 U$ R+ s6 j/ Y5 ]var xDir = 'right';
) L; q7 e* e7 @5 ^+ P% V8 Y9 `var yDir = 'down';% b: Q2 a  f* [9 D
var superballRunning = true;
# H# a5 K0 i  \& a/ y% c6 Ivar tempBallSpeed;
' T3 y' F; _1 R2 }var currentBallSrc;
. h: [% ?! ?9 [- L2 r; ]1 Q4 n7 lvar newXDir;
( s2 [$ j2 U( y' U) ?/ [% {6 {var newYDir;
: Y, r6 f& u, V/ Q- {# t5 ~. ?
2 M4 n% X5 R( h. p6 mfunction initializeBall() {' V3 G# [- F- P$ W! L7 X2 B  u
   if (document.all) {, H: H# H5 S  L% N5 i/ S4 \
      xMax = document.body.clientWidth
+ d! i/ }5 Z- h8 B8 ?7 ^      yMax = document.body.clientHeight
( g+ ~, V. J% ]% ~+ ?; j      document.all("supertext").style.visibility = "visible";
9 z. A9 E8 {8 s  _6 N      contentWidth=supertext.offsetWidth- C8 \5 c3 F2 s% ~
      contentHeight=supertext.offsetHeight* O! n7 U. T6 N& n  i& U
      }
1 ]  S; o% N' i) c# G   else if (document.layers) {
8 d9 H, a" a/ o. ]1 m) ]      xMax = window.innerWidth;6 _, v. s/ ^; B1 E. u9 g
      yMax = window.innerHeight;
; T7 D; A5 y' A4 p7 D! o      contentWidth=document.supertext.document.width6 }& h' K+ }1 c! g* L
      contentHeight=document.supertext.document.height
& V7 k! m% c1 C9 v) r      document.layers["supertext"].visibility = "show";
  g) S( {6 l' |0 `( |- H      }) s9 a- b& g0 `3 O
   setTimeout('moveBall()',400);
  Z. v% D% y# H   if (hidetimer!='')
% D" O0 v  `$ l7 ?# y: k   setTimeout("hidetext()",hidetimer)8 w) C' l$ C5 _: S
   }$ _. ^; c: `7 R4 i; s) ?( {

1 N0 s9 k: _( _) }0 }function moveBall() {
4 u) P4 k+ E$ G6 A   if (superballRunning == true) {: ?4 `& S2 R, G7 S
      calculatePosition();& @( U. l3 \7 N$ m/ b" k+ G# Y
      if (document.all) {
* j" j; G( k- }1 y3 T% M; I         document.all("supertext").style.left = xPos + document.body.scrollLeft;# T4 O3 l) r$ {( m
         document.all("supertext").style.top = yPos + document.body.scrollTop;
7 u1 N! A" t! \. @2 d" |. L         }* V* M  s; ]# e
      else if (document.layers) {* \  `" j$ x2 o5 G8 q, A
         document.layers["supertext"].left = xPos + pageXOffset;
# M8 {. a3 L* @6 ]- ]! L, V/ c: A         document.layers["supertext"].top = yPos + pageYOffset;
7 [9 t" s+ V, S* Q2 m8 t- }         }) C/ _+ }: b3 w: [* E7 ~
      animatetext=setTimeout('moveBall()',20);
0 q  }. q0 A4 P; M1 P3 l& j      }. _% k$ L4 e6 L/ A2 O
   }
8 Y; }, N3 b, l! O8 w1 G2 z
2 e0 E+ ?3 z3 R) Pfunction calculatePosition() {8 |( H6 z) I' l, v4 l: P  M' U4 A
   if (xDir == "right") {
- r& z3 ]3 }9 j, S3 E4 A9 k# B      if (xPos > (xMax - contentWidth - BallSpeed)) {
+ _! G. v3 E, P, ?         xDir = "left";1 Q# g$ f  o$ v3 V1 i. n3 r% d
         }
6 ]$ z5 O# X3 k! H      }7 O% v6 e; p, f" W6 H' m
   else if (xDir == "left") {+ w$ i3 ]7 i* S  [- t9 {; f# D
      if (xPos < (0 + BallSpeed)) {6 t, K' T7 T5 b$ m% g9 B3 x
         xDir = "right";$ y, J: i$ u5 H& r
         }
+ D  z& T5 R/ l+ [8 C      }2 x% E) h: q" R
   if (yDir == "down") {
# L* _) d- T. u! L0 F; y0 a      if (yPos > (yMax - contentHeight - BallSpeed)) {) \7 S+ j4 ]& V
         yDir = "up";
7 q, F8 C/ s- P% N5 W         }
5 t* o" N% A2 j3 D      }% \6 a% o# c( g
   else if (yDir == "up") {
0 m6 ~2 p) u0 D9 X      if (yPos < (0 + BallSpeed)) {* G& P7 x4 x+ X
         yDir = "down";
* u: X1 D2 d6 L8 R) @, Y- t         }, u" Q3 e+ M0 @5 H- {- O
      }
* I4 N$ u1 @% N   if (xDir == "right") {0 y3 x- L! z4 g! x: D+ S# C
      xPos = xPos + BallSpeed;
6 z  i7 R' Z; S! F. ]      }  ]) R+ W- \6 `6 e/ H
   else if (xDir == "left") {
4 }4 K9 ]6 f0 |6 b9 S( C      xPos = xPos - BallSpeed;8 M4 y- Q; O1 Q- s
      }
8 Q3 F& @9 w3 Y) L- t) W; i1 J   else {
3 e( q4 @$ ^" ^) a* e* h" E7 R      xPos = xPos;
% E4 z, I; @! t$ _: X      }
/ `- J7 @5 M* N% E1 {   if (yDir == "down") {
) t  H% m% f3 b( ~. ]+ D3 x5 B      yPos = yPos + BallSpeed;; k" x1 }# e6 ~( y! W6 }4 f4 M
      }6 k. q% T4 h/ q1 L4 K$ i
   else if (yDir == "up") {
* Y* P  p6 g4 `3 R      yPos = yPos - BallSpeed;/ w) w. y" V1 z1 C6 ~" k8 z6 b
      }2 x( U/ ]: A* P" y7 a
   else {
2 y( l) r0 N; x      yPos = yPos;3 j8 r" Z, w. n; w$ z
      }
  |% Y8 N/ x9 ^& [  e8 y$ \   }' V& L+ a, [( Q
" W0 \+ Y8 R% v7 |: H+ t
function hidetext(){0 D" f, v, n' y$ Q( l
if (document.all)+ a+ @* l; @  |8 @
supertext.style.visibility="hidden"
3 F# _' l8 m3 f6 F" l- M9 Melse if (document.layers)0 ^- N$ D, h8 f
document.supertext.visibility="hide"( v6 L3 k7 c" K- ~  C
clearTimeout(animatetext)" ^' e9 Q/ G' f/ V1 B) [
}! L6 o3 ?- b0 x9 k1 t  B

$ `: @- S& _, g2 z  ]if (document.all||document.layers){" u% t2 u. ~$ j0 [- s
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) q0 q0 s& ]5 ~8 g6 o( H+ D. `window.onload = initializeBall;
/ o" I6 x- q& R( {: Mwindow.onresize = new Function("window.location.reload()");4 v. Y1 y- [8 z+ ?# y" d# w
}5 v3 o" q# c- Q# Z$ [4 @

5 {$ T( f2 N, l; p</script>

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