返回列表 发帖

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

<style type="text/css">% m# f1 K1 D. X% H$ L; {
#supertext {
, {$ P" d" j, P# ]position:absolute;
1 [- b1 x, I$ {& B( t. p" M" g7 Nleft:0;9 S  Q: \% C; O
top:0;
: G2 y3 t% M* C! k8 ^& _0 Evisibility:hide;0 p) w; Z+ ]" u
visibility:hidden;
* L! {6 P- Q+ V}
' n  M8 C% M) s  k9 j5 ~$ n</style>1 Q! j6 s# _7 K& b6 D9 X
<script language="JavaScript1.2">
: u# \4 J8 k2 d% f# K8 f<!-- 改变下的字体的大小。颜色-->
+ `6 |1 \8 y  r. o5 ]6 Pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'- ~/ h1 o1 R- k" e$ F- }# q* }/ h
var hidetimer='';! Y$ E; Z! w, Z" B+ |/ j: }
<!-- 改变下的弹跳速度-->9 r# ^5 F* Q5 s7 `& F) o
var BallSpeed = 20;; j( ^' P1 I, P6 }) B5 X$ e
var contentWidth;
2 O# v1 A3 T3 I- [7 o- L9 j; x7 [9 Ivar contentHeight;
! ~. Q6 N: k2 a' C: A; z: fvar maxBallSpeed = 50;/ z8 x7 o9 p2 k( }# {

* s1 o- k" u. I: r2 k: ^/ q( Y
9 W' K! s; F- |; l2 yvar xMax;
/ p* }0 a( }4 w! ~) V$ Lvar yMax;
; G7 p7 ?! T! E) w6 B; w$ B9 |) Q+ B2 tvar xPos = 0;
9 J' |  b) L: q9 p8 {7 Cvar yPos = 0;
) n# X8 O; g2 y" r5 o* yvar xDir = 'right';2 {: f" q: ^$ p5 b; H
var yDir = 'down';" e8 }  ~2 ~0 E% ~( \6 s  F
var superballRunning = true;& e- f' w$ y4 N3 R6 X/ B
var tempBallSpeed;
0 E) x  |6 ^1 ^var currentBallSrc;4 h9 s- [/ d( t. Z) s! e+ q
var newXDir;
; p/ z& U5 A. ~7 o; Vvar newYDir;) n, b! d; ~8 L7 G' M
! U+ V" X3 p5 Y2 o( b+ N8 q
function initializeBall() {
" L/ e. H/ P9 K8 L" _   if (document.all) {. B4 G2 J  B2 s3 k, |
      xMax = document.body.clientWidth+ R6 R" `( G& u0 u4 m+ Y" n
      yMax = document.body.clientHeight1 T) p7 p( s9 ]
      document.all("supertext").style.visibility = "visible";
5 M! e, M; g* x+ y! g  z      contentWidth=supertext.offsetWidth7 c) D1 J" v2 C* s9 K( Z, \5 J
      contentHeight=supertext.offsetHeight3 _' O* u  m: b- Z+ a) ]+ Q
      }( I% l  D8 ^/ I+ R
   else if (document.layers) {7 x4 Q0 u2 \  W% h; ?
      xMax = window.innerWidth;( M+ b3 j/ |3 m  b- u
      yMax = window.innerHeight;
) i# ^6 E6 f1 l0 O9 I      contentWidth=document.supertext.document.width
' y  W1 i- z6 ~$ X      contentHeight=document.supertext.document.height
: D3 L9 W6 `+ b/ w      document.layers["supertext"].visibility = "show";
! S) ^: B; a/ c3 f! V; F: |8 H1 a      }9 `: H7 K9 b" S$ x3 h( V
   setTimeout('moveBall()',400);
* ^( n4 Y) d7 `; L4 R   if (hidetimer!='')
' A( @: l9 L) D9 X( o8 R0 T   setTimeout("hidetext()",hidetimer)- ]0 w) v9 U6 H6 ^4 K5 n" h$ M
   }: T0 S  s- F- l3 K$ v
+ s) |5 Z9 X9 b5 W
function moveBall() {# p2 c# g) G+ E/ D+ A
   if (superballRunning == true) {# v& l- v! i  b6 I
      calculatePosition();4 k5 M2 ~$ Q! m# [% C( `% g8 |
      if (document.all) {
1 \: ^7 ^  z( Z' @9 r         document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 g7 x+ a, n8 _; E$ B* n; s         document.all("supertext").style.top = yPos + document.body.scrollTop;
- k$ x& @9 ?# s" m) K* V5 U. p9 A5 I         }4 V; ~" N) R, Q* j$ h* ^0 E
      else if (document.layers) {1 ~, ~7 |% S/ U" _5 f7 _
         document.layers["supertext"].left = xPos + pageXOffset;& V6 u- I/ |. j5 l  D1 A$ D7 L6 d
         document.layers["supertext"].top = yPos + pageYOffset;
, r% h- r; k+ E         }
. G6 r) H# T  r      animatetext=setTimeout('moveBall()',20);
& _' o7 w5 S- @7 Y3 z      }; o5 z( w- y3 u, i
   }
# H' V; n& c4 `& F0 b' y
; {  f1 N# e+ S) d( p3 m& S! Ufunction calculatePosition() {; w# E5 @- O$ B* B) Z) H" Z% m, F
   if (xDir == "right") {
& c5 g' P' |/ o5 V( k. p$ X+ S      if (xPos > (xMax - contentWidth - BallSpeed)) {. h1 ~: G- v1 u  m  p& l5 y' V
         xDir = "left";6 |( _5 t: O9 O) ^* [4 \+ ?" I
         }
9 \) }" `+ g% k9 T! _- Q      }
3 Q9 ^+ T8 S1 G$ H% B) W   else if (xDir == "left") {3 y4 ?7 L3 |: X
      if (xPos < (0 + BallSpeed)) {$ ?5 C5 V- y# X' e
         xDir = "right";+ [* C8 H' x1 S% j" j2 E
         }5 U1 U) d* q$ p$ B
      }
$ X7 {; N' ?7 f# `# b   if (yDir == "down") {
: R0 Z- g" H- X$ ~1 q9 u5 w      if (yPos > (yMax - contentHeight - BallSpeed)) {" ^% _; y6 e0 T
         yDir = "up";
; @7 b) Z0 |! e, [/ z+ U* B         }
, A$ D* a' z( g      }1 V) `3 r1 v' @$ |4 b% |/ l
   else if (yDir == "up") {
( @: a  }" {. \% ?5 a) ?  Q      if (yPos < (0 + BallSpeed)) {
- ~1 y4 z( c; W: e         yDir = "down";' o0 |% S+ [, S) X3 X
         }
* a4 e# E) [! [& C& k      }5 H: A( t8 Y5 p8 }5 t
   if (xDir == "right") {
, H1 }: B& _3 p" ~! {* e; g5 i      xPos = xPos + BallSpeed;
, h  {/ K' ?) O" U; l  E. A8 o* b* O      }
) l' J' e. v+ `8 M   else if (xDir == "left") {) S. }8 H+ m( U7 v" S/ t% c2 a
      xPos = xPos - BallSpeed;
' G% a! M$ Z- T: M1 o0 [& q      }& j& W3 M& ^) u( p! e: c% U
   else {9 C* T& k% y  c5 s
      xPos = xPos;
0 d, T3 t1 x6 E% Q& `8 A% D& ^      }
) e( @; N* {: d% w5 w   if (yDir == "down") {6 M- w: V( z9 v0 Z" E1 l& ^
      yPos = yPos + BallSpeed;
  q  A6 Q# H9 l2 C      }; w7 T- ~- z- ]9 |
   else if (yDir == "up") {
9 Y: {9 A9 J8 ~; G      yPos = yPos - BallSpeed;
" b- U. N$ y: ]; `      }7 T  U- }. K% s# d) u/ o" W6 _0 @
   else {2 Z, _' W9 y) Q) O9 G- O7 l
      yPos = yPos;
% i, ]- n' }# e! w7 d. A9 ~5 J      }
; F+ [$ }6 ~- V. K% R   }' }: j# Y1 m; J, x1 P" G
, h1 ], o. s9 u7 k
function hidetext(){
  g0 p8 B- e1 g) O  H  z% fif (document.all)
$ e# Q0 ~* m- s, E6 w9 G0 h- ^supertext.style.visibility="hidden"( o$ k. {- Q: _( q% P
else if (document.layers)
0 b5 J7 ?$ x; G* J% sdocument.supertext.visibility="hide"8 l4 E1 H1 I( x& X2 }
clearTimeout(animatetext)- E3 a, X# k( [* ?0 h" R; J, R& @; T
}: g! s: O0 w4 ]" c6 C

6 ?7 \2 r, _. E+ j9 O/ Y- Y  e$ Tif (document.all||document.layers){
* V8 b/ M: I3 f2 d% C9 T  Rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 r2 b, A- S  z6 W+ b( @* O
window.onload = initializeBall;
( d/ \* n% N# G! Vwindow.onresize = new Function("window.location.reload()");) i0 M- y9 a; e. s6 Y/ K3 n
}# E# A6 y. w5 H" B0 L
  {# Q. o/ r9 d4 N
</script>

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