返回列表 发帖

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

<style type="text/css">
, c* f# A( e9 v# h& R#supertext {! M6 |& ~; y( |$ T& L
position:absolute;! v8 T9 `2 e% T, t2 W
left:0;9 m' B$ r  i' C3 h" l' t
top:0;
7 s+ V+ G- m% R( X: Xvisibility:hide;; B2 }& s  L6 D; G7 H
visibility:hidden;
, _  R5 j" h* c3 Z* W}: n. G3 x; ]% i( ~, f* L
</style>
# G- A4 h1 e9 O; B: L8 {  q6 n<script language="JavaScript1.2">
, l; a3 r# ?$ b6 n0 P5 b<!-- 改变下的字体的大小。颜色-->) j, z1 T* Y0 i* t& i: B8 K: ]
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 z2 @1 _* @. Dvar hidetimer='';- H" U  [' w9 Y& t. V( Z! c
<!-- 改变下的弹跳速度-->
+ c# a9 ?* |; V- ovar BallSpeed = 20;' W( D3 K! _9 i5 H  Q
var contentWidth;
+ c) N7 {# E2 `$ pvar contentHeight;
2 v' |9 t( K1 c+ E9 Lvar maxBallSpeed = 50;, e' ^- w1 W0 E9 d3 ]- X
' }0 F) M2 c$ i, P& K! @0 o

5 `2 F! e, t; S* b1 V0 }- y. zvar xMax;: `5 ~. M0 g: w
var yMax;
# O: Y3 l1 f+ J$ }2 Y4 B0 [var xPos = 0;# u7 }/ |' ?) T' G
var yPos = 0;( w  Q% ]9 z  k/ C8 D- I
var xDir = 'right';
! R: B! J) v" O- L: t6 Svar yDir = 'down';
' _( Y! O5 m7 _4 W; v! Pvar superballRunning = true;
% ]: V) X0 ]8 W2 I3 K) evar tempBallSpeed;
$ Q. {- v0 `/ l! ~5 x. a; evar currentBallSrc;
% r& Z% v% m  f! Y0 X4 l0 u. Jvar newXDir;
( }: T& q  b6 y$ f5 Avar newYDir;
% L9 n  u' {( f: ]
5 f# f7 R5 L2 A3 j+ C. ]. k( Kfunction initializeBall() {
. r+ W$ E/ T% [# z   if (document.all) {
8 u9 h5 T9 J9 I. x' ^      xMax = document.body.clientWidth
" w2 G+ D# d+ S0 N      yMax = document.body.clientHeight1 ]2 [; _2 P! Q
      document.all("supertext").style.visibility = "visible";
0 @8 [" @0 V2 T3 W) Z5 `6 u      contentWidth=supertext.offsetWidth/ Z3 `7 t8 F3 ]% c
      contentHeight=supertext.offsetHeight
2 P: V. t! h" U9 V% l5 f+ H5 n      }/ A; G/ T: c% r/ B
   else if (document.layers) {' L: k4 C2 s6 e& P2 X
      xMax = window.innerWidth;% n/ A" U$ k2 K+ }- ]6 p2 p
      yMax = window.innerHeight;2 x( i/ N+ W% _: u1 v
      contentWidth=document.supertext.document.width  i' e9 u3 E% o# l( ~0 [4 m
      contentHeight=document.supertext.document.height6 z$ X7 W8 Q0 y
      document.layers["supertext"].visibility = "show";% j3 s, \2 m& {% V: R# I  ~
      }
! z6 H3 k  V& V) |/ U3 g   setTimeout('moveBall()',400);7 B+ ~* q& Q, r% s2 H+ i6 q
   if (hidetimer!='')# ?- X+ j9 R% u  i1 |  h! H0 b
   setTimeout("hidetext()",hidetimer)
: Y1 k, v1 R3 E( z1 H' I7 u   }% T: L; e. u- i: E2 y- ~

1 _' i' ^* Q+ ]- @* {function moveBall() {
1 w; |" U% G0 }" ^   if (superballRunning == true) {
4 U' q- @, q! [* @: i& N& n      calculatePosition();. J5 Z+ }0 l, q' ]8 a) }
      if (document.all) {* y' n! i/ n0 x+ Z  R) i
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
5 l1 v/ \' A! R4 V0 B$ a         document.all("supertext").style.top = yPos + document.body.scrollTop;6 k7 E" \- |( A' `; ^/ I
         }& B4 v" V! o% ^! ?, o2 N6 \. t6 \
      else if (document.layers) {
% f( R/ }/ @/ ~( }7 \. q         document.layers["supertext"].left = xPos + pageXOffset;
. Y0 r* e; t/ e7 ^9 s         document.layers["supertext"].top = yPos + pageYOffset;( ^0 M* ~: k$ D7 q
         }
# Z( T8 {4 Z5 a+ r) @! L      animatetext=setTimeout('moveBall()',20);0 B; q* _0 h+ H! `! W
      }) m9 e, n, W/ R" y$ V& v* X4 ]
   }( p; D% r0 a, j! i$ \. D
& ~9 A1 x& Q& I9 o  Q
function calculatePosition() {
* s! z3 S6 |7 Y9 e$ X: w2 W   if (xDir == "right") {
0 J! m! Q" M& S7 _* }6 t  O7 }7 Q      if (xPos > (xMax - contentWidth - BallSpeed)) {
* x) f$ A0 c# E- f1 F/ U         xDir = "left";0 k- ^5 J+ R+ d4 V3 T0 C
         }3 @2 x. t) Z4 R4 G5 `8 O. E' k
      }& I8 |  Q0 h; r
   else if (xDir == "left") {
! F8 `  L* q2 z5 p0 g: Z      if (xPos < (0 + BallSpeed)) {" P+ Z2 p: L( O; P  l* ]0 w) P) \! K
         xDir = "right";3 C& C/ \0 i: g* o
         }$ v  u0 S- _  U/ a& L# b0 y
      }
6 v7 a3 X: d/ z" j   if (yDir == "down") {, N% f# q3 o" U  O. D7 a
      if (yPos > (yMax - contentHeight - BallSpeed)) {& }3 O( ^" f& }: K% u8 ], q; \
         yDir = "up";
' o; ^* ^! R1 K/ N) p         }  z6 p5 X' o8 J* u- w
      }# G; A9 r* r3 o) o2 z* T; G
   else if (yDir == "up") {; t( F/ S0 G5 [+ |
      if (yPos < (0 + BallSpeed)) {
) s2 o* X+ L7 N1 \, m7 J3 _( |         yDir = "down";
3 H; F& P9 o: a3 z& B2 @         }
& `& j( j" s4 Z1 a5 Q7 S      }& P2 `# K3 D" f0 F
   if (xDir == "right") {
- h0 j9 k8 Y9 f, @2 W2 X8 C. L4 t) H% v      xPos = xPos + BallSpeed;7 ?2 z/ B7 }1 E( T- ^
      }) T3 Q8 U2 A' Q& e. [
   else if (xDir == "left") {6 l- Q4 V) c6 ?% q- L
      xPos = xPos - BallSpeed;" B2 M0 r/ p2 o( k# Q/ j( ]5 ?
      }% C7 [4 _" O/ i+ [
   else {
% ~# q4 A7 T) I7 j: l, N6 M      xPos = xPos;8 J, d$ W$ z$ n+ o  f
      }
% Q) f. |9 Z8 f! W   if (yDir == "down") {( a9 Y. `$ h' M( |
      yPos = yPos + BallSpeed;
0 ~& Q! q/ ~2 \  L  U$ u8 x; N      }9 X* G0 `6 l4 o3 W& V+ W+ Q
   else if (yDir == "up") {  M3 @/ @! I9 T8 g' S+ y
      yPos = yPos - BallSpeed;8 z6 M  j3 r" O7 p
      }
! k1 ?5 ~/ d0 I4 V. C! I   else {
& S" w9 D( Z* i6 j* C  S/ O# Y      yPos = yPos;
" k* D8 j; |& C" a. a      }/ O1 O2 W6 T+ A1 a
   }
  X, s8 E+ }" y. f9 `  t+ S0 K5 c) i' W' \' _2 k! l; Y
function hidetext(){
, r2 K" H2 y! Y: F' d( G4 ^if (document.all)
9 F* c2 y5 i/ J' b; N: M7 ssupertext.style.visibility="hidden"
$ l  X; v: O2 }: Welse if (document.layers)1 {6 K& w0 b# k. c6 p, \
document.supertext.visibility="hide"
* Q1 h$ J& ]" t- UclearTimeout(animatetext)
9 H* i; b" F  f}9 Z6 g" |! t. i0 ?: ~

8 O6 V7 U6 g4 ^, [# M0 I/ cif (document.all||document.layers){0 x5 O; M! _/ Z6 \$ C) V2 G6 f/ O
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 I, Q! T$ h% [1 q  E$ Awindow.onload = initializeBall;4 y4 I* C8 x; x% P9 Y2 ^" B
window.onresize = new Function("window.location.reload()");
7 R! n, C' f4 J8 x}! A& H+ Q; |" W
; I" c0 E" q- m2 |" J
</script>

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