返回列表 发帖

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

<style type="text/css">. j% h* n8 ]" H! j- _( s& ~$ n
#supertext {
2 y9 d. |  G! Rposition:absolute;# E5 C: L# J4 F8 R0 \  y2 u: X
left:0;
1 K! q8 v" k+ A) Y8 c  Y4 Ztop:0;
* J) a$ a$ h# o$ N! U/ }2 bvisibility:hide;
# i' D) n2 t; m7 I# b) L8 ovisibility:hidden;
1 `0 I/ [7 k3 {8 H( ~: R}" J/ T  m1 y( U( f; Y2 {$ H
</style>+ }! X* f! R  V. T
<script language="JavaScript1.2">. W# A9 C; q" c; }1 g
<!-- 改变下的字体的大小。颜色-->2 Y0 O# a) z  d3 ]  g0 `! W
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
/ \0 |; B& y* `: a; Pvar hidetimer='';
6 ]* o  f9 i/ H+ b$ H# q<!-- 改变下的弹跳速度-->( M5 \; H+ z' ?3 U
var BallSpeed = 20;6 T/ x. N4 r# J, \# Z0 U# U- T  o5 z
var contentWidth;
2 ^5 X! V2 l# I+ N+ S1 ovar contentHeight;, Z+ e; y, u; W- L
var maxBallSpeed = 50;) D2 L1 O! N! w0 e8 j' b

$ z! L0 X5 t# t) S0 r9 [. Z# t% I/ x  n1 H6 ^
var xMax;1 \! g1 ]' v  K& [/ ~2 j/ U( B* X& W; {& I3 e
var yMax;+ B$ I) X+ Z/ ]. |- o0 g
var xPos = 0;
! q! D# [6 Z5 C+ y* evar yPos = 0;# \' ^! W: d1 @* N4 a* x
var xDir = 'right';
8 w- }: `1 e/ P9 B' L% Pvar yDir = 'down';( Q( ?8 `+ j' D" N2 Z7 G
var superballRunning = true;8 \* F! u  }  a+ L( w
var tempBallSpeed;
" C% m2 x. t0 L9 c$ C# a4 ]# }var currentBallSrc;
& u9 M1 x( R7 y. m2 p, P# ]% ^var newXDir;
- z6 u% s" [7 B2 o9 svar newYDir;
$ d3 G. {- m3 d, s$ d* z+ ~
& S, n3 N+ ]% D! jfunction initializeBall() {
: `- E7 ~1 f% d" ~/ |* z   if (document.all) {$ q+ h& d5 ~: U" |. \" P3 n
      xMax = document.body.clientWidth
% d8 r2 ~) v5 s, X" I- L- B      yMax = document.body.clientHeight
0 M( Q- Z, R: V8 ^      document.all("supertext").style.visibility = "visible";
+ H% X8 T/ Y6 h+ j% i# U      contentWidth=supertext.offsetWidth
, t, `9 a+ |2 T+ h0 T" g      contentHeight=supertext.offsetHeight
9 {  l7 G+ v% r; y6 C6 N) Q      }$ R5 _1 N0 n/ T
   else if (document.layers) {" D% B1 r5 n& y. C, c7 W) b
      xMax = window.innerWidth;
& V* }: M: t7 Z1 n" c+ ^1 u      yMax = window.innerHeight;! o: G7 g# Y! v5 W$ R9 T( J
      contentWidth=document.supertext.document.width5 A2 A+ `0 t- Y5 A/ s
      contentHeight=document.supertext.document.height2 q4 ]- c  x' K# Q! F
      document.layers["supertext"].visibility = "show";3 q8 V7 K8 ?- L3 B, ]
      }
& d, v6 d+ n& N9 b   setTimeout('moveBall()',400);& w. n8 p5 ^, t9 I5 y2 I6 g8 G' ^
   if (hidetimer!='')
$ Q7 K! u5 o: [   setTimeout("hidetext()",hidetimer)
# Z9 v7 f7 S8 R0 E; d+ K5 w   }
" J2 {& @* g$ b  A) p
( [( P3 ?1 z8 f- pfunction moveBall() {
. y- @  G: x- M+ I, U   if (superballRunning == true) {% \% d6 |7 w# c- w) I# S  c
      calculatePosition();
' ?4 Q8 U% e$ N  @      if (document.all) {/ Z6 G# @7 I' A, z" e5 x+ `
         document.all("supertext").style.left = xPos + document.body.scrollLeft;* a% |* u5 t8 s. G1 @
         document.all("supertext").style.top = yPos + document.body.scrollTop;
  z7 I/ @6 ~" r  k' f         }. R$ o! \- ?5 V$ z
      else if (document.layers) {
" F6 U  s# F3 u* k         document.layers["supertext"].left = xPos + pageXOffset;
' ^* m, X) C/ E* }6 r         document.layers["supertext"].top = yPos + pageYOffset;
1 ]4 C+ N7 a; B4 I3 {         }& Q; V7 _% ~0 U0 Z
      animatetext=setTimeout('moveBall()',20);
7 f5 t! J4 I) ~4 Z5 |+ y6 M0 v      }
6 r# m1 x) Q2 C4 F9 _+ G" f   }3 n" E: r1 F6 |" |9 J: U
* C) \; R0 r# f; q
function calculatePosition() {! j& v2 C$ k' \' ^. L% Q
   if (xDir == "right") {* J& ?; h% W8 ?( J
      if (xPos > (xMax - contentWidth - BallSpeed)) {
8 z2 U% G: C( J0 A6 l# [         xDir = "left";9 V5 Y) U" _) f; N" H
         }
/ y. Z- H7 }* O      }* m1 L- W8 d- a3 V& a
   else if (xDir == "left") {- Q, Z/ h8 F7 G
      if (xPos < (0 + BallSpeed)) {: K$ p7 t1 z6 I/ G7 R9 w, d
         xDir = "right";! W. o$ g" b: p; h
         }# D; O5 Y! I" Q, Z. u: i
      }( w  X; x! e( s0 V
   if (yDir == "down") {. G, q; i7 L4 F0 @+ U' [8 x$ N/ J# K
      if (yPos > (yMax - contentHeight - BallSpeed)) {
& P* N  E* F: \+ k         yDir = "up";  V' l7 u( X. i2 p2 H4 U7 x
         }
1 v8 C" l- W7 u9 ]6 }      }# w$ e7 }6 y3 Y2 M% J
   else if (yDir == "up") {
7 e1 C! F( {! J' _; Y      if (yPos < (0 + BallSpeed)) {
4 d0 A9 j3 T: a. G6 G         yDir = "down";! z& H0 C+ `# A( i3 v+ n6 Z0 k# C
         }
0 u0 f# p0 o) |3 E: f      }
, G& K* k) g" r: a. E3 F6 \   if (xDir == "right") {
; m6 I! k# D: f* a& c4 i# P      xPos = xPos + BallSpeed;4 l' \% V+ B* }0 X6 X$ F7 R1 r7 p
      }1 O& S3 l6 ^! u5 c
   else if (xDir == "left") {. f, j  r( W3 d
      xPos = xPos - BallSpeed;9 g9 b* Y: I+ E) z4 b; f1 q# _
      }
2 N7 V* k- `( d7 u5 J   else {
9 N6 s% m# o6 Q5 I0 I, G8 x8 h      xPos = xPos;# ?9 [3 y3 H+ a
      }
& X. m: y; m0 e4 x- s, g* Y   if (yDir == "down") {* Y8 b# s; Y- e. ~- }
      yPos = yPos + BallSpeed;9 @2 w/ ]. Q" n1 E& t8 X
      }7 B* n8 v: ?7 N% e9 {. U
   else if (yDir == "up") {
* t! {: |+ O, @5 B% y0 y( Q      yPos = yPos - BallSpeed;: G8 }# k: e+ I# ~
      }5 c  E5 Z! A, x  b) k6 }
   else {6 K& L2 @1 N( f: F
      yPos = yPos;
* v$ g. V9 p5 r      }4 p7 D0 G- ?% v  {
   }
7 l! `6 }2 [' @" I
. {* X2 p3 |4 m0 V2 C: ufunction hidetext(){0 Y0 [5 L8 [2 L- o1 F! u$ v
if (document.all)6 `4 b& Z  i# w  j  s# l9 x
supertext.style.visibility="hidden"; L$ m* _, C8 m
else if (document.layers)
! X% s1 e$ x; t5 H, R/ ndocument.supertext.visibility="hide"" e! U" g6 `$ d! b4 O& U7 M
clearTimeout(animatetext)
! Q" R6 J4 u  c$ y" w" V}% o* e! ~+ g* D2 m

1 o2 t# [) t, {4 B8 l9 F) gif (document.all||document.layers){, R  l7 v# X4 m! N+ o0 P* v$ W
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 H+ Z$ `8 X$ d. Mwindow.onload = initializeBall;# R: [7 [+ U' {5 y0 K6 N6 J
window.onresize = new Function("window.location.reload()");
7 X7 r3 h! e" f}
+ w$ V2 q* Q9 Q4 \# [$ g5 I( c; j$ {0 S* O
</script>

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