返回列表 发帖

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

<style type="text/css">
9 O9 k$ m1 m) d* j#supertext {5 N) i0 @: S" H' @  t
position:absolute;& F/ `8 w) ^8 w7 D: C
left:0;: [* I$ s* a7 J" A2 P; t
top:0;
: ~" T+ W5 K+ M4 g* dvisibility:hide;8 x2 H8 H+ ^% }) S
visibility:hidden;
0 r+ K0 s5 x! e* r3 t}
% z" R1 r0 z4 A1 C4 ?- G</style>' q4 X. {+ ?7 ?/ i: E
<script language="JavaScript1.2">+ y3 o4 i2 D0 c5 b- |4 L* w0 l8 i$ e
<!-- 改变下的字体的大小。颜色-->! o# ~( }6 t5 {6 @! e& p' }
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'' Z4 r4 H- \8 M& V/ V
var hidetimer='';
1 a' {9 q' o- O" r<!-- 改变下的弹跳速度-->
- T6 g9 N6 \" A$ b: }/ d3 Cvar BallSpeed = 20;
, C+ v- F' p: n4 [) ]$ tvar contentWidth;  f- e5 _. W1 I; N
var contentHeight;) A. t( V/ o) T6 t( P" h" W
var maxBallSpeed = 50;9 X3 h: x( h. [4 t9 t$ s# N

% u1 V0 ?9 T: ?5 L
( c+ D* T5 L% W  U" N' o- Svar xMax;* E- w- S( X1 N, c
var yMax;
8 e, X: V  Y" x/ {# [var xPos = 0;/ S( \5 n$ a1 d, ~
var yPos = 0;
- ~$ \5 B9 {# G& U/ i4 @var xDir = 'right';
& _/ ?9 m% F' B& Y$ j8 qvar yDir = 'down';; l2 g8 I# Z/ Y$ B- m. Z
var superballRunning = true;, B! ^% w  R2 O, C' g/ I5 H
var tempBallSpeed;9 T; h! D, I- Z+ l$ E- ]8 g
var currentBallSrc;
' w3 H1 Y- g! \( Yvar newXDir;
0 t/ z  v5 z3 t) t5 Z7 h- s/ Evar newYDir;0 t. Z' A) q' @0 k# J
' ^. z; [: C- ?- G2 k
function initializeBall() {8 |( c0 ?- l4 G6 k5 l- O3 M
   if (document.all) {
7 V' q  W0 }1 j2 D5 Y4 c( U3 ?. S      xMax = document.body.clientWidth7 c! B" W! u4 k
      yMax = document.body.clientHeight7 F+ w4 x  I* c; G  W! [# f
      document.all("supertext").style.visibility = "visible";
# S( ~  {- S  p) b      contentWidth=supertext.offsetWidth, N% N& V* L. \2 f- r1 d  y
      contentHeight=supertext.offsetHeight
3 z0 E1 g% }. r& J      }) [( F( [0 x$ g. }8 t: o  A- ^
   else if (document.layers) {8 Y! ]* R  t, q, A2 w3 q  @" [
      xMax = window.innerWidth;) R, Q. h2 |  q9 u$ z$ g) V
      yMax = window.innerHeight;1 Y0 @  k* N2 z% @" R7 B# J
      contentWidth=document.supertext.document.width" q% u) b0 {; B5 z
      contentHeight=document.supertext.document.height
; E! G/ f! W, c3 K% c( A      document.layers["supertext"].visibility = "show";7 B7 ]2 l: a0 T- n
      }
: x+ ^1 l0 W+ W# l* M0 T( B   setTimeout('moveBall()',400);
3 C  N$ a$ ]+ B! e  Z' \   if (hidetimer!='')
$ k2 }/ |/ y0 c$ ?4 k) N' O   setTimeout("hidetext()",hidetimer)
8 Y# f% b. t( U" ^( V: a   }7 n' W0 F- U# E2 C3 I# B% Z. N5 q

! `4 Q" k: z0 ?4 `) cfunction moveBall() {
1 X7 Q" j% C$ \2 v$ w   if (superballRunning == true) {
# X/ I4 X) c# d# e' J# O7 w      calculatePosition();$ D3 u: m0 l' M- B# K8 z5 N
      if (document.all) {# o) G0 `. Q# h5 G8 N, u
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 W! |+ m+ b1 M$ ]- {         document.all("supertext").style.top = yPos + document.body.scrollTop;. B6 c& K% K! k1 A; b
         }
' k0 F$ F  H% @$ h      else if (document.layers) {# ^! f! s& T$ u2 z" B' @1 s
         document.layers["supertext"].left = xPos + pageXOffset;
5 s0 M/ b1 H- s1 g+ F/ |* G2 ~         document.layers["supertext"].top = yPos + pageYOffset;
: e) X8 I% \$ s9 u         }1 y2 H- j8 t: C: L* P+ x8 o/ \
      animatetext=setTimeout('moveBall()',20);; K- L+ O- S4 D. O
      }
) j! \; W6 z. q: {  w   }
- }) e/ i( Z; e2 K6 S5 _; U
! {/ W7 A6 H, G' k) @5 h4 t. Afunction calculatePosition() {
* q1 u3 F. |) ?+ g0 k   if (xDir == "right") {2 m9 {. w4 q3 W! u; n
      if (xPos > (xMax - contentWidth - BallSpeed)) {
' {, H- f3 O' A5 D# s9 N         xDir = "left";
9 o1 }; K* ~& Y5 x+ z" E         }
3 m* d2 t5 m7 ?4 m* z9 z% k( G      }
$ D9 X1 {, e$ u% G, r   else if (xDir == "left") {; b! D$ ^# J8 X: x3 x4 l; u  T
      if (xPos < (0 + BallSpeed)) {* s; s$ n7 p% Q- n* R/ q
         xDir = "right";3 Z- P) i- l! F) M5 A+ g
         }
. C) O4 {8 S' ?% r5 _+ H% H      }
, }- m( F/ J; T* c: D+ y   if (yDir == "down") {$ J! U6 s3 I/ Y) }9 z
      if (yPos > (yMax - contentHeight - BallSpeed)) {
. T3 D* w' u5 H) y$ |         yDir = "up";
2 f1 Q. I2 w% `! m         }
' A$ R& q2 t2 N      }
" o9 l3 R2 M, }1 o3 H# o   else if (yDir == "up") {& h: C  L* g0 M, ]7 i
      if (yPos < (0 + BallSpeed)) {3 P6 @, `. L, P7 O% Q
         yDir = "down";' \3 m0 |1 p+ K& Y
         }
1 N1 {/ l. g/ _  f  `      }; K0 n* ~  H/ y. b& [! L! L1 y: c
   if (xDir == "right") {
* H0 }# X- U! K  f/ I      xPos = xPos + BallSpeed;5 s. T8 d) w8 q$ M
      }
3 M4 M; z& n; r: v# u5 J! x& Z; B   else if (xDir == "left") {
8 q" ]$ }) A9 a# v$ o  v, x$ ~      xPos = xPos - BallSpeed;
4 }2 A. g! ]0 ]: B3 p( c$ ]      }2 ~$ W/ G$ t, P6 @& G6 T! @
   else {
) k* L, h, Q- B2 a" e      xPos = xPos;7 Z2 R! j% C% C9 n: Z0 u
      }
' q1 J' O) I) N! H$ N6 J) s   if (yDir == "down") {8 u% a% T: |5 d0 X. `( |! U7 [/ J
      yPos = yPos + BallSpeed;
! ?- L5 Z& e+ u. N3 X. s! x" E: G      }
7 ^) B6 j/ X) t( _) y2 G+ S7 s; H   else if (yDir == "up") {
+ ]- N* U: w, p: a' @, O      yPos = yPos - BallSpeed;, c& A  P8 T" e3 M* O; b8 \% v
      }, O5 P3 p' P( g, G* {
   else {
% u" N! O2 E0 K* |3 M+ a      yPos = yPos;* I/ s$ }: S  L7 V& L* J3 g
      }8 t* u8 ?4 u# Y7 K6 M  A; J
   }
$ h: ~  C; {5 {9 _  h2 N  K
: ]/ @# ~6 k! F& ffunction hidetext(){* a; U, {" y4 D0 H
if (document.all)% U9 B4 O/ c9 {1 e) ]0 o! a
supertext.style.visibility="hidden"/ ~! w7 U) l, t, E" k
else if (document.layers)% C7 x- f  @' L4 l7 O5 Q
document.supertext.visibility="hide"5 r' }! h' i- g5 u
clearTimeout(animatetext)" F# z+ C) a- A7 h0 g$ t* ?& _. p
}! N+ _0 d* A! T6 P& k- N* |7 e
3 \4 d4 t5 f* m  o
if (document.all||document.layers){
, A9 X2 Y+ `( B6 V- xdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')! N; Q6 E( Z8 }- E# O
window.onload = initializeBall;
# V" c4 M! o4 y! {( M9 ~window.onresize = new Function("window.location.reload()");
$ E- d5 j0 s( c}
8 D& L3 v* ~  ]% j2 b
* S* w. y- p3 [: |9 ^</script>

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