返回列表 发帖

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

<style type="text/css">( {' F0 W" A, B
#supertext {6 ^% m# s, Q  t/ G6 ~5 L- m# Z
position:absolute;
" l; V0 D; R- z: w3 Y& n- Jleft:0;
/ h; s/ O. m! r% ~7 m* O0 a4 ktop:0;  h2 b. ^: f) c$ y
visibility:hide;
! M- r, q( D" W2 M" cvisibility:hidden;& F* I/ [! O+ r/ M  O
}- x" `- N7 x: F, J/ Y
</style>; `" S" |5 S( [1 Z' p/ J2 I  \
<script language="JavaScript1.2">
/ |& i- ^; j: ^<!-- 改变下的字体的大小。颜色-->
6 r& k. w8 r0 a5 Y. Qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ I' G. d/ S  Z
var hidetimer='';6 h9 l# J7 l$ ]8 h
<!-- 改变下的弹跳速度-->
3 c% A  v7 N' Yvar BallSpeed = 20;
. Y# {* w( T* Z& O$ k& kvar contentWidth;
6 f& j. t5 Y( k5 Q4 z( h' bvar contentHeight;+ M: U' Z  P2 ^0 i
var maxBallSpeed = 50;
9 _5 `4 z' v8 j( O8 `9 l# C. B% D+ P0 O1 O& ^6 Y+ w0 A, h

% {% H5 W/ C1 O+ S% l1 A8 ^& Ovar xMax;( W4 s, C) X, W+ X3 X$ j# A
var yMax;1 a1 E3 u7 X$ C2 K8 p; N4 l
var xPos = 0;5 W, L. p( _5 h
var yPos = 0;/ j! z+ _* ~4 K4 {/ o
var xDir = 'right';# O2 A; F9 _: A- B7 Z7 ~
var yDir = 'down';
9 Z* ]# U+ e1 o  ^var superballRunning = true;  v* P" ?$ M+ z0 W9 z
var tempBallSpeed;
5 C( h2 g7 N( A2 C. t) fvar currentBallSrc;
" B+ y+ q5 s0 c! J; n2 e0 j/ Gvar newXDir;
; M: s4 ]9 g; O& O& C% ~$ Rvar newYDir;
+ a8 h" B3 Q: c# Y1 P
2 ]; R; l$ U2 [1 I' qfunction initializeBall() {
* {1 r* P. V' w7 z0 I  r( h# F   if (document.all) {' W( f( d$ J& G) U0 V
      xMax = document.body.clientWidth9 n. w/ K3 x  \& D  e
      yMax = document.body.clientHeight
2 q# N$ @( [  |1 j      document.all("supertext").style.visibility = "visible";  Q) D& z; E. b. i9 _
      contentWidth=supertext.offsetWidth/ X. |. O  B8 I; o; r
      contentHeight=supertext.offsetHeight+ Y0 y+ I7 T+ A
      }+ {7 T  L6 B* t' X( h4 K' q
   else if (document.layers) {
: t5 G1 l/ g6 `# W      xMax = window.innerWidth;
' ]% O% U4 I1 l# |* Y  Q2 G' D+ |, [6 O      yMax = window.innerHeight;
! Z  R% r2 ]6 o/ J; L/ r      contentWidth=document.supertext.document.width
4 ~3 ]1 U0 u; S0 z6 N      contentHeight=document.supertext.document.height6 e( [+ B0 ?$ X! b) p" }1 W3 z
      document.layers["supertext"].visibility = "show";7 c2 I/ c% h" h3 K7 g. Z* [+ i/ i
      }) i/ M- |* {/ R; r; D0 V+ ~+ h' b
   setTimeout('moveBall()',400);
* m- T+ ^' R* j- B$ A/ B8 L9 k   if (hidetimer!='')
6 [0 `# C9 `6 Y0 J+ c! j0 @   setTimeout("hidetext()",hidetimer)5 V1 p' @5 y! q/ Y1 v& g9 `3 t, [
   }
: A* H8 n% R7 M) N; S3 |$ T* r& h/ s& P: \, _
function moveBall() {
; N* E0 q2 K; \% t4 O   if (superballRunning == true) {# Q: P8 e/ {8 v# ?) G
      calculatePosition();4 T- x' Y8 u/ o1 n4 Z
      if (document.all) {
; d, F; _2 }2 L3 M& f2 p6 v         document.all("supertext").style.left = xPos + document.body.scrollLeft;
+ V5 u( [& x: [, s         document.all("supertext").style.top = yPos + document.body.scrollTop;
0 o# z4 h/ y9 @! [         }. o( ?5 y/ c0 z) N; X$ D1 |
      else if (document.layers) {$ f' U% L7 g9 N) a3 B: B
         document.layers["supertext"].left = xPos + pageXOffset;# a/ f. U8 {) w
         document.layers["supertext"].top = yPos + pageYOffset;
7 T7 }! U1 r1 M, y0 m+ J7 U         }
  O% H/ |0 V5 G( p) w      animatetext=setTimeout('moveBall()',20);5 n% E* X4 X8 q; _6 B5 o
      }" p0 _) Q9 U$ p+ x9 F4 R. ~8 g2 d
   }+ m7 d/ j# [9 t) X; l7 [* R: Q2 M! }

3 b  S; }  ?' Y  _1 O1 p5 U5 `function calculatePosition() {
6 d& z7 M. e# Z: }7 X; O3 R& b   if (xDir == "right") {
  }2 _! {% z1 I# a. q      if (xPos > (xMax - contentWidth - BallSpeed)) {
8 `' E, r$ B" \$ Y6 s         xDir = "left";
/ C+ d! C- l4 @% x) D5 E  ?         }, i" N4 x7 C- d
      }
9 h4 l8 }' W  |   else if (xDir == "left") {* l3 t; z6 z6 Z! z+ b! z) d
      if (xPos < (0 + BallSpeed)) {
& a1 o% R. s  @  a1 O         xDir = "right";8 [; @2 C/ R; l+ p) l
         }$ W, A" ^1 W" w, f$ L
      }: n8 ^- s% W2 x/ D
   if (yDir == "down") {
7 m/ }! l$ {6 Q# }5 R7 x. \      if (yPos > (yMax - contentHeight - BallSpeed)) {" B6 h5 m* H- |9 |
         yDir = "up";
  d" L6 P) Y7 |( @# I1 l( b         }: b4 n' e- B8 H" O% F0 Q9 f, F2 N
      }4 |1 J9 M1 a/ y5 L
   else if (yDir == "up") {
6 d0 {) f; I, I      if (yPos < (0 + BallSpeed)) {2 A7 H( [1 E: [3 u( \5 d, A
         yDir = "down";
! X! b* l# H$ j6 G6 I- m: q1 z3 y         }
( C" ?7 |$ y+ q( i; i$ @- P      }
$ v) v( [% d4 b  h   if (xDir == "right") {' d( y& e3 t/ u' b- U' k3 w6 q
      xPos = xPos + BallSpeed;" m9 b  \/ u0 A: V
      }
) Y# Z5 X. L' h' C/ H% \" P3 m   else if (xDir == "left") {: `( W1 H2 _; T; r0 |* a
      xPos = xPos - BallSpeed;
$ c1 J( a4 ~  q      }
) L' W! s! t) S) V9 o   else {
* M8 D) k7 y1 {; {4 n) J* e; J      xPos = xPos;9 s7 m4 l! X) h
      }  A9 k5 U/ ^' r) k
   if (yDir == "down") {
2 b& x" m5 \8 R+ O8 N  D      yPos = yPos + BallSpeed;+ q) x+ z: u) ~# a( B2 K+ u2 b
      }
+ u$ N. r' H/ s. B; N7 I   else if (yDir == "up") {
, B" C/ h9 R' `& o6 U$ N. r      yPos = yPos - BallSpeed;3 G& Y9 f9 l1 @6 t
      }
  i  u1 b5 I9 M$ s7 G   else {8 x) o/ @9 M3 I3 ]! z1 m+ g5 x# A
      yPos = yPos;1 \+ q  M! W$ B4 X7 f. J
      }8 F$ V4 i+ Z/ ]& U, H1 L( w+ Q
   }
! T, y  b) e0 s' U
# e" j% e) H/ j% z7 T8 O: g& P2 Ufunction hidetext(){' J2 ~+ r7 Z+ n
if (document.all)
, e0 K  W8 c; L# W: N$ T+ ^supertext.style.visibility="hidden"
: S0 u- j0 X! c) }4 }/ d- melse if (document.layers)8 N/ H) I6 J! H/ ?* O
document.supertext.visibility="hide"
. i! u5 {0 ^$ l5 TclearTimeout(animatetext)
) H1 \3 e- i4 s  j}, F7 x9 M8 G( b9 Q
/ V: p% f! w1 Q
if (document.all||document.layers){
  g: C$ ~; x3 _7 R' k# _( k* {) Rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')$ p6 ?% t8 F! |( s% ]
window.onload = initializeBall;
6 {7 W% P4 @, ]0 d1 K/ @7 cwindow.onresize = new Function("window.location.reload()");
) S8 \6 K$ i0 _+ \% H7 m}5 C( B& `8 d, C( S9 A. t: r, h* D
$ ~# j" U; s4 f# Y" D% D6 V. d
</script>

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