返回列表 发帖

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

<style type="text/css">
3 @& G2 r8 U! P0 W! J) z#supertext {, F3 p  n0 m1 E. {7 x5 @" [
position:absolute;9 C: P( k) w, `- b7 j9 l5 A4 m1 ^) T3 p
left:0;4 C$ `7 ~  e% T1 Q; c* }% W
top:0;6 i% J7 ^; P( h" p' l
visibility:hide;
, Z0 g2 z# [* |, Kvisibility:hidden;0 D2 D! S2 t1 H* }. _& U
}2 N! b% h  a, K6 c% q. _  Z
</style>
/ |; l! K  z; o  Y3 A2 @<script language="JavaScript1.2">% R) Y: R" D8 @8 Y0 g' D. m! v
<!-- 改变下的字体的大小。颜色-->$ ]& p( V7 D" R# n
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 c; d( N' e2 k
var hidetimer='';& b6 u& L1 e: k* |9 M& ~- g# H
<!-- 改变下的弹跳速度-->
4 g, f# F# b; c9 r& s( wvar BallSpeed = 20;
0 V) ^, g3 ^# A4 Xvar contentWidth;2 n1 W9 e8 L3 n, r+ C% x
var contentHeight;
9 F( C2 A6 L/ J; I/ B: r& L1 ?9 m/ qvar maxBallSpeed = 50;9 ?: r1 P& B" w7 M! F( |+ w( D

% U$ _, h: \0 h. ~* S$ K5 b9 r( L9 f. ?5 W5 x. Z7 Q
var xMax;* E# T8 _' u& J3 N
var yMax;
3 X) ?* U/ _% D, T2 Lvar xPos = 0;
0 _8 T8 |6 a- |7 dvar yPos = 0;
0 k! `$ m3 g5 k  Zvar xDir = 'right';
# C8 |4 o0 I! Gvar yDir = 'down';4 A$ j! S! g* B2 ]( s2 h) K
var superballRunning = true;* _) A' D+ l6 a
var tempBallSpeed;6 }/ G( m" {! P$ S% Q8 P" j; c
var currentBallSrc;& R8 g8 l' @) h: j/ o4 s
var newXDir;1 N/ z0 J, U5 U
var newYDir;
! i: W: [" H, h0 Q3 [3 A( ]7 n, g4 z/ ^. w. q
function initializeBall() {
4 d- Y. _0 b! h  F   if (document.all) {
6 Q5 ~9 x4 Z$ G6 q- H; c5 z      xMax = document.body.clientWidth5 P& W6 Y( f# J: W
      yMax = document.body.clientHeight. ^0 W  _% }, S1 M
      document.all("supertext").style.visibility = "visible";& \: q0 }. A" m7 v: J, {3 ]( t# ?
      contentWidth=supertext.offsetWidth. u& D3 a% K" s. ]3 V
      contentHeight=supertext.offsetHeight
5 |% r/ I9 B, G$ x      }
; g% c3 h/ H+ j5 d2 H   else if (document.layers) {
5 B, _/ }* A' C2 {! T7 ?- g" k      xMax = window.innerWidth;( A( M  j5 b% S' }, F
      yMax = window.innerHeight;
+ s- ^1 O: K# q- Q' d% ^" w      contentWidth=document.supertext.document.width/ K  W. q0 u0 d; ~& B& r
      contentHeight=document.supertext.document.height
# C$ F& O' a2 ~/ }" Q! R      document.layers["supertext"].visibility = "show";
2 V& u4 {! N$ w  }/ F      }- B6 J) S! J, h2 n8 N
   setTimeout('moveBall()',400);5 ^8 d5 L6 S- X
   if (hidetimer!='')& g$ F# @: r! G
   setTimeout("hidetext()",hidetimer)
6 P, a4 w( ^* E, A% N6 v   }
4 p$ b7 h, F% n  o: W) S6 k: j9 m6 [# z9 s- E- d) l
function moveBall() {& P0 ]# T! E! ^4 O" X- {! ~
   if (superballRunning == true) {
" S7 v4 k- e, U2 q6 b      calculatePosition();
3 O6 ]5 ^6 P! J6 R7 R. {      if (document.all) {$ M+ `' b. V! b2 o! I  X, S
         document.all("supertext").style.left = xPos + document.body.scrollLeft;" I$ o! e3 {6 p- N& k
         document.all("supertext").style.top = yPos + document.body.scrollTop;
9 P$ F: x9 y5 ]0 [         }" r' v9 U; _, P( l7 ?. K
      else if (document.layers) {
. k. F* r& y: V7 {& s         document.layers["supertext"].left = xPos + pageXOffset;
' H" z. Y: S3 J         document.layers["supertext"].top = yPos + pageYOffset;  A) c* ?" R% a" E
         }+ ?5 c7 q: y( s1 z
      animatetext=setTimeout('moveBall()',20);
1 L; y' s$ r& }4 W' r: Y  s& C1 X      }) f$ G4 Q' V3 \9 c5 o, q
   }4 A" ~% _9 Z* R
0 V, \9 D) E8 q+ {
function calculatePosition() {+ y4 S  n6 W5 f) j( ~
   if (xDir == "right") {9 W: ^8 H& ~/ q2 l$ i
      if (xPos > (xMax - contentWidth - BallSpeed)) {" _# e: a& b& R+ }" E
         xDir = "left";
) }2 _: p1 Z% F  A' v1 a         }
) n3 f6 `! P5 v$ l  E" S. ^2 C' _      }
- I, R1 V: ^' S3 z   else if (xDir == "left") {
5 U. g5 z5 W2 I2 P$ N* y* ?0 V      if (xPos < (0 + BallSpeed)) {
$ Y2 o3 e3 ]  g6 Z$ h+ I         xDir = "right";/ b' D9 p- ^& L  _2 {& U
         }
' S; {( J  t$ `' h      }
/ D7 l2 X2 p" s! V# k; T   if (yDir == "down") {
$ \6 L: P' }2 q  L, w      if (yPos > (yMax - contentHeight - BallSpeed)) {
7 j  B, s' E, n1 c1 [# p7 h         yDir = "up";, V$ [4 W  O6 ?  w( L
         }
& r" J/ `9 E4 s+ V8 `$ f$ a  k3 ^      }
, ~9 U. k8 P' w   else if (yDir == "up") {+ M7 E* `  V2 F5 p$ b
      if (yPos < (0 + BallSpeed)) {6 R$ Z. g" ]1 r" O# M
         yDir = "down";5 x% D, E* c( i
         }" s" N% Z8 @$ b+ k* c& L
      }1 E8 @' K( a6 P$ Z" |3 a. S# U
   if (xDir == "right") {
! d7 j# j5 E- o9 s5 j      xPos = xPos + BallSpeed;+ i4 F! ], }' J( c5 s) Z  D1 x5 T
      }
  D! ]" l1 w3 B2 r; e! y: H* r   else if (xDir == "left") {
: Q% v8 }/ y: u7 m3 f3 k0 o5 V) U      xPos = xPos - BallSpeed;: f' D# e+ w% \% x- l6 J+ y* O
      }' L9 W0 {- T# Y: h$ ^. v/ Z/ x
   else {
) m" I0 D9 o8 ?" L      xPos = xPos;
0 d/ I) p- J1 w, [  U7 Q      }! b6 E, f3 O: y7 i' q5 b' j
   if (yDir == "down") {/ w9 z6 [. u& N
      yPos = yPos + BallSpeed;7 E  K4 l9 }* r/ s; A$ X( {
      }! @/ s4 C4 G9 B" o  X5 s& d3 H
   else if (yDir == "up") {- N+ F+ K. S7 |5 }
      yPos = yPos - BallSpeed;0 N3 F4 S4 ?5 @' K
      }& P8 i8 U( D0 }- W& q
   else {
" s! ]( o1 K' X  s7 y      yPos = yPos;6 h! f& w  V! X, a9 N* ~3 w
      }6 d6 i0 R* R5 h. j* G3 a/ L5 M+ L
   }
* x' k2 I/ z) C5 Z) I/ `6 H
7 B+ m3 i, f: k1 X1 m2 Z, nfunction hidetext(){' b) v" W, U2 z# M; Z
if (document.all)
, h, w8 O  K1 y! i( P# D( ]supertext.style.visibility="hidden"2 F  j) o* T+ Q- N. m) |% x8 E( M2 }
else if (document.layers)
1 _0 ^' S. g7 ]8 h: W; odocument.supertext.visibility="hide"
5 d* Y& N* `' JclearTimeout(animatetext), K; h+ t: S* P9 t+ ~6 ^% O
}
4 I  N9 S4 `- k2 l2 c6 ~- r. t$ w1 y6 p
if (document.all||document.layers){3 y  {4 l8 L  \, e$ }$ B# I
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 t5 b  E- ^& z, o- ywindow.onload = initializeBall;4 \5 e3 w3 L4 I4 }) N
window.onresize = new Function("window.location.reload()");
9 l8 Q& I- \# F, c6 f" d# b0 S}) p' y2 Z+ Q' ]& C/ M& t

8 q( g% O  f  ]' Z- W</script>

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