返回列表 发帖

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

<style type="text/css">
: j) H# G% H4 z#supertext {. q$ G% g8 q4 u5 m% ~3 ?5 E
position:absolute;' @# \) k& C7 ~; Y  Y8 c
left:0;
) g% P$ ^' s& X1 h) G: j2 R) |top:0;2 e5 W5 ~2 S% O2 N; c
visibility:hide;0 g$ B5 Q- o, V) j# l
visibility:hidden;
7 d' w2 z& H+ Q. e}
3 V- p! m. E: b</style>5 U% |3 W' q  H! x" R
<script language="JavaScript1.2">- L. ^& q& H7 R; x' V0 {
<!-- 改变下的字体的大小。颜色-->; m# s3 c2 f% p" R+ ?  c% V( {
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 k2 i3 e# e% i$ u$ b
var hidetimer='';2 V# K  Q4 S9 R1 C
<!-- 改变下的弹跳速度-->0 U. X4 Q3 k; e
var BallSpeed = 20;
: m( {5 y  f" g3 j* ]& s4 vvar contentWidth;8 S# G; {2 ~- v
var contentHeight;5 c% e: T) H4 y5 c, ^; |
var maxBallSpeed = 50;
; t6 w* A" |6 I6 h9 I2 Q
1 i# o' l; z  |+ Q+ j3 Y% [2 |# `
var xMax;
0 k' j  ^" \, a% j& Rvar yMax;
$ g' y3 D" u6 r1 V+ O" `8 s6 \var xPos = 0;/ s( h3 U+ X; B2 z
var yPos = 0;
+ Z2 E' m$ e2 J2 W$ ]var xDir = 'right';
1 a( o# b% C' i9 |4 B9 o, @var yDir = 'down';' Q" J6 ^/ a) P. l
var superballRunning = true;
& j5 T( G& h6 F6 c7 B( B6 }var tempBallSpeed;
  R0 _4 H( G# z! Wvar currentBallSrc;7 e. ~# l0 O+ h4 _6 {, c# l
var newXDir;- B+ z) D- _9 p" _9 G% h8 T
var newYDir;: F9 P: F8 D) z
1 m. |) H  D  o' T+ N2 J- p! X* @( u
function initializeBall() {* z" W2 i7 i0 z7 o4 q) b
   if (document.all) {% d) k- w- J  C0 S+ N
      xMax = document.body.clientWidth
5 W1 h0 M7 k$ |* ^, ~! K; i& N2 O- s      yMax = document.body.clientHeight# l# h; A8 c3 D! D9 |5 ~4 T  s
      document.all("supertext").style.visibility = "visible";$ Y3 w% @4 b+ u
      contentWidth=supertext.offsetWidth
! B% y5 }. d; a4 |2 X  e6 J      contentHeight=supertext.offsetHeight' A" z& C' ^5 o" E. j
      }
8 d" c8 W, C! I   else if (document.layers) {) s4 o! T6 M- L1 J7 d; J' w# I
      xMax = window.innerWidth;8 A& W; X( P! N. j# s4 g% b
      yMax = window.innerHeight;
0 D7 \1 Q: J- a. p* t4 E      contentWidth=document.supertext.document.width
3 b) [; R6 Y  j, _3 y      contentHeight=document.supertext.document.height, ?& l: R3 y* `( K* C8 ?
      document.layers["supertext"].visibility = "show";
$ |( g2 T, R* `& r      }
. e3 x" ^8 P- [4 C) w   setTimeout('moveBall()',400);
8 s4 q: l; ]1 A   if (hidetimer!='')* Q. M6 [5 W) ]$ @
   setTimeout("hidetext()",hidetimer)+ @. |' J$ x% G8 n+ M% n
   }
9 R3 T5 s3 ~+ q7 w4 t# j+ p
( G6 D0 k& d. e( \! Wfunction moveBall() {
" `  o/ m4 m- g! M. ]7 z& i   if (superballRunning == true) {; K- J4 c7 H# K4 ?$ j
      calculatePosition();- b$ c) D, r. A" W# {) l
      if (document.all) {) |3 Q8 x' z+ j$ E3 C8 \3 c) |
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 l  k5 o- Q; d" X         document.all("supertext").style.top = yPos + document.body.scrollTop;0 Q( q+ U& j/ z& M
         }
+ F0 l) K$ l8 O      else if (document.layers) {
! D# x# f& L( ?1 O4 L         document.layers["supertext"].left = xPos + pageXOffset;! I/ ?# l# H6 m
         document.layers["supertext"].top = yPos + pageYOffset;9 b; U( w6 v# e
         }' b' w, Z9 o1 a
      animatetext=setTimeout('moveBall()',20);& A* K4 d# g) t6 r9 {
      }- V* N; ^0 Y4 C" U; y6 K1 f
   }
5 N8 K+ W! o- \! R8 B( s. G% I6 ?5 \8 q4 Y" E5 I$ k
function calculatePosition() {
5 @, A7 P8 A/ z  T! k+ t2 H. P7 L   if (xDir == "right") {
! z' v# E- W1 }4 _- K      if (xPos > (xMax - contentWidth - BallSpeed)) {5 Q* g: ~  @9 Y. W$ C/ j* E. x( h( _0 Y
         xDir = "left";1 N, U1 x' }2 W+ T" T+ |8 M
         }1 Q5 K  L: w  j1 A: d7 F1 _* i
      }; W/ C+ g% B5 ]2 L6 R9 q% m
   else if (xDir == "left") {
2 H: a4 t0 m% _# T' }3 N      if (xPos < (0 + BallSpeed)) {( x; ~3 b' z! `; `1 Q: S5 Y- f
         xDir = "right";3 S( s9 C3 ^5 V" L! g6 E, b+ j7 T
         }0 W" V0 B+ U! @9 H2 z0 z
      }- v* d3 u8 c8 o( K8 B
   if (yDir == "down") {. Z/ e, F( c7 R! |( i5 v- [. G
      if (yPos > (yMax - contentHeight - BallSpeed)) {5 t8 k- a, g7 S& [. p
         yDir = "up";8 y& ^( Z/ C, u4 z$ w$ j
         }
/ P. N7 W1 Q* R& k& ?      }/ [) Y4 P/ m. B% j9 I
   else if (yDir == "up") {0 m# V0 k% F/ w' i
      if (yPos < (0 + BallSpeed)) {
! I- C! o0 y7 e( l% I         yDir = "down";1 g& p! c$ A  p+ h0 p1 a( w
         }
0 |6 o0 h' l6 X, t* o      }0 i4 z# j; s" V
   if (xDir == "right") {
. v) \& R8 X$ w1 s* W. ^! m" r  r" P      xPos = xPos + BallSpeed;
* s! w3 U: f, h* Z  T3 Y: C      }9 Q1 l5 \' G' c: G3 ~0 O
   else if (xDir == "left") {' g- z4 d) T' @+ F9 z) M
      xPos = xPos - BallSpeed;
1 D+ e0 C* W) G4 I# ^      }0 A0 ^! ]+ F! S3 i
   else {* M* M0 o0 [/ U3 l5 j
      xPos = xPos;
2 a8 ]8 t* |- u5 z- Y# \) }# a      }4 X( A5 t% Q- a5 h6 m
   if (yDir == "down") {
( L& K' K5 H/ H% V      yPos = yPos + BallSpeed;  I: a" i: q6 |3 R' u
      }- G- h; V7 L3 \$ ^3 b7 |
   else if (yDir == "up") {
/ C) B, {, N+ }# E' @      yPos = yPos - BallSpeed;
3 S/ t5 `, A; E7 m! s9 u3 Q      }
; i+ V0 ]' E; ~/ \' i   else {
2 D% M2 U. e+ Z2 Y      yPos = yPos;) y8 Z$ t$ K( {7 o. }) [
      }5 `! y, W% a; s6 D' A
   }( a/ E* Z7 V" y! O4 C6 c

6 j- k: J- w+ B- ^, l2 p9 cfunction hidetext(){& z: @. V5 n; W
if (document.all)
8 G0 [  a' w( z( _, l  N) e4 Jsupertext.style.visibility="hidden"7 z& L  ^4 ^1 w# K9 ^; C, s
else if (document.layers)
  M) ~0 n  h2 S- Jdocument.supertext.visibility="hide"
3 P; D0 r* R' P% R6 F/ K% iclearTimeout(animatetext)6 S5 W; T1 C  o% b/ z
}1 \3 {% ^5 A" v: e  ~7 S: v
, k2 K  E0 b- M0 K+ j
if (document.all||document.layers){
9 A9 J7 I  _! K1 P9 Ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
4 r& v3 D$ a3 ?! d& _# `+ Rwindow.onload = initializeBall;' M+ L- y' u( X6 F' J
window.onresize = new Function("window.location.reload()");
: Z& e4 S7 H2 f}
& @7 I/ R" M9 M4 `
& k' {. [. d$ e7 q</script>

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