返回列表 发帖

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

<style type="text/css">
% X  j* n8 h2 ^4 Y#supertext {5 d/ c9 v+ B2 e' g! C. D# |
position:absolute;
3 s, m# s) y2 h1 N1 J$ f( M) \, `left:0;
5 {  W+ T' y, n0 N& dtop:0;
: f4 w6 C- F7 q# L. P* `4 e, W1 x! Ivisibility:hide;+ c- L3 l7 N# G; P3 e
visibility:hidden;  j( W+ M$ u* k5 H$ g7 T
}& T, Q5 M4 E' `8 `1 ?* Y" j
</style>" @; X% X& W$ J( ^5 {
<script language="JavaScript1.2">
& S/ p' j) J% P& |; I& x/ Z<!-- 改变下的字体的大小。颜色-->
5 r3 D/ T- E6 K' Z' V% tvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'- L5 ?+ E1 I& h# y9 x
var hidetimer='';' ?' C+ C* l5 E# o
<!-- 改变下的弹跳速度-->* ]6 d" H4 \9 r+ p. e! q' b
var BallSpeed = 20;
) L' }# u. U/ T7 G2 `! H  G7 avar contentWidth;! R5 O% c7 D+ `; y, L# }, l
var contentHeight;# t) j" T. O9 V! Z- i
var maxBallSpeed = 50;
5 w! o+ v, }  L& ]+ q, p" A; H% B8 z3 f9 X: l" H# O3 @  f) M& O3 J$ D

# @& L* d* i, |6 k) Q/ avar xMax;9 Q; t, G' d, n$ _3 _. W
var yMax;
- V5 g7 @5 v$ K4 _, Jvar xPos = 0;
3 n' i" d# F* _" C) l* ^. E, Bvar yPos = 0;! p9 q/ x1 U& B! E7 U
var xDir = 'right';" W" E6 B' z* T2 f
var yDir = 'down';
# M# B( ~  _! Y! u5 T9 k3 Jvar superballRunning = true;
; `- K3 {' [9 D6 H6 zvar tempBallSpeed;
: _/ P- J; ~0 R: E4 Q! m$ _var currentBallSrc;$ b, X8 Z+ x: |+ k% o; D
var newXDir;/ h0 T" G0 x8 M& k9 e" P. m
var newYDir;$ Q% [6 W3 w" F, Q4 w9 f, h
0 k% c' P7 s7 W
function initializeBall() {& t5 G9 v7 ]* Q3 `4 C+ [" Q
   if (document.all) {
3 g8 B$ V% L2 O7 L      xMax = document.body.clientWidth: Q# L# K( h7 w. e
      yMax = document.body.clientHeight' l! N. G* \  ~( C( N
      document.all("supertext").style.visibility = "visible";
- n/ L8 k: Y8 a: t- A- u" {- `      contentWidth=supertext.offsetWidth
% [+ c: J$ B$ w6 ^9 r2 U      contentHeight=supertext.offsetHeight
6 }- B" N& H3 j% N      }% K) s) G4 O, x
   else if (document.layers) {
& R! r6 \7 r% l/ r' }      xMax = window.innerWidth;9 ^7 T9 O( f/ c) G) P" R
      yMax = window.innerHeight;
& b! i2 D5 P6 e/ o6 B      contentWidth=document.supertext.document.width
0 `5 B7 j4 `& ?1 u* [/ ?3 o      contentHeight=document.supertext.document.height$ j7 v" J( W" p( z- v: K
      document.layers["supertext"].visibility = "show";
* E+ |; A, Q+ z5 w      }) D! v  k' D8 n9 _& U1 J1 d! q2 ]
   setTimeout('moveBall()',400);& w# y% _, S$ {* L
   if (hidetimer!='')
2 Z. D$ q5 [& y8 a/ F& f7 ^8 q" |   setTimeout("hidetext()",hidetimer)7 a/ p- z2 T) y% ]$ b" O
   }; ^* l( h( ~  A6 q0 F; X/ t, S

4 _8 q7 n! r1 c+ y' ^% @( P6 S0 Hfunction moveBall() {
' ]- Z& g) g! L   if (superballRunning == true) {
) E6 G4 S6 Y. X# K8 |      calculatePosition();9 W4 N  p* i1 d* U0 ~
      if (document.all) {
. Q8 U8 _  j' ]2 ^; S         document.all("supertext").style.left = xPos + document.body.scrollLeft;; b6 W# S7 K( D
         document.all("supertext").style.top = yPos + document.body.scrollTop;
; u' }5 u4 y* f( g4 t9 w         }# R+ l* B+ @# M1 ]  P
      else if (document.layers) {2 l+ H/ F. L# G2 N5 t, I4 S& ^/ G
         document.layers["supertext"].left = xPos + pageXOffset;
2 ~# h- C% w; X$ j8 l" s         document.layers["supertext"].top = yPos + pageYOffset;5 y5 u" _; ], n. n  c% h
         }
- t$ E' ?5 z' G0 _& @* `      animatetext=setTimeout('moveBall()',20);
% P1 k4 w! p9 N9 O, }( O8 s      }
- |, b0 X# `7 |1 j2 j   }
, P- d: E% @% Q/ e' J$ J0 V" f3 _0 T% r8 }% b7 N
function calculatePosition() {. O  I* Z8 `- s' k
   if (xDir == "right") {. n) j1 g% h7 z2 M+ U  Q7 q
      if (xPos > (xMax - contentWidth - BallSpeed)) {
9 a% C2 b5 h; p% h& I! X3 E: ]         xDir = "left";
4 M, g8 C# g% n& @         }: Y; v( z& h1 k2 w& e2 X; C9 i
      }
4 c! R: k) D+ c8 e   else if (xDir == "left") {: @: F. x# k* N8 {$ G
      if (xPos < (0 + BallSpeed)) {
! @, a  @5 p  G- R* _9 H) M         xDir = "right";
2 X9 U0 R7 l7 P8 J4 N         }
) V2 t1 J( D, W: g% Q3 c! S1 p% G      }6 Z$ j+ i0 r- X+ g1 l; h
   if (yDir == "down") {
$ u) |) ]# Y, F      if (yPos > (yMax - contentHeight - BallSpeed)) {+ j3 A, }7 r  V+ P
         yDir = "up";
. {- t# T; c6 X4 }; R, {; r         }# [% k: A4 t; u* Z3 D% i% n
      }
% G! Q. u9 U8 u% f, Y0 U   else if (yDir == "up") {" U. A8 c, R( R$ R
      if (yPos < (0 + BallSpeed)) {
0 M0 C% n( {. K         yDir = "down";4 c9 W* W, c8 R% ~. P& ?( B" {* m
         }/ `- D' _% g5 J' M6 W/ \2 L$ z
      }
7 O( p, \3 {$ x/ x- W; Y   if (xDir == "right") {: }: p( v6 N$ D! ?% h; l
      xPos = xPos + BallSpeed;8 P/ _3 m/ u2 T2 [; K% `5 c8 P
      }
! `% T& q" p9 g8 ~# l+ V8 ?5 O   else if (xDir == "left") {
% J3 x! n/ @6 C      xPos = xPos - BallSpeed;
6 w* n. ~: S7 {+ }/ o3 l/ M      }
' {6 K% v4 K1 L! P   else {
6 U  {# H) {- X2 T      xPos = xPos;7 C) [1 o, s7 K
      }9 p: x; i' K& c" S; r
   if (yDir == "down") {2 S) Q6 O, o1 X! I& Z
      yPos = yPos + BallSpeed;
- s( e5 s0 ?3 R7 a      }
; X6 u) y4 R& P   else if (yDir == "up") {" k# |2 Z8 V6 |- f4 p, ^! e
      yPos = yPos - BallSpeed;
3 B9 z) j) r3 f      }
; D" b. V( V& ^& }   else {
/ I! Y6 E! ~2 q( c$ D( K( i2 p      yPos = yPos;
, e2 K) I. W0 c/ c8 r2 P" n      }
5 H2 L5 ?) q) [/ q" J   }2 S) ^1 h* |8 B' z% j) m$ s% c5 u
5 K3 Q+ }' ]" ~! L+ _+ a
function hidetext(){
- L  f# Y; G# o9 sif (document.all)
6 l3 M) H$ L' {+ G! gsupertext.style.visibility="hidden"/ k* k! C* d6 W  t" c3 m( h
else if (document.layers)  i- e' ?. S6 I. W
document.supertext.visibility="hide"
4 v; _- c( l( _3 a# e$ ?/ UclearTimeout(animatetext)
- A3 q9 D' [9 e) @" p$ @}7 B+ X% o( t, a% B# {8 \) u* L
) t! G8 p8 ?* j; C
if (document.all||document.layers){" k7 c# z, q( h+ s2 A
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'). p  M$ J4 M% l: m+ w
window.onload = initializeBall;3 @( X( d& R* k3 x0 x& Y& M9 w
window.onresize = new Function("window.location.reload()");% a+ f+ \5 S% h- ?& }: R; G  l
}
& d9 y/ \7 W) J2 k9 X, U0 l
  @. q6 \$ G- C4 K' G</script>

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