返回列表 发帖

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

<style type="text/css">
4 P( d3 m3 @9 z$ b* T#supertext {
! Y- x# r+ J/ L% n& h: Sposition:absolute;! E" d% ?6 A; B2 d! [* E9 S
left:0;" @; m+ K5 A# z$ A# S
top:0;
7 g! C7 t4 y- z, O" r/ ?visibility:hide;
& b5 M1 b) y" D7 avisibility:hidden;
4 p+ K: I) O  a2 X. s; {}
- b6 N4 @1 ?5 ~1 m9 |</style>
: Q# b: g0 R9 p7 A9 z# \4 H<script language="JavaScript1.2">0 w( B) Y3 u9 x9 }
<!-- 改变下的字体的大小。颜色-->
  |/ v) i7 e  G, K8 @var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 Z% z- b/ j. k
var hidetimer='';
0 C' A# {# _* b, |<!-- 改变下的弹跳速度-->
! z6 u" @" O8 k  h. `var BallSpeed = 20;! \* `2 a% M4 P% p
var contentWidth;
5 i9 y2 @& V0 _& g1 _var contentHeight;+ T& b' L6 a0 f* z) q% a
var maxBallSpeed = 50;
3 ?3 ?1 `' m. e- H) y
8 I2 Y+ @6 W. O; j# W" o( q# e% a  F6 _$ q) i3 _" E) J
var xMax;3 q9 Y0 z9 Z( N+ b& `; D/ D
var yMax;0 ^. Z( a# C- [: k) L% |
var xPos = 0;
$ B7 I8 k, v' v7 K  ?6 ]var yPos = 0;* F/ W, X4 G1 G5 n
var xDir = 'right';/ @  u. |4 i: e" o0 S! {
var yDir = 'down';
) |, T- @: q% u. k1 svar superballRunning = true;  p+ k- T7 l( w! T) a; V) U
var tempBallSpeed;
  s$ M7 D1 W9 evar currentBallSrc;3 A. D" I/ d$ I# n5 t! n
var newXDir;
: l% p5 x6 @  Y+ R; W5 dvar newYDir;! J, b7 A# r  v, Q7 {2 H
+ a! ~& f" x* r9 M* Z
function initializeBall() {0 E$ R" A# o+ @; w( w
   if (document.all) {
8 M8 q2 Y  b" a& s' [( u. ?      xMax = document.body.clientWidth1 o! B) k# D5 N6 o7 v/ G9 a* W7 u
      yMax = document.body.clientHeight) I( u) m0 }+ F+ g  J
      document.all("supertext").style.visibility = "visible";
2 V4 E1 U" s4 m# y+ _- E4 o: F      contentWidth=supertext.offsetWidth7 f& @" U+ `$ K; T* U5 ~
      contentHeight=supertext.offsetHeight/ G* b. i, }) z5 D5 X" W
      }9 T2 Y8 }# g/ h; N" x% f: O
   else if (document.layers) {4 `1 s+ Z0 C" y9 R& s8 K
      xMax = window.innerWidth;( G6 Z& g' R0 v8 z3 K0 p
      yMax = window.innerHeight;8 L$ I# G7 t1 J
      contentWidth=document.supertext.document.width7 a8 f1 w9 f, _- z
      contentHeight=document.supertext.document.height
6 ^( s) q# u* [% R5 T      document.layers["supertext"].visibility = "show";
) E# ~0 P5 Z, P5 [- h8 l: ?- q      }3 ?& y4 G9 W8 N. j& @. T4 E
   setTimeout('moveBall()',400);# t6 V& n$ c$ j, }* r2 V
   if (hidetimer!='')
9 @  o9 t% L) n. Y. F$ O   setTimeout("hidetext()",hidetimer)2 h$ S7 W1 j0 m9 J5 V3 e, \' J( G
   }! ~# w% N2 S- T7 c* J2 N+ `

" T3 v$ V5 _* W# Hfunction moveBall() {2 x( b  }2 _; E: W9 a
   if (superballRunning == true) {+ _/ u3 j7 v" _
      calculatePosition();# i2 }4 R, t. r8 Y& N( I" v
      if (document.all) {
8 }7 u2 b6 S! M, O4 y1 H, W" {         document.all("supertext").style.left = xPos + document.body.scrollLeft;
  j: m* B4 _' g) i9 x8 Y4 C         document.all("supertext").style.top = yPos + document.body.scrollTop;
$ K5 C: |3 `4 K9 Q0 R  k         }& X% X3 E6 g/ Z0 h
      else if (document.layers) {, E& j& |) @/ g9 S, v$ `5 |
         document.layers["supertext"].left = xPos + pageXOffset;
# o, U4 w, ]  N5 \4 a7 [# j  W" j         document.layers["supertext"].top = yPos + pageYOffset;8 q8 J+ u0 S; o+ k9 Y2 L. _
         }
6 ?; ?$ B* ?8 e7 P& Q( D      animatetext=setTimeout('moveBall()',20);- {/ W% H3 y0 x1 u. h* t+ I5 K
      }
1 u( T  a" A7 p: h3 [   }' Q, U0 z/ o: V( M8 B
1 O/ \0 b1 L5 o5 P1 v- b
function calculatePosition() {* ^9 y7 j  Q0 \5 J
   if (xDir == "right") {
0 x! ^( f. s3 F; I      if (xPos > (xMax - contentWidth - BallSpeed)) {
: [, z. k8 j4 V/ Y% R3 X( y         xDir = "left";' g! k8 y5 F# O% M, N9 n) P0 l+ ^
         }
) ?; q2 R6 B6 }. s$ o) \      }5 W0 D6 o" ^% m+ l. s) A  X( h
   else if (xDir == "left") {  Z' L: A- s- k3 S: m
      if (xPos < (0 + BallSpeed)) {% ~) k% q5 @6 g1 T; \
         xDir = "right";
% n+ c" J, b  g+ T3 `* ?' [/ J         }2 p- v/ L  n, `! w) |9 ^
      }- E& h. M) J; v) N" X4 u; u
   if (yDir == "down") {
( I! A% U) i% d# V+ F, a. X* Z      if (yPos > (yMax - contentHeight - BallSpeed)) {
* {# B  ~4 b- [$ y. w9 k         yDir = "up";
. R+ r* b& ~5 k( v9 }& R! g7 i0 o         }
' w3 S# y. f/ u/ V8 R1 v, T" C* \3 }4 ]      }
. h! r; C  g1 k   else if (yDir == "up") {5 n. @* \  I3 r4 j! g7 T
      if (yPos < (0 + BallSpeed)) {) I8 M& t1 @- A- ^- r
         yDir = "down";) x9 b- w2 ~" ^& @
         }2 \. J5 k* I# d8 a0 p, o* L9 n
      }
* b( O- j8 `+ Q9 x- I   if (xDir == "right") {
; U" h& L! I0 X6 B  U+ J/ u/ k      xPos = xPos + BallSpeed;
' Z" L$ ?/ ^# T% g3 I" S  s      }3 _, S- }, g8 V) Y
   else if (xDir == "left") {. ]  E8 d0 T& E$ u) q8 o. v
      xPos = xPos - BallSpeed;+ P& E5 X- v" `- x
      }
* Y: A, ^9 {" D2 Z   else {4 x% L# @# f" K' G" t; N
      xPos = xPos;2 A# Y+ d, o) C, p
      }, T0 b# g6 K' S+ k# v; q
   if (yDir == "down") {
$ X  u2 U9 I. F      yPos = yPos + BallSpeed;2 R& _  ^" k7 [
      }
6 ~; }" b* i: Z; C0 S% ^# [2 ^% j   else if (yDir == "up") {
( N$ e4 ~. a: P+ ?9 R+ J) `: e4 i      yPos = yPos - BallSpeed;5 _+ }' T- \8 n6 j
      }
+ K5 c) V$ q; ?# J" y8 e/ i   else {& N5 \3 R" M4 t/ _2 x. S
      yPos = yPos;7 K# b  C( ^* g6 w0 k. D
      }7 u1 R5 F6 n; a" \* j( l% f& m
   }
9 @+ a0 f" k+ K
7 x3 M* y1 {* ]! ^function hidetext(){
  C- o# R! P# B& u$ X# e- `# Cif (document.all)' T7 ~+ g3 d7 i2 x2 a% s& v) W: y
supertext.style.visibility="hidden"
- O2 M8 D. ~, Gelse if (document.layers), A# \% C. Z7 p3 {: W7 N* [
document.supertext.visibility="hide"
7 \; r; ?6 Y- x: b$ X4 ~/ wclearTimeout(animatetext)
! x) _' x$ j5 z' N5 d0 W7 }; d. k) o/ J}
. K( \1 F6 F3 ~: X# h* ]: g5 p% s+ V8 g; _8 J* ]
if (document.all||document.layers){0 g$ y0 Z- D) o, L  a" D
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'). |$ ^/ y5 }, z4 i
window.onload = initializeBall;
3 d- q4 g6 j% d; ^window.onresize = new Function("window.location.reload()");
. Y/ ^$ i. u. ]}
8 u* f9 F) Z) _0 B1 u: |
, }3 R0 Z: a) n6 y, j- S2 r. {' q</script>

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