返回列表 发帖

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

<style type="text/css">1 U& N. J+ G/ i/ u/ v6 A
#supertext {; V1 z/ R# f0 h$ Y
position:absolute;2 C+ ?4 M, Y! a* {7 N0 H
left:0;) z1 W5 S1 c: u
top:0;
2 P  n4 ~6 a* S% A$ pvisibility:hide;
2 _; S9 |7 T1 W6 vvisibility:hidden;( Z* r8 c, ^2 }
}
/ ]' u/ u. _4 Y. |- l; @, E' h</style>0 l, d3 [0 W5 e# ~! a$ O) a2 K
<script language="JavaScript1.2">
+ K+ s5 e  ]' @, {8 N<!-- 改变下的字体的大小。颜色-->& M+ ?6 n- F9 o  O8 L
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': |) P3 E, a, x  `3 ~
var hidetimer='';
& P. b% b( n" b( z<!-- 改变下的弹跳速度-->3 K' T, ~2 Y  `
var BallSpeed = 20;
! Y, R  C4 C' }% jvar contentWidth;
3 j0 h% o* \: X4 T- r- Wvar contentHeight;
: I5 Z8 |1 G$ l7 u9 ~var maxBallSpeed = 50;
0 x1 ]6 w/ x3 ]3 j1 S) n9 J" ]/ h# B/ c1 |" [6 ~
- g- m  `$ }; u# D; V: x7 \5 x
var xMax;
4 L7 T; h6 z3 V( [var yMax;4 T2 f6 a( f7 f- H( p/ y  \
var xPos = 0;
2 H6 V8 i& H% r$ g- p  G/ b  w2 w9 Gvar yPos = 0;9 j* W) f" c2 \( V/ K5 E
var xDir = 'right';
: R, R5 f0 z( u! jvar yDir = 'down';
( g/ c1 t0 R0 W$ T9 U8 Xvar superballRunning = true;) b; f. s. P" c& L2 h. }8 Y7 G" \
var tempBallSpeed;
& \7 L- d2 F; n! n0 qvar currentBallSrc;' H9 u& E7 C+ Y# F+ j" G
var newXDir;
+ @7 y1 ~3 h" d1 ~6 G5 Rvar newYDir;
6 {& p! d' e3 U+ p
7 r# A, F+ c. W8 K. Gfunction initializeBall() {' o  g5 Y' J% n' x1 L" P9 u% q
   if (document.all) {
1 e2 m: j1 \* A; T      xMax = document.body.clientWidth% y0 ]+ U8 U7 B, a' [) c6 e' ^
      yMax = document.body.clientHeight. H! C$ c* |/ w- b
      document.all("supertext").style.visibility = "visible";. w* F' J" Q+ ~8 e( `
      contentWidth=supertext.offsetWidth8 w* V* {: N& O, f! z4 Y# p
      contentHeight=supertext.offsetHeight
# P7 u4 X1 [! K- g      }! {: h6 l% h, q2 S
   else if (document.layers) {8 M0 P" w( {# Z; c( w
      xMax = window.innerWidth;, i! g' y; N; x  L  Y1 I, s. z
      yMax = window.innerHeight;$ `! h$ A! A0 l3 @  I( Z' V1 d" j
      contentWidth=document.supertext.document.width
9 B1 x; x3 n3 z8 k, n, N2 z      contentHeight=document.supertext.document.height' w6 D. q2 [6 R  p/ F* n; K8 L
      document.layers["supertext"].visibility = "show";# s- U4 {: ~4 J
      }- Y. {) l: U/ I8 }
   setTimeout('moveBall()',400);; G5 j% v+ m0 |7 O0 }! M
   if (hidetimer!=''), e: ~5 l3 a# l- [
   setTimeout("hidetext()",hidetimer)
$ F# f, V5 F) ^   }
( E7 r1 s  u. P) m1 @& `" Z3 r! E# I
' H9 G0 |+ ?  G+ Q- f7 b6 ^" Jfunction moveBall() {! f! ~8 d3 v# i! k! v! V- p
   if (superballRunning == true) {. c2 x1 N( v1 J* q, }
      calculatePosition();0 A8 n. b" D3 }  z
      if (document.all) {) e' D$ T9 ~+ r, `" n8 l' g  `
         document.all("supertext").style.left = xPos + document.body.scrollLeft;9 y/ V0 \4 S  P
         document.all("supertext").style.top = yPos + document.body.scrollTop;& b6 i9 Q8 a$ Q! D+ G2 @5 {" T# w
         }/ Q' \! V% @* N, u: K# w# o4 M% c) c
      else if (document.layers) {" w4 p: e- y- X0 H" l! t# ?7 R
         document.layers["supertext"].left = xPos + pageXOffset;
. s  h# S5 l) K: o4 ?  K         document.layers["supertext"].top = yPos + pageYOffset;/ n8 n" n" q3 A) d& z' J
         }
: T2 C. }& D; u) s# Z* ?" ]- `      animatetext=setTimeout('moveBall()',20);. P+ h) n2 F8 R7 q7 P5 k8 @
      }
% h% i1 \& G9 r- s) C! g   }$ J. T3 E2 b& j0 Q% E$ I
0 J: `2 `0 J8 d
function calculatePosition() {/ N  G; d, G# v' k; L* K
   if (xDir == "right") {
, V& x: @% g, T/ [& y7 d4 ^      if (xPos > (xMax - contentWidth - BallSpeed)) {
( b! ]  m! w# E& D" j         xDir = "left";/ ]1 x. g0 p! {+ s8 {: j) @
         }; l9 M+ H8 p& X( l" J
      }
5 K% @  a+ E: E. v4 @, N   else if (xDir == "left") {; f6 E/ u  I2 P0 |: I
      if (xPos < (0 + BallSpeed)) {
3 a8 M  c! d# F         xDir = "right";
# x# w" Y/ i2 H9 x0 k+ {         }
7 Z0 |0 A3 O8 O) `3 v- s( n      }
" ]8 L* W- j, J   if (yDir == "down") {
" }$ F( _5 r$ `3 j/ B7 N      if (yPos > (yMax - contentHeight - BallSpeed)) {
3 c: B4 M& N% d; k) \: Y) a         yDir = "up";3 q! c3 M+ r- i' O2 A+ X
         }0 n* B" {, b/ A" ]5 [  R. p; {' Q5 X: e
      }
' P/ Y# |7 _8 `7 ?& i; g6 u+ I   else if (yDir == "up") {! ~/ N' c3 x, V7 b
      if (yPos < (0 + BallSpeed)) {
$ l- ~. [9 O- a- ]' |5 X         yDir = "down";
# z% ]8 e' b* g& }         }
5 }- {; c, ^/ n* @      }7 t! ~7 Y; X$ k7 F: c+ j; f
   if (xDir == "right") {
8 w4 C5 y# a5 }: d' m. H      xPos = xPos + BallSpeed;/ l! x, l5 ?/ w' L( J4 I! d
      }6 D4 g& d& I2 v! _3 c) _
   else if (xDir == "left") {- W  S6 s" }) q6 G: \
      xPos = xPos - BallSpeed;/ W4 [0 e% e% \; W- B) |
      }
- Q, x4 j( z' a) g1 c   else {0 \3 [) c$ w& X( T
      xPos = xPos;
4 _. Q$ g& T7 Y4 S0 N5 K' Q7 J7 r- I, O( e      }' f- y- N; ~$ s7 }1 }4 W
   if (yDir == "down") {- |+ N* O- I: j
      yPos = yPos + BallSpeed;
+ s9 t6 i' G! ]3 m. T% ]& g4 F& d      }6 f+ ~9 X/ K3 b( s6 a$ V7 U/ Y
   else if (yDir == "up") {
6 F& f7 m- n/ ^3 `: C      yPos = yPos - BallSpeed;
+ [. ]% A" a6 ]; Z/ Y0 s( v      }
4 U3 X7 o% \. k' W# A7 G   else {
5 C3 }8 o1 N4 P      yPos = yPos;/ i8 h7 _: I' ^4 _- L/ y) ^
      }
5 H+ Z* _8 C/ I% E   }
4 ]9 x4 i! c7 |! o' ]( E2 W2 D
6 B7 K% b) Q+ Q; a! xfunction hidetext(){5 e" Y. N) N7 H) h: b5 C
if (document.all)
5 f8 a4 F2 D- H# F8 y  d8 o8 m; jsupertext.style.visibility="hidden"
; X2 T4 l% d( ^- \else if (document.layers)3 k, l7 Z% e. h6 T; W4 u
document.supertext.visibility="hide"2 H( g" G4 {; I" o+ A% D
clearTimeout(animatetext)/ V$ c$ M: w1 g. P
}
- @" o- k# j" J  f$ U6 f7 ]; u: a& s1 }
if (document.all||document.layers){! H+ Y6 d! I- D8 z  \( l
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
1 s$ l6 E$ G% w. Fwindow.onload = initializeBall;
+ _7 g8 k* o: Z6 ^" V' b4 nwindow.onresize = new Function("window.location.reload()");) }1 b1 F) r3 m( l' C- M- c
}) ^' ]1 ?5 ^$ j: S- X, }

! i% C, W/ o) D: g</script>

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