返回列表 发帖

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

<style type="text/css">
7 Y. o9 G5 n# H: n#supertext {2 b$ L" X' W' O9 E! \0 j( l
position:absolute;' ^9 G( O+ S9 E7 B: U! L
left:0;
: c; ?) z  [. rtop:0;7 p  ^# [' v9 Y' l
visibility:hide;- E0 z- f! R' T" ^/ u
visibility:hidden;$ P& _" v+ w+ e0 b' v
}
: q3 p. V/ W: A7 I# S9 j6 z3 l</style>1 W. i9 m" t* {- V
<script language="JavaScript1.2">
: L' }/ m; D  B$ }  l: H5 U<!-- 改变下的字体的大小。颜色-->
, N4 y* s# m: [: p) @+ Mvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( e" ~! m* t# r! rvar hidetimer='';
. K$ \# j6 t7 w6 z5 u) Y<!-- 改变下的弹跳速度-->- J% b& ?0 g( N. E8 D  X' O2 |3 ~& K
var BallSpeed = 20;
! v* i7 \9 C. [. O+ Vvar contentWidth;. H0 B2 _( A) j# M8 _3 E; C. Q
var contentHeight;
" R9 m# ~. ^; X0 Z3 pvar maxBallSpeed = 50;
0 u, M1 N: g3 [9 ?- _
9 L4 S: Z9 h! v0 V) M, w: H
0 Z4 x: f0 H  |  v) Vvar xMax;, s4 K2 c- J" ~# a5 L
var yMax;
# Q  i& A6 o! r% Y9 l0 Hvar xPos = 0;
1 f: I) ^$ p+ }& E* \: Gvar yPos = 0;, I! Z' t# a) t! m; ~# f
var xDir = 'right';
2 D2 X% D9 q$ {+ `1 K$ G" evar yDir = 'down';
2 _' g3 |. h$ ?9 N8 W' Jvar superballRunning = true;" K8 H0 n; i' U. m1 W( i/ u5 q5 l
var tempBallSpeed;
; H$ N5 q3 a" ]/ @- }: M! B* M. M* z  Jvar currentBallSrc;
/ Z& Z) B+ {7 Ovar newXDir;2 g2 z. X3 d% K" A) A# ]* J3 o
var newYDir;
# u6 p0 O( d) n8 m$ b1 b( V6 _8 j0 J  V
  L- Q# k6 M/ c+ e# D- Afunction initializeBall() {
: }' `& v7 k5 `! z' N   if (document.all) {8 `2 z, e& e' g8 v+ z# H: B7 k
      xMax = document.body.clientWidth, r8 O' o6 t- l" T; E6 j# f
      yMax = document.body.clientHeight8 D+ t. a& w7 F9 N& q
      document.all("supertext").style.visibility = "visible";
. M# J/ }' e& d1 c* L8 S7 j      contentWidth=supertext.offsetWidth
6 _$ K' T: r8 k$ F7 b% z5 R      contentHeight=supertext.offsetHeight, a5 s4 g2 V# u% G+ A! \
      }
6 \# M, E8 _8 ~4 c6 Z   else if (document.layers) {
7 n( ]# }) ?0 I! S5 K      xMax = window.innerWidth;
( N0 l( |# K; U      yMax = window.innerHeight;
9 }2 a" x4 Z0 o* ~! w: }      contentWidth=document.supertext.document.width4 C3 B/ l/ s2 x- t
      contentHeight=document.supertext.document.height" Y  n, F9 `- s
      document.layers["supertext"].visibility = "show";2 e" Q1 q( w) P4 O
      }1 G: w- w. ]% M4 Y# M
   setTimeout('moveBall()',400);" v) L7 w: d' J- K
   if (hidetimer!='')
5 e, M. |# Z" f   setTimeout("hidetext()",hidetimer)
* r3 j. v$ q* k. N3 `   }2 g, O( Q& m* {% `

$ }) k# f) @2 d! Y7 |) g- ~6 Gfunction moveBall() {
, O6 }& a7 t! @6 [8 ]; [   if (superballRunning == true) {
0 S/ s  W1 N- S1 V" o      calculatePosition();9 A9 A+ Z/ f- t9 l9 X2 p4 b
      if (document.all) {7 ~0 n- J' V3 T1 h6 W! M7 S
         document.all("supertext").style.left = xPos + document.body.scrollLeft;+ W& Z& I; f! W* f
         document.all("supertext").style.top = yPos + document.body.scrollTop;9 ~7 Z, ]( g% k% b
         }
! f$ y6 @. b7 Q2 Q1 q  x      else if (document.layers) {
: R7 d, F6 n& P  x         document.layers["supertext"].left = xPos + pageXOffset;
! `/ q% d$ o8 A+ s. T4 R' N         document.layers["supertext"].top = yPos + pageYOffset;8 \0 C3 E2 [+ U1 x' U
         }
. U+ y4 o8 p  @      animatetext=setTimeout('moveBall()',20);0 \! U( y0 T3 C
      }. n2 |7 x, t) ?# F2 E
   }; I" S# i" @/ q9 j0 |
0 Q, M. J; k+ S8 A% y% A& L8 l9 ]) Z
function calculatePosition() {
! E' A) a5 V# u: r. R   if (xDir == "right") {
' l' \7 V  O! s3 ^0 @      if (xPos > (xMax - contentWidth - BallSpeed)) {9 c6 y8 |6 v0 W* v+ h
         xDir = "left";6 l/ z! ^, L3 Z1 y' e+ W3 E
         }6 x6 a- x% M* G: J
      }5 K' q7 h' i. n0 v& {% V) s
   else if (xDir == "left") {1 @4 |7 A( s0 p: ]
      if (xPos < (0 + BallSpeed)) {" j* z) B9 y) t) {2 u, y
         xDir = "right";
) x( W/ X, H: D# Q7 |         }
( X" C* Z8 D: R$ r, ~7 j5 M# z      }
$ e3 Z8 m1 U* K6 V2 f   if (yDir == "down") {  |, o4 @" u! ]
      if (yPos > (yMax - contentHeight - BallSpeed)) {4 R1 ]3 k0 l9 R; ~& M8 f( I1 Z
         yDir = "up";
/ P1 d& H% p1 V3 {* W         }8 x4 W( e6 w% J8 \
      }" }: T+ a" i- K; N
   else if (yDir == "up") {
. g* D* T0 B. R, w      if (yPos < (0 + BallSpeed)) {
' r  O8 N9 s$ c  f% s' U3 N/ \         yDir = "down";
% X3 G7 R" q; H) c; [3 L3 U         }; I4 ^9 I4 K: w$ L) V/ R8 U8 w
      }
. H) c, [0 Q. p$ M- u   if (xDir == "right") {7 C: ]% ~# I# p# a; b% O. {
      xPos = xPos + BallSpeed;
/ I$ V3 k- d# s/ q  j0 |$ n) Q6 j      }  ?( W; n8 u& ~9 V2 c$ m: ~
   else if (xDir == "left") {
: {, Q" R! V8 P7 E/ i9 T$ q      xPos = xPos - BallSpeed;0 w1 p- u" G& B* g  b4 E+ J5 r
      }: l' H& l* j1 T/ m$ b. T1 p) s
   else {. w; j9 y1 G/ r/ H' D1 E, y
      xPos = xPos;
* K1 A7 L1 O; M# A2 _      }
4 S! ^# C7 Q1 |8 |6 @( e   if (yDir == "down") {: C. w8 k0 o8 a. ]" @# ?
      yPos = yPos + BallSpeed;( p! d7 S3 E7 K0 V3 P- ^) T
      }
0 l8 g5 Z* U: e8 Q& e' `   else if (yDir == "up") {# ^' j- @! |0 V* V
      yPos = yPos - BallSpeed;
1 s* p6 b0 r0 |$ Y' j1 a4 b9 M" A" T      }
( a* }7 |4 \2 Y) ~   else {
9 O  m7 b" c9 t& {0 S0 G. p      yPos = yPos;' O$ a) b. }6 k+ {
      }% |/ j. R* A0 u$ H) p  V6 u( s1 {
   }
/ ~8 ~2 u0 K7 C5 H1 g& D
7 j2 N" J* p5 }2 ^9 Tfunction hidetext(){
. V: L6 C* p2 {: h( E5 ?if (document.all)3 L0 d1 H: D) O" {
supertext.style.visibility="hidden"
; r$ y3 C& V) s0 p& S+ Selse if (document.layers)+ E, Q- S7 Y! y2 M0 G
document.supertext.visibility="hide"
* D9 F* Y1 I6 V( BclearTimeout(animatetext). s0 r: N/ S" r" _* N
}
. J  D- H1 x6 I! s
/ i& `- g! ?) B0 \5 m( F) uif (document.all||document.layers){& c: N$ r1 r: L4 {0 b, Y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')( `% q- e! \0 H2 `  A
window.onload = initializeBall;1 y" `  k7 |! S
window.onresize = new Function("window.location.reload()");
& F2 X4 w$ @& q9 f8 v}
( y( Y4 m- [, J! s' T5 T* j% i! R% R* Z9 w# t
</script>

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