返回列表 发帖

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

<style type="text/css">
/ y1 }, H) D" _5 \# s#supertext {/ l8 N3 Q/ L/ H, o6 ?+ p
position:absolute;
1 A! v' w+ V4 h: G# p. q8 {left:0;1 X$ W1 @; Q$ S. @2 k& w
top:0;9 h8 K4 W4 I" i9 N2 W
visibility:hide;
& ]$ N# w0 M0 E+ Rvisibility:hidden;
5 Q% U# q, N% Y2 F4 w}
9 b1 l- J& a! N' }* o9 T* M$ M; A</style>
) _2 A: q7 K5 Y* p+ f3 H/ j<script language="JavaScript1.2">
1 ^5 k' J- A/ m: h% N<!-- 改变下的字体的大小。颜色-->; W5 M" @, k/ _+ R$ S
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% [: p$ b5 S" k) O: ~- T, v# ]var hidetimer='';& n8 {3 B4 w4 V9 a; o0 }
<!-- 改变下的弹跳速度-->& C' ?6 X+ o: y& l4 a+ b  w2 X0 j
var BallSpeed = 20;
$ B4 K: @# g" Dvar contentWidth;5 C. x% D7 I' m( {
var contentHeight;3 F4 b8 C6 c' C! v* P; ^/ I3 Q+ E
var maxBallSpeed = 50;3 J/ f5 ?; m9 D/ u* P
& }3 B  L) d( Q( S
& q8 w5 P2 O7 S
var xMax;2 l+ u- y8 ~! O8 L6 @! H! a" l9 T+ [
var yMax;9 Q& _& |. b. Q/ v
var xPos = 0;
# z! g% p( R% n# Z( D- yvar yPos = 0;
! S& h2 h+ E% Y1 xvar xDir = 'right';8 ~2 C( s- |0 g! Z! ~" M4 F
var yDir = 'down';. j: E  F& x" {
var superballRunning = true;
; X8 I. {- e8 Bvar tempBallSpeed;
. a# w9 V: i5 S, [var currentBallSrc;
/ j8 k- W' j% \( Y. L! Lvar newXDir;2 l8 v, G7 q9 ^) Z
var newYDir;- J! s/ o' R  S$ \4 o' q$ |

9 M/ B9 f& X- U- e/ Sfunction initializeBall() {
+ v+ J. p) P) W7 Z" J3 O   if (document.all) {; e8 g! x" ]  D! A" d0 a3 a# `
      xMax = document.body.clientWidth
3 H4 a+ E' k8 N. n! l) A      yMax = document.body.clientHeight
& l. {1 {# }- u2 A      document.all("supertext").style.visibility = "visible";. G' t: l1 u1 e, J- f9 y
      contentWidth=supertext.offsetWidth
# J- ?. K( _' E9 W* k# r      contentHeight=supertext.offsetHeight
; N" ]0 X) g7 y$ p3 ?4 W  K6 _5 [  ~      }& K" k4 v6 t3 U5 r
   else if (document.layers) {8 \5 n" V0 j& u7 }# `/ N
      xMax = window.innerWidth;8 O2 ~  q2 g' o4 N1 K6 w! ~
      yMax = window.innerHeight;
% Z7 z7 K$ B9 W% p! J6 T% O; d      contentWidth=document.supertext.document.width
, ?; d5 Y  o  g* h9 `( z2 Y      contentHeight=document.supertext.document.height0 M$ M+ e, k: W% J5 w
      document.layers["supertext"].visibility = "show";" G/ ^7 T6 Y+ v# x( s, u, x6 v
      }
6 x3 ^% J' X  l   setTimeout('moveBall()',400);' r0 W, [8 G9 K$ k. {
   if (hidetimer!='')
3 u) s# U4 M6 A( D. b) m/ N   setTimeout("hidetext()",hidetimer)4 C: H4 B6 ~& z2 y
   }; Z* c; I! G) \% f8 e7 h+ Q4 {2 c

# p0 b" P( y( ~$ vfunction moveBall() {4 Y" {: I) [6 K0 u
   if (superballRunning == true) {! I0 @9 M! m9 j" v3 d0 w. Q+ C' O
      calculatePosition();! c. p+ l- _: g2 B6 f5 y
      if (document.all) {
4 M6 o2 C: W2 C" A5 f: g         document.all("supertext").style.left = xPos + document.body.scrollLeft;. G/ J9 o2 q" e, `
         document.all("supertext").style.top = yPos + document.body.scrollTop;( l! t; N2 ]. J: z+ s' F# g2 }
         }$ f0 I/ ]0 K* p! ?; P1 G
      else if (document.layers) {* k! S! ?. `/ i0 I
         document.layers["supertext"].left = xPos + pageXOffset;8 ~8 ?7 A) J5 H$ w
         document.layers["supertext"].top = yPos + pageYOffset;9 L' E0 S9 b9 ]4 ^+ H
         }
- Y" Q6 I5 f# U/ P      animatetext=setTimeout('moveBall()',20);
! }  \7 Z: U7 ?! b% b. l+ B6 Z' n      }, A3 p9 Q  J& E+ z
   }# D' r: @. B( D  {0 z& u- {! S

" Z* u/ a% I- e/ |+ b* T; }1 bfunction calculatePosition() {" L+ N4 f" T! T, O1 ^
   if (xDir == "right") {1 g/ ~- d# u: z" g3 z! g5 y
      if (xPos > (xMax - contentWidth - BallSpeed)) {
; O! v- E' N5 h# b- R( }9 |         xDir = "left";5 U) I, c5 u5 n# ^2 C& C6 l* h
         }+ x( j( U1 m1 p3 e0 f
      }
% {5 r# A6 ^8 d9 x6 E' P; `% U: z   else if (xDir == "left") {
! c# r. W+ y$ @7 n      if (xPos < (0 + BallSpeed)) {
- v- P( r+ g4 W4 Q, I2 b5 @         xDir = "right";" x6 z8 V$ y8 K& u7 y: u
         }+ x1 b( u3 X2 l! N+ N
      }, B, ~! b) e7 i: i' b
   if (yDir == "down") {
& z. i% R$ C+ S      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ |/ M, K/ j+ y         yDir = "up";$ i4 X4 D3 u' c* M
         }
9 y' t7 j% a$ ]. {2 V      }
" r% X  E; V  j$ h2 ~3 a   else if (yDir == "up") {
- |% _- l5 ]7 E$ {6 o: _, A0 D      if (yPos < (0 + BallSpeed)) {
  Y$ D' r  n) i+ e         yDir = "down";- W$ W4 d. q4 ~5 ~/ |& m9 C
         }
' l+ ^* s7 |" O      }/ a% {1 t) k) f3 A7 W9 a
   if (xDir == "right") {
+ q: v; a. j* s+ r+ \2 q      xPos = xPos + BallSpeed;8 @+ j' F  e0 ~% B: o/ F  l3 ^4 c
      }
+ V% T% D7 m0 K   else if (xDir == "left") {7 U( ~8 o! C7 m  w& j
      xPos = xPos - BallSpeed;7 H2 l, ]: m" O4 F- R
      }
4 I4 T5 Y5 u; _5 \( q0 A   else {
/ L7 f& h, m% `4 o      xPos = xPos;
3 g4 v* \# [% _3 N6 I      }/ t- E% w* E8 ]; i7 e
   if (yDir == "down") {
7 w' w) B& I5 S; v0 G! F" o      yPos = yPos + BallSpeed;0 s- c! e3 ]. G2 }4 ?6 R
      }) N. e4 N" Z! s
   else if (yDir == "up") {% r- s5 G9 H; |% U+ J! R
      yPos = yPos - BallSpeed;3 v7 W7 `5 p" P- T) C, ~' m
      }3 D" S% z! j" E' ~. `5 i5 E6 [
   else {
6 [9 U3 k7 s& f4 a# \( q% `8 q5 T      yPos = yPos;
& T, m! u& R& C6 m# \      }, X; a8 k# u) o! x! [7 _8 G7 ?" H+ a4 Q
   }
8 I8 L. }7 Z  T- q3 k7 \# J. B+ U2 n
function hidetext(){
  V% ~# ~# i* P6 Eif (document.all)
% [" y( ?9 k- f% xsupertext.style.visibility="hidden"3 ^& d5 N& U) t% d7 r  H; O
else if (document.layers)# ?, K/ {, s* S% C) L
document.supertext.visibility="hide"4 m1 ^: a! Q9 K! |
clearTimeout(animatetext)" h! A% ~/ _2 D8 p; k
}
1 g. S/ j5 M5 U* `* ^
  m. L9 H  P3 A% e# l, uif (document.all||document.layers){
0 C1 t% ^+ T) {% M& P) F3 s# Udocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! Y. a. p! C/ D! V" I: V/ \window.onload = initializeBall;3 n% v$ p3 y1 ]& U9 ]& q! Y
window.onresize = new Function("window.location.reload()");
3 A1 O, x) Z. S' M+ }}
6 e- e: }, r; `3 x% \! r6 c: I/ b8 ^$ Y6 c* J
</script>

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