返回列表 发帖

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

<style type="text/css">6 \9 }  Q7 U1 k, A2 S) {) d
#supertext {
/ J" z0 i5 Q/ j+ v$ S* mposition:absolute;
% D1 U5 i5 W/ b$ O  K8 @# Jleft:0;
7 Z2 N/ R% }# P' Ttop:0;
# Z2 k- e1 H: ]/ k, E3 [visibility:hide;
' o& x  _) D6 a* T+ e6 h) Y5 ivisibility:hidden;3 z8 a5 m$ k2 e) D
}: k6 q# c% |1 `2 t
</style>- g4 J$ T+ v1 v, I/ S& k
<script language="JavaScript1.2">
' ~: }! e- m& t% u/ [. R( j<!-- 改变下的字体的大小。颜色-->7 h9 \  [1 g% [/ _& L* k
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') V! M0 \' K4 u9 W3 _, h
var hidetimer='';# P, @4 B% b. A
<!-- 改变下的弹跳速度-->
4 y9 V( P3 c& V$ v. V3 h# y/ w$ C1 ]var BallSpeed = 20;3 H( a2 L) }3 @5 H
var contentWidth;
, o: s% [% E. P6 x9 K, _var contentHeight;
% M/ h1 \0 U) S$ Avar maxBallSpeed = 50;
; D4 ]0 D. X% y* |4 q# _/ x; c6 Z. N' e4 b7 Y  J# Q
! ^7 q, }) v" J. D
var xMax;
2 v6 a; B& E+ M2 r$ {) o0 e( H1 bvar yMax;
" Q8 _" i7 A" g0 Y% K5 U0 b7 Vvar xPos = 0;! X/ F1 @" `* b3 A  j
var yPos = 0;  S0 p8 f6 ~8 M6 W5 u) u
var xDir = 'right';( X8 I9 ]4 P3 d+ _4 k3 z. [
var yDir = 'down';
9 M# X- |1 U) Mvar superballRunning = true;% k! V$ X+ r2 t! R8 @3 L8 X
var tempBallSpeed;, p7 b, e; n/ W: A* z8 G' P. B
var currentBallSrc;( V! }9 R4 \5 M% R; t* M1 j
var newXDir;5 }# ~7 Y& p+ p; j% G$ ~6 w0 b
var newYDir;
5 v! O& W. Z& G* c5 O1 Y: `7 [4 Z2 n& H9 E
function initializeBall() {
. g% h( E7 G. H" P   if (document.all) {
( d3 z) A% N/ w( t( a) E$ |      xMax = document.body.clientWidth2 [+ J: b; }0 Y1 J+ _5 A& p
      yMax = document.body.clientHeight
* ?6 [! M- v* w5 w2 c; O9 a      document.all("supertext").style.visibility = "visible";
( ~' t2 y! C. H7 ~      contentWidth=supertext.offsetWidth6 R2 m( {6 S( @% B2 v9 i" N
      contentHeight=supertext.offsetHeight. b, J  K" F% n* V
      }
! j! F' N1 P& P; l   else if (document.layers) {
% M- E: l# G" z+ i      xMax = window.innerWidth;# f+ p4 Z# ~5 }$ O
      yMax = window.innerHeight;. M2 z4 ?" z" T- h! h9 M6 B
      contentWidth=document.supertext.document.width
. y# `. w/ K9 {1 @: n6 u  |" C      contentHeight=document.supertext.document.height2 y! S+ g6 i  Z, E+ H
      document.layers["supertext"].visibility = "show";
% T. O5 C0 E0 Z* l' X' G; H) g      }
3 A" s$ [% f, p, o; t" g; ]   setTimeout('moveBall()',400);+ {  d9 z' F8 w* n6 |# O+ ^
   if (hidetimer!=''): H1 ^" w% O7 u2 {/ j
   setTimeout("hidetext()",hidetimer): B' e( p0 c' |7 w& g
   }
& L# ?1 b$ R# C1 W" v& ?$ u
" k3 \( I( j2 mfunction moveBall() {6 u2 l7 v1 p' Y
   if (superballRunning == true) {- w' B, K/ T( |
      calculatePosition();
8 l4 Q; E/ p: i! x5 O0 j, o      if (document.all) {: u% }; ~9 i2 _
         document.all("supertext").style.left = xPos + document.body.scrollLeft;: \2 u! a3 [4 c
         document.all("supertext").style.top = yPos + document.body.scrollTop;
* b1 e8 ^- K% D) O         }
9 Q/ K+ @. I+ T0 l      else if (document.layers) {; O2 }# [, \! i$ a& x
         document.layers["supertext"].left = xPos + pageXOffset;
$ u8 M1 Z/ a) W# D         document.layers["supertext"].top = yPos + pageYOffset;% m+ M! q& x! s4 j/ w/ H& e
         }; b' A! F3 N! \1 N! m. C1 L; @: i
      animatetext=setTimeout('moveBall()',20);* z( e6 z' W, a: U/ ~& n
      }
0 Q* l* @# ?/ j$ w* W/ @   }
0 C  \8 G; O' i9 z: E/ v
4 G: `% ~2 T. i3 d! B$ Cfunction calculatePosition() {
' S7 e0 j0 O) a+ ?4 _   if (xDir == "right") {6 `" L$ f7 u# d8 @% G
      if (xPos > (xMax - contentWidth - BallSpeed)) {
7 m3 q4 V; B/ }; x8 s         xDir = "left";& C& y$ ?" C% z8 h7 }
         }
) }8 E' `! C, s      }3 ~* U( ^+ h  A- S) ^1 H9 `
   else if (xDir == "left") {
( `/ G# |, v& u+ G, a+ R$ Y7 j9 `      if (xPos < (0 + BallSpeed)) {
8 G1 _- q" O+ g+ ]' ]         xDir = "right";( |, v& J; `2 s
         }  f) y% F/ `2 m1 w! |, s
      }! i2 ^8 M- Q6 V7 n
   if (yDir == "down") {; W2 q0 m9 h- r0 w( X" |. w. S
      if (yPos > (yMax - contentHeight - BallSpeed)) {: z. r. v; s6 v4 w
         yDir = "up";
0 |0 ]# [) v9 R" E/ R9 W9 K         }9 \7 x  G4 R2 n0 w$ q! n
      }
1 G) u, ~$ T3 J3 P# I   else if (yDir == "up") {3 `9 F, {$ H% h0 V0 F; P
      if (yPos < (0 + BallSpeed)) {0 r! g$ s- w1 \1 V* D
         yDir = "down";
. K8 i8 c9 ?3 O4 u* y         }0 b6 j( ]* H& K! k+ S5 Y5 Q
      }
: y$ [7 B# F9 B# Q$ c/ Y   if (xDir == "right") {
3 M, d) n9 O, ^: K+ s/ y# t! R  D2 x      xPos = xPos + BallSpeed;
9 Y" u  P5 r) d4 P/ m( P9 ?5 E  L      }
0 x0 f, E! Y* ~; T8 q   else if (xDir == "left") {  E( r" B5 y4 C% w' d) C
      xPos = xPos - BallSpeed;
; H1 z/ |; r4 w7 x4 s  Q      }4 ^& y8 O+ n, ?6 Q+ \6 `
   else {2 |: ~& g- R7 q) }" Z2 O
      xPos = xPos;
3 a+ b; D8 }# N7 G      }
: D' _" s/ G3 U   if (yDir == "down") {
( x- ^5 P3 z& E3 ^' Y. L, a, L      yPos = yPos + BallSpeed;
9 h' j8 T! ~; j1 p4 P! A2 f  W0 ?      }$ Z" V; q9 G4 w: V% n( y
   else if (yDir == "up") {
+ s, p; D( P( H9 E7 h0 a/ l* M      yPos = yPos - BallSpeed;' j' K" h3 [5 W7 d
      }1 p  f8 w4 v  _" A2 x" f& A/ L
   else {7 W* a5 ]+ w9 _( ~
      yPos = yPos;
- G) l. n7 R0 H. [- D; Q      }6 h6 D' A: g5 D6 Z4 D" A: A
   }! c+ G/ Q* H. Y
4 B2 G7 S. Y6 x! Y
function hidetext(){
5 o. a; W* Q( m9 xif (document.all)
7 z* U' y4 d- p: {7 T9 X: @supertext.style.visibility="hidden". d8 ]  F  z' s( U4 G3 L. }+ K
else if (document.layers)
( y1 K, v/ f& a: C- E9 Ldocument.supertext.visibility="hide"
, [! K) r( p( T7 J5 VclearTimeout(animatetext)
1 l- O8 q4 K: q' C, C}
. t8 g$ ~" K% r0 S& h5 j2 X5 k3 U' v
0 h+ u1 n# u+ n9 Hif (document.all||document.layers){
; E: u5 Z" y2 }$ E/ F" i6 {document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 t& m' P+ T5 j2 \" ]( lwindow.onload = initializeBall;
& b8 L6 @6 }& r1 gwindow.onresize = new Function("window.location.reload()");
" b3 w* n% t# W& V: _3 X' y1 l& ]}
5 ?* {; }% n4 [! L8 u$ S
2 r- x7 }, ~" P' G. a</script>

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