获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">
, f3 j; D( k+ }$ T1 k% m# [* u#supertext {
6 h0 v# f% @! [% dposition:absolute;' X5 _- _0 O* y3 g2 O. Q) m
left:0;
- D& {% D1 z5 m. H9 Otop:0;; s+ s% s( _( j# d8 |
visibility:hide;
/ x; N$ ~6 @" _9 Evisibility:hidden;5 q9 p$ S9 f2 g3 B, i- W
}3 t% j! t/ c' c5 \( v
</style>
4 a; A1 B& J8 {8 R9 [/ ^+ X' v" ~<script language="JavaScript1.2">
' q& E/ d; L9 o( h: F; V% M<!-- 改变下的字体的大小。颜色-->
. r0 g2 w8 `% E; X2 J( _var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ i: |/ B8 a- Q- P2 j& ]8 q, d
var hidetimer='';' C! U6 K; a9 w0 M
<!-- 改变下的弹跳速度-->, E- m$ }  Q" N
var BallSpeed = 20;- h( V; I* T" B7 M  P3 k* N
var contentWidth;+ O2 g% b9 P# ]
var contentHeight;. T* G# M7 Q. x, E. `* i+ {
var maxBallSpeed = 50;/ d4 J! v3 W$ S; I6 D
  k3 O# b) I; L  f& \' Z
( G8 d: m$ R2 e  E+ h# }% o
var xMax;0 j) w( G" D: c5 l, v
var yMax;
% y1 D' g9 ~: Dvar xPos = 0;
: ~3 P7 I# R+ c: S! c2 l$ I$ cvar yPos = 0;* t$ }% j5 _+ W
var xDir = 'right';
7 S& U7 b" u  t6 \; Z" Z. b* l/ Gvar yDir = 'down';5 L0 y- q& @0 C) G: _
var superballRunning = true;: z, |) c. l% x* D: n
var tempBallSpeed;5 z- j: V7 U# i6 T8 x- `  {
var currentBallSrc;
1 O# w! A/ S% y0 |7 m1 G& Cvar newXDir;
6 k) d/ i, ?) [) ^; `var newYDir;, x* G7 e7 K" S

; w' ]! t, q% C7 b! |3 q4 Cfunction initializeBall() {1 p, `9 q. L4 @% `( z
   if (document.all) {
/ Z* B9 L" F  m! n+ B      xMax = document.body.clientWidth$ f8 p& W  a* B4 k( Z
      yMax = document.body.clientHeight, V, w+ I8 l9 c+ c7 E) G
      document.all("supertext").style.visibility = "visible";8 r; y& P/ n5 m8 k
      contentWidth=supertext.offsetWidth
  l/ a+ v: e& T# ~6 ~7 f7 H$ Z6 W! U      contentHeight=supertext.offsetHeight& [% T6 j5 A, W) J0 L. U/ j
      }( x6 V, b6 F1 A+ r3 j
   else if (document.layers) {
. a: Y! l: q( j% ^# G0 }      xMax = window.innerWidth;
3 W, z8 ~8 B- Q0 c2 S      yMax = window.innerHeight;
0 X- t/ V$ a/ R- `0 s" F      contentWidth=document.supertext.document.width  ?) R# C; S+ a) T
      contentHeight=document.supertext.document.height' [: c# |2 {3 E* T0 L* e
      document.layers["supertext"].visibility = "show";' I3 E, H5 V7 B  `
      }( L0 h+ N# R) K
   setTimeout('moveBall()',400);/ r  x0 I" U6 X/ u4 W
   if (hidetimer!='')" n( p% B/ Y8 P6 w1 t7 h
   setTimeout("hidetext()",hidetimer); @2 h0 D9 n! g/ u! e3 d: k+ p6 o4 K
   }) S+ E. M5 J$ ?- P

, s. X4 J7 l" x; c& R1 A. L$ |( rfunction moveBall() {0 P: o2 f7 y( U7 @' k( @
   if (superballRunning == true) {
: z) I( G$ I. \8 N4 N5 ?      calculatePosition();- V& j) A) y% K2 h
      if (document.all) {1 D& P- e: E' c5 [
         document.all("supertext").style.left = xPos + document.body.scrollLeft;, R3 J, h* K3 d2 k! d5 X: L
         document.all("supertext").style.top = yPos + document.body.scrollTop;
1 y. \+ X- I' l5 z! i         }/ ]' \  W: k: J7 U' o
      else if (document.layers) {
+ A8 J' M8 O; A- _& _         document.layers["supertext"].left = xPos + pageXOffset;
3 G5 t$ y/ V: N$ D+ W- |3 }) _0 _         document.layers["supertext"].top = yPos + pageYOffset;
9 l+ _, v0 s1 U* u- T+ j9 ^         }# R; E3 E2 E6 D: X6 e* i$ V; C# _
      animatetext=setTimeout('moveBall()',20);  i3 j/ C5 f9 P7 [( E1 v* {
      }; i+ D2 b8 }; ^
   }  i) q# c) o, ?; a4 y
- p0 f* ?5 U+ X# k
function calculatePosition() {
% T+ J. F, A' |/ g4 U9 r( {   if (xDir == "right") {
- Q- ]& @# j% _  E& [6 {      if (xPos > (xMax - contentWidth - BallSpeed)) {
6 ^! X) R/ q. ~) j+ o         xDir = "left";' u3 Q7 p; R3 a: e8 w& J: t* O
         }- h' P( P* L7 B; ^- ?8 y1 N% E$ F& J
      }: m' ?1 u7 f9 C/ V5 e4 V- o4 Q% A8 ^
   else if (xDir == "left") {
8 z* x% l( y6 ~) \6 r, C+ @      if (xPos < (0 + BallSpeed)) {, ~2 [  S. p8 ]0 B5 S
         xDir = "right";
  y4 \  G5 R9 r! ~* u: B" `         }; g. k; `0 V; J& L  a4 k8 i
      }. p% }; m. Y* u( o( i
   if (yDir == "down") {! L9 m$ z. Y/ W9 O$ J4 _
      if (yPos > (yMax - contentHeight - BallSpeed)) {* \5 \( u$ D8 s2 Z
         yDir = "up";8 h- T" B9 S. }3 W  \2 a0 H% v
         }* _0 l$ A8 Z* r+ F1 y
      }7 b2 \2 y; t5 W$ G
   else if (yDir == "up") {
4 D( f7 k( i/ U3 W( l      if (yPos < (0 + BallSpeed)) {
& F9 x' Z, r* h. X( y         yDir = "down";6 g: T1 H; J3 |* N" B1 B+ M
         }
( l; c/ \6 a( n      }; j3 T0 R' m) e* M) c0 I0 C
   if (xDir == "right") {
# }! N3 x% Z- h% i* |" t9 Y      xPos = xPos + BallSpeed;
" J7 G) v6 p) \) N6 u      }* b- i6 A0 v( O9 B  K! g  E
   else if (xDir == "left") {+ \8 d) e/ J) }5 A2 V" w
      xPos = xPos - BallSpeed;
  |$ t( ]; Y2 u& O6 ]; u7 i" E      }
/ B+ ^: y9 n, O8 e   else {
9 _' k" c6 T* ~" s) _. @& w      xPos = xPos;+ }7 q+ i/ r- G' n; W; Z% z
      }" k+ j  c' V; y, ]8 }# ]
   if (yDir == "down") {
% I) e8 `1 \; F2 O8 m      yPos = yPos + BallSpeed;
3 Y2 f  S  J7 ]      }
, C, K& T; z8 R4 X5 T! _   else if (yDir == "up") {
* A! _* N6 r6 g% L; U      yPos = yPos - BallSpeed;7 S8 \: ]' H( R. |& k
      }
0 F; q' Y$ v2 _+ G2 ~   else {1 X6 e7 ]. t, {/ L
      yPos = yPos;
1 ]2 b& _+ q, a2 ?+ m) l, j      }3 }6 J/ W& S+ I' d2 O
   }
5 c& p) |# o3 \- {* v* `+ D
9 G; C5 h$ I, @0 Gfunction hidetext(){
  z5 I* v- g% nif (document.all)
! y- [; p& ~# F' Isupertext.style.visibility="hidden"
7 M- _. Z6 x9 [% i& V+ z  _1 W: qelse if (document.layers)& q: `( {! ~& o, B
document.supertext.visibility="hide"; P- b; ~9 |- i2 J0 M0 o
clearTimeout(animatetext)
! D" W8 [6 T+ R, ?' d' s}! l0 s9 X0 L8 W* O9 ?
. ~: x7 P& I# @
if (document.all||document.layers){% ]1 ^# w. B! D% Y0 y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
  [- U1 @9 {0 w; x! l8 jwindow.onload = initializeBall;0 y9 g8 u5 C4 N( b0 K8 T* B
window.onresize = new Function("window.location.reload()");
$ t3 d& K/ ]3 ?$ [& O; W}
' [7 ~; J. J1 t' u; e9 u
. P$ [# w5 U7 m- m: ]# S</script>

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