返回列表 发帖

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

<style type="text/css"># v$ s) U! `4 x5 e
#supertext {
, Z  _5 z  I0 N) L# ]0 V+ O5 }4 `position:absolute;7 }5 Q1 d- r/ K5 s3 t3 Y, F
left:0;
! {; A" ?/ w! stop:0;
0 m0 _' G. F3 Y3 A& K2 q, y3 cvisibility:hide;
1 j/ ]" r/ F  C7 o' G* Ivisibility:hidden;$ w  U% F, _+ V' ?$ ]4 D
}
7 I% Z% Q2 x- c4 }4 N</style>" E+ c4 ?# [% C9 g) a0 F
<script language="JavaScript1.2">, }2 J8 p5 i: v; M
<!-- 改变下的字体的大小。颜色-->+ A) q. U' S3 S: x" Z- x/ a+ ?
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
& y! H5 ^- h  e% n& O: Nvar hidetimer='';6 F& u1 r& n  l+ R5 g4 j
<!-- 改变下的弹跳速度-->- Z7 I/ R, ^& }, [% h
var BallSpeed = 20;: l* r: i- ]: a5 f6 o4 \0 U
var contentWidth;
0 T" s% q, g7 C, t: a. d( }8 Mvar contentHeight;
, w  c. y3 Y8 gvar maxBallSpeed = 50;* ^; ?/ U6 J: c! s4 _. d, M

; r5 h2 J1 G5 J
; X/ n5 W( c# S& ]3 s0 C2 Fvar xMax;
3 d/ W" N' M0 `  W* q4 `3 b9 Hvar yMax;5 _3 C$ h8 Y, g5 D
var xPos = 0;6 a. q& s8 R4 X
var yPos = 0;5 J1 `' C# ^! N" K. U/ C$ D
var xDir = 'right';
$ r0 g9 g6 ~0 s+ O* O& H2 Wvar yDir = 'down';
' ?7 N3 R2 S3 N  t$ A6 f6 R2 i& f1 M: Zvar superballRunning = true;* h2 C& F6 `* W3 G% c7 c5 G
var tempBallSpeed;, d) c2 F. P: @3 j
var currentBallSrc;
$ J0 W" ~' k1 h* G& u( V; \var newXDir;2 H5 z7 _  m; o) @7 X
var newYDir;6 r; t# N  R9 ~% k" R

) ]7 G' H2 Y# `function initializeBall() {. Z2 C1 g  Z1 p4 x
   if (document.all) {
( O0 I( D7 |% r* \9 G      xMax = document.body.clientWidth  p/ L, g3 k" i6 \+ ~& V
      yMax = document.body.clientHeight* e& |  c- r: L/ ~% i* M/ W' x* w
      document.all("supertext").style.visibility = "visible";* c; j! i6 q" V; t; F; j$ \
      contentWidth=supertext.offsetWidth
- w: Z- l: D1 f+ c$ z. V. }! Y% k6 b      contentHeight=supertext.offsetHeight
4 Q. ^3 e0 B/ A( I6 c      }
/ O: T/ B# M" G  D( w+ V7 v! {   else if (document.layers) {
. A  f( |2 q. N1 g      xMax = window.innerWidth;" `5 h3 g' ~7 M. }
      yMax = window.innerHeight;
& G0 m8 r3 q. r$ G' P      contentWidth=document.supertext.document.width3 Y( s) l9 J6 S" b: j/ C
      contentHeight=document.supertext.document.height
  s# J: `: V! |. J+ p      document.layers["supertext"].visibility = "show";8 A/ U# e! w5 k: \
      }( v; q# Z0 e6 e- F  e
   setTimeout('moveBall()',400);
. N! C$ q' W6 y  J2 M9 f( \' y   if (hidetimer!='')
, p% ]8 f! A$ ^5 L& `& i   setTimeout("hidetext()",hidetimer)
0 \: g2 C4 ^  G. W8 z. M4 y2 a! Q   }
5 d( K# R) j% g/ r! Z; A# V( Y2 ?$ F. w0 w8 i( ~# H5 u
function moveBall() {
9 d/ r; s- s: y' a; S7 a! C  Y( E   if (superballRunning == true) {
$ v$ k7 @$ n6 C8 D3 q, f3 P+ ^0 E      calculatePosition();. P: O8 K7 W1 o3 Q7 S; o
      if (document.all) {
4 z; T: K9 y# V+ q$ m         document.all("supertext").style.left = xPos + document.body.scrollLeft;( E$ ]6 ?6 x2 ^  Q/ ]
         document.all("supertext").style.top = yPos + document.body.scrollTop;) [. i' s5 y* b  H
         }# `8 i- N. P; Y# S/ t  M1 M& P
      else if (document.layers) {3 G" \0 t/ o9 T! S1 }& e4 d( i
         document.layers["supertext"].left = xPos + pageXOffset;  e# N8 i; \, ^! E( c
         document.layers["supertext"].top = yPos + pageYOffset;. k& J& a9 S2 D: B; a0 w5 v
         }
0 P" |- |+ n/ h6 B      animatetext=setTimeout('moveBall()',20);
' W3 E, L0 h; g: w" X  }      }
+ p* [0 W: k5 y7 s/ F0 T   }" S" |  X+ @3 Q! B' e1 x2 S8 E
: V/ ~6 o" ~0 a; F0 W9 M
function calculatePosition() {
. B6 j$ o  |" H   if (xDir == "right") {
- B! [7 i  A$ p& F9 s# N      if (xPos > (xMax - contentWidth - BallSpeed)) {! N" u  d1 W! z/ H. e
         xDir = "left";( n0 D# t' s" `/ ^  a! F
         }
( w& s$ N# D. A0 N) D  s3 ~0 }      }% d$ r8 [$ T* K( G! [
   else if (xDir == "left") {
% l, H: V+ _0 C/ T" A8 i, o      if (xPos < (0 + BallSpeed)) {8 C: V/ d- w' x9 _( m
         xDir = "right";
0 x* \! R. U6 a0 _2 ^! @9 ]         }
0 w7 O$ ?3 E7 v0 h3 U" l      }
5 B( T$ ~( P, g/ p7 t; G+ Y0 e/ a   if (yDir == "down") {
6 G$ X7 n: a1 J      if (yPos > (yMax - contentHeight - BallSpeed)) {& n/ Q3 G. E6 E+ y4 v7 f
         yDir = "up";
3 v2 q1 P" t- r* Q) {! p         }
4 i4 J$ U0 y2 f* T9 Y      }* u( J  t( o, f! f; W* k, H' v
   else if (yDir == "up") {$ S3 z8 ?8 S, }  T& e9 b: d
      if (yPos < (0 + BallSpeed)) {& E! W3 _! p& l2 K) R
         yDir = "down";! k+ v; @2 q3 A" f5 v) t& y
         }) {! o# F* l, {0 X' [  O8 ^
      }
- J. j5 U" l$ L! S" }   if (xDir == "right") {
9 n" ^( S. U3 m9 j4 i3 D5 E      xPos = xPos + BallSpeed;% D$ j# e& b& K% m3 \  I% S/ w4 a7 @6 V
      }
- B$ a6 o/ J6 D   else if (xDir == "left") {* L* ^! q' a1 {7 p7 c6 f$ T
      xPos = xPos - BallSpeed;$ ]5 n1 O$ N# ^* C1 y6 ^9 o
      }
0 F" {. D# i+ q1 w1 i% Y   else {3 b- ^$ i) q8 w
      xPos = xPos;
/ e8 |; I0 c& [- M: b      }! N- @) C* q: Q0 \
   if (yDir == "down") {
6 y! _1 C3 g- d/ L      yPos = yPos + BallSpeed;. m& @% U! s3 I) h" w& I4 b+ C
      }: y0 W) [& \# \, C3 A% B; D0 R
   else if (yDir == "up") {
- q% L6 p9 U0 r. D! J, L      yPos = yPos - BallSpeed;
9 O9 k+ K! h" J3 n# H      }% u5 @% B# n4 e6 m( q4 q; K/ G1 r7 u
   else {' Q8 L; d& S( q' B. b6 a6 k3 j8 V
      yPos = yPos;: ^: ~. ~+ p. I# x7 t/ t( z. L; `: [
      }, @) l) J: N$ f0 {$ c1 f
   }
- K" x! `. Y3 w3 u+ L" Z. J- D% i. I3 z. x( ~" o
function hidetext(){5 }( W* m( p+ n7 N9 |- y
if (document.all)* ?* ~! w- Q4 x1 `9 y9 A
supertext.style.visibility="hidden"
$ `( V/ v: ~4 e3 h7 a9 `& relse if (document.layers)
1 A3 Q& `' D8 m( J. m* O  pdocument.supertext.visibility="hide"' i0 n7 m( d4 D* }7 ?
clearTimeout(animatetext)# _8 d" C/ e' O( ^9 w% V2 D% B7 R
}0 w1 f0 n$ X: u' s- {( L
% k3 y: R$ Y5 K& M: ]  K$ L" }
if (document.all||document.layers){( s' ?, I+ ?1 u. d; m  E
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ l- b7 q" l) _7 q' b# a7 f0 nwindow.onload = initializeBall;3 r: M0 z7 p' R, j
window.onresize = new Function("window.location.reload()");9 t( E, N. b' R5 |7 Q5 R
}
  J: i1 e2 g5 K3 ?4 _9 f0 ^6 o  k* H8 a( Q5 D9 j) A
</script>

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