返回列表 发帖

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

<style type="text/css">
! o! X0 u9 y* U! {" O1 r#supertext {/ b0 a; B" H! d; F3 G( k# U4 u
position:absolute;
% c( Q( g- ^) T3 \! D6 u! D5 ~left:0;
5 d- T" }1 G* a1 f& S* s# h& n6 _top:0;. a5 [; R; c2 Z0 P( K5 B
visibility:hide;7 c% z( h4 e( Y/ m! u- h  h
visibility:hidden;
/ a! g" \6 D% C" \1 K; v}
* V3 p% y: U: t5 l( J</style>( s  Z" X% A$ ?" V4 W- v
<script language="JavaScript1.2">
/ V3 Z  a7 Q- J4 X3 ^; f6 K<!-- 改变下的字体的大小。颜色-->
6 O) t" h% P8 y6 [var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'6 Q; P9 A9 w5 h, T9 U" s
var hidetimer='';6 M8 p8 d$ s; F2 I1 R# P! Y
<!-- 改变下的弹跳速度-->
  V& t( i9 P- o) ]2 Q0 Qvar BallSpeed = 20;
% D8 ^! `+ O' v9 k" {var contentWidth;
0 u+ c& l& @( ^' w' n$ n2 k/ ovar contentHeight;1 p1 P' m- g+ a) X$ w
var maxBallSpeed = 50;
4 s$ u. Q1 A/ o5 W4 G
1 N- {6 u. ?( F/ ]1 \. q, O  @; A
9 k, {9 v/ u) x) B8 a+ `7 R7 q3 Kvar xMax;
) g8 j. j5 p3 g: ~+ U7 R! d) \var yMax;
, q; {! I& {# ]6 c& R; hvar xPos = 0;
0 {' j: L4 t6 u/ dvar yPos = 0;
+ j( V0 m9 M) a& y& U- mvar xDir = 'right';1 M7 D" C  [3 V8 h# h7 o& M
var yDir = 'down';
7 Y% v* B. b& Fvar superballRunning = true;2 b& z4 O9 y) p9 l: ]
var tempBallSpeed;
$ @" Z) t: `* t: Z% Tvar currentBallSrc;1 q+ p" _- ^& z2 Y; _
var newXDir;
& l2 c1 z3 P% Q9 nvar newYDir;3 E* ^9 o, n$ E" U# Y
5 I, x: _7 Q+ Q' |! u$ X. [0 R
function initializeBall() {1 y  H3 H) F- @
   if (document.all) {
- m6 d) k' f/ w* B' v' i      xMax = document.body.clientWidth
4 ]/ o( v9 K; Z' f      yMax = document.body.clientHeight9 u: N7 f  w3 _" a
      document.all("supertext").style.visibility = "visible";% }5 U5 }- L% k. ~2 d
      contentWidth=supertext.offsetWidth- k! e7 I6 o4 n
      contentHeight=supertext.offsetHeight
. I- q- ?5 Z/ w+ }      }; m9 M: e/ T: g5 q2 {% Q
   else if (document.layers) {# W6 [& }* J+ Z' d8 t6 p+ w& O
      xMax = window.innerWidth;
$ Z; a) y' K0 G- k% k      yMax = window.innerHeight;8 K% D0 q$ \7 ?. S2 I
      contentWidth=document.supertext.document.width. B5 F# g6 r  s" G% l
      contentHeight=document.supertext.document.height2 O( j7 D6 M  L; I' ^
      document.layers["supertext"].visibility = "show";' V2 n$ [* _& s/ c" [+ z  ?
      }
7 V; L1 L4 G: w. e/ R% L   setTimeout('moveBall()',400);
$ d6 E' u& d# w8 @   if (hidetimer!='')6 g7 l  i- h! G- b" B
   setTimeout("hidetext()",hidetimer)
' d6 b% A4 D+ }* z6 v$ ^/ ]1 ^   }
9 g  W2 |" R0 a2 c; V8 u1 @# {' |6 }" \: C* s8 l  s. r
function moveBall() {
" c) j* W2 x! v4 u5 A   if (superballRunning == true) {
9 c% X1 J1 z3 |0 G; d& \$ m      calculatePosition();/ b* [( r! _: m# g3 v5 t4 u2 N, D
      if (document.all) {( ]/ U5 h" z2 P4 I$ `4 Q
         document.all("supertext").style.left = xPos + document.body.scrollLeft;7 m% i2 I- _) j
         document.all("supertext").style.top = yPos + document.body.scrollTop;& b) S2 e# q" n8 b: F
         }5 W5 u+ \) _$ l$ K0 h7 p% C: N
      else if (document.layers) {
9 Z4 B/ D: N: ]- r/ A& `. R         document.layers["supertext"].left = xPos + pageXOffset;
" Y, n7 d5 ]( @, Q6 }' Z& n. k% w$ w         document.layers["supertext"].top = yPos + pageYOffset;
+ g# i0 V5 j+ w         }3 i1 [3 y0 ?- u" I
      animatetext=setTimeout('moveBall()',20);4 E- Z6 T) s; m/ x
      }. ]% J- Z- y$ w2 X) a$ p7 R  ^0 Z
   }  ^1 Y& B+ O7 s1 @0 h5 y. ]3 B* Y

9 E! h2 w& K' ~- e' qfunction calculatePosition() {
4 E2 u2 U& l& D) y# f   if (xDir == "right") {2 f. ~3 n- a. Q- f% A0 h8 a
      if (xPos > (xMax - contentWidth - BallSpeed)) {
, i; B5 Q5 p7 M8 r; F         xDir = "left";
# c5 F9 ^1 @: ]5 p7 ^         }- |& S9 v  s2 z% T
      }( _, Q0 O6 T3 m  A
   else if (xDir == "left") {
( _9 C5 U  {) a) z2 f$ E  ?$ r      if (xPos < (0 + BallSpeed)) {
% ^5 ^) r- I0 Z5 W' Z         xDir = "right";5 T8 s+ T1 X1 V+ ?! b
         }
* h8 l0 Z1 t7 W" p      }9 E: Q* j' S  `$ d/ n0 j
   if (yDir == "down") {
$ H0 x7 J( ?$ \6 a      if (yPos > (yMax - contentHeight - BallSpeed)) {5 g' t& d  q( E* b/ D5 T. v0 m
         yDir = "up";
5 K- C1 r/ s. ^# Z* W# R         }! ~7 V# f. L* @/ p' j4 {
      }- d3 l' q. B4 V1 F, u
   else if (yDir == "up") {1 b& _( W; o# d. e
      if (yPos < (0 + BallSpeed)) {# B3 D6 ?& N6 B4 O
         yDir = "down";6 D" U9 @0 _8 l9 }' F6 p8 Y- G
         }. {5 ?# w7 Y( S
      }
1 H) w! t( V) S5 l1 K! T8 K   if (xDir == "right") {
/ B7 M9 f! h7 I! H+ T$ C! ]: t      xPos = xPos + BallSpeed;
+ ^% k: Y( x  K& D0 ?1 n      }
6 j$ r$ _( Y) i3 c" @   else if (xDir == "left") {
$ `1 C, r- g# k/ {/ d      xPos = xPos - BallSpeed;0 o  L5 v5 i8 d6 t- T" H
      }; ]$ u) N( z( v/ d) Q) V3 i
   else {! Y: T4 O/ I. a- e+ \
      xPos = xPos;/ z" S0 b+ B! c0 u5 x" n- H* N& h
      }0 H0 ~* S& A' G/ u
   if (yDir == "down") {& c- k% y0 s$ u3 _4 {" I* }
      yPos = yPos + BallSpeed;" a/ [4 E8 M' h3 z( _1 w
      }
. l* T8 |: X& c' B8 f   else if (yDir == "up") {+ k1 |1 \$ [' r* _
      yPos = yPos - BallSpeed;
7 a9 N1 x9 W; @2 G) u2 q      }
- F4 m* X) A$ A  \% J0 K5 {, w# g   else {
; G" F  D8 i* e2 k* m/ _6 [      yPos = yPos;. f4 J$ Y8 h# x/ o, Q/ P
      }# D* E' T+ L/ L# h+ J5 B9 n8 r& q
   }
1 P: T( {( h. x, D* ?0 {" @4 H$ X& ~- v4 i
function hidetext(){
$ `  ^/ J: m  t1 _8 q7 ?if (document.all), E- @# P2 j4 C1 n8 b) o' s
supertext.style.visibility="hidden"8 s  _, v2 ^# E& ~* i5 A" w- z# t
else if (document.layers)# r, \( b. k# y% H; H* k
document.supertext.visibility="hide"+ ^  h. ?* K! P
clearTimeout(animatetext). V# v4 T. X. b, R3 m6 w+ [  r9 i
}
5 v" c- s& [" q( E1 X
) g( e' w! G' W6 `3 Lif (document.all||document.layers){
: ]0 {! b3 i% `! F* x! y5 Rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" R5 @3 d" y6 q, {- rwindow.onload = initializeBall;
+ A2 A4 A: n1 I8 P! wwindow.onresize = new Function("window.location.reload()");
3 f! [: n: r; V) Y, r' }: R}
+ F' _" a! k, E
3 ~3 K# \1 E$ N' T. e/ J</script>

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