返回列表 发帖

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

<style type="text/css">
2 b' a5 V8 @0 w+ }( B#supertext {
7 p. y5 F' a3 |0 u9 jposition:absolute;
5 b% f4 Z/ o" A3 |left:0;4 ]6 N, X; p( f4 P
top:0;
. i! n. {, X+ B* d7 Nvisibility:hide;
8 x8 {6 A) [, I0 d( r7 Xvisibility:hidden;! g8 c* S" P' F
}; ~9 t# P. J# a& G7 N4 }
</style>
' o3 U& S( _+ o<script language="JavaScript1.2">
' K0 {0 `9 {$ d1 S% @5 J5 t8 k<!-- 改变下的字体的大小。颜色-->
! t9 L- t; R5 k+ A1 O& Bvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
: ^- _/ g/ T1 Rvar hidetimer='';3 N: ?: p1 h2 w& B% F6 U
<!-- 改变下的弹跳速度-->3 ~' x- i0 W- l; V' m
var BallSpeed = 20;
7 E- q5 n6 i* \( U+ `' `var contentWidth;- I/ {) l! h# v
var contentHeight;
% ^# n( P. Q" uvar maxBallSpeed = 50;
+ S5 `6 R! X4 P+ ]* z2 q* \
; ^% O  @! t) W6 i6 c$ f# a2 i& H. I$ S
var xMax;6 j8 K& T: j- v$ N2 P
var yMax;! ~: `1 O) p9 p
var xPos = 0;
* P( P1 `; @9 K% H9 Y4 Q+ Uvar yPos = 0;0 D; k8 n+ Y( |" z9 A9 S. s9 o
var xDir = 'right';! u5 n9 `# q) }0 V
var yDir = 'down';- Y/ H# ~  `3 N3 o6 m3 `3 ^
var superballRunning = true;0 A  t% F+ Z  |) R$ U6 g
var tempBallSpeed;+ S6 ^4 N9 |' s" Z, D+ b" g
var currentBallSrc;$ p" Z, L# u0 k# h" o, z
var newXDir;
/ p1 D$ L. w6 e3 ^" U. Fvar newYDir;; k$ U5 Z( g) o0 N& A
* \. }! g( i+ @+ X% B2 j& b9 J- Q
function initializeBall() {0 F2 \7 u4 b. x( H# ~( e$ ^2 Q* ~/ j
   if (document.all) {
2 p1 o0 k) G% L( ?/ A      xMax = document.body.clientWidth
; J7 N$ e( |# ?8 Y" F+ E      yMax = document.body.clientHeight5 a( K" C0 H% X& l: t
      document.all("supertext").style.visibility = "visible";  g% @2 H/ I, ~8 ?
      contentWidth=supertext.offsetWidth
6 n: @$ O8 v( v0 F; }7 c: p! j9 j      contentHeight=supertext.offsetHeight
  s, N! Z. x- C* n      }, z- Z) f* ?* r( n; W7 C7 e
   else if (document.layers) {# s  k0 x& Z. Z- W0 d; R
      xMax = window.innerWidth;
  _$ X) N  Q. C: C7 z* ~      yMax = window.innerHeight;
) U6 o8 E4 `2 v2 I7 ^      contentWidth=document.supertext.document.width- m) |! H1 x" p6 z+ U; ^
      contentHeight=document.supertext.document.height' `3 B! k" _1 F
      document.layers["supertext"].visibility = "show";" r+ C1 q+ n' `+ w
      }
3 ^! |5 \' T, w/ e   setTimeout('moveBall()',400);
: d/ e; I" |- G/ L% [$ x4 L" O   if (hidetimer!='')
0 W  P' z! y) I6 a   setTimeout("hidetext()",hidetimer)! k! |. I! S) j$ S' v
   }
0 i0 ^* B- Y4 T' {! J$ k! R0 G/ O
! t' S1 v+ G; Yfunction moveBall() {# I+ M3 R) k1 N! q
   if (superballRunning == true) {
2 d4 y8 B4 F9 ^/ d$ H      calculatePosition();
% v' A. `% E! h1 \( m  P  V0 E1 E      if (document.all) {1 X( i1 |  b2 T2 K& `" s
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; g/ z( z8 I6 m' `         document.all("supertext").style.top = yPos + document.body.scrollTop;
" V9 t- ~. q( y! ^& V* R9 a         }
, o$ ~% ?9 N/ ~( ~. Y" N      else if (document.layers) {" q0 U3 @5 E3 b; J+ J! H. c
         document.layers["supertext"].left = xPos + pageXOffset;
7 V. m8 i" g! l) S* V6 W5 ~9 H         document.layers["supertext"].top = yPos + pageYOffset;' g. c  {  A4 t6 a7 Q- e$ l
         }5 f; s& C7 [* _
      animatetext=setTimeout('moveBall()',20);
! w" ^4 \" W) [( C5 n  Z      }8 u( j% z/ O% ~7 x0 y
   }
' J$ a) `3 L5 l' [" j0 p- s
; ]. d6 ~! `9 t4 c( qfunction calculatePosition() {
5 ?( [# d" Q# c8 P   if (xDir == "right") {& X- o8 T, J. ?& `7 |. b# ?* l
      if (xPos > (xMax - contentWidth - BallSpeed)) {, t" ]1 z+ ?8 r9 `
         xDir = "left";
4 F3 B" m  p$ O  u6 S         }
' x1 c+ v$ I7 ^      }
2 T- v' i. W! ?/ A& [3 Q   else if (xDir == "left") {
/ d+ Z" r( H& o( h0 q0 z      if (xPos < (0 + BallSpeed)) {3 _9 N. U  h2 [, k
         xDir = "right";
" X6 o! B' E- m( D7 o         }
- @3 P/ Q* `/ I+ D4 W4 |      }# s% c0 \2 x0 u4 |9 q
   if (yDir == "down") {3 Y( G2 K4 F( H, `5 g
      if (yPos > (yMax - contentHeight - BallSpeed)) {
0 w6 U( M) w6 o         yDir = "up";
8 B, J; y7 @" K# D; i2 u6 ?* z         }
/ f* A8 u+ B0 ?5 Y& U# r" t      }
  y% e' C/ N' ~3 m   else if (yDir == "up") {
0 {9 S  @7 y4 H9 b4 q      if (yPos < (0 + BallSpeed)) {
7 U# I- \, u4 Y; v: _4 D* v. u+ F         yDir = "down";3 q. o/ Y/ v; }9 `6 Q
         }
' w! S4 r" T& Y  x      }
' Y0 {' z$ u) H2 N/ f3 A6 n   if (xDir == "right") {
' R  B. B% T7 C, [      xPos = xPos + BallSpeed;$ L, v7 K( R* `" r7 e7 x9 ?. e
      }- @" k8 V0 }' e
   else if (xDir == "left") {; B* S" i# _8 {$ J: W0 B2 N' e; {
      xPos = xPos - BallSpeed;* L. J3 o) P: F: H/ N
      }
5 g) x$ ~6 ?; Q" P1 \3 c   else {- L: }$ |, }7 o( s  |
      xPos = xPos;
" f8 M$ m/ z# \7 H* C4 j6 q2 w      }
* J# t9 l0 O2 @& `8 m, t/ m$ m   if (yDir == "down") {5 K; D& t7 E- Y) d1 Z9 x
      yPos = yPos + BallSpeed;: K4 R$ T; i+ `9 a
      }" q# z3 }& {1 o3 A1 F' r$ V
   else if (yDir == "up") {
; W8 u8 G4 e7 S      yPos = yPos - BallSpeed;, z8 F. }, W" _
      }$ ^+ I  y" \9 U8 \' g) y- l- b! Z
   else {9 j" ~9 S0 `- q+ H+ z$ f# U0 U- ]
      yPos = yPos;
# z  e: r0 m- Q4 _      }
/ S% v/ N+ G4 W' v, k! n5 L! D, J   }9 [+ _. k+ a1 C' n: m
6 `: _; g$ ^) @; ?% ~* G
function hidetext(){
! l* J( ~$ f4 b& S1 R/ p1 _; n1 @if (document.all)! p. E5 l* ^  A, g* e! D/ V+ G. n1 K0 k
supertext.style.visibility="hidden"
9 p" M0 m7 k, M" y- K' `else if (document.layers)0 s% e9 E) j/ Q' m- {/ f. O5 i# Z9 t
document.supertext.visibility="hide"4 ], n5 b1 @; O5 G
clearTimeout(animatetext)
0 O$ A9 w& T; ?* r( \}' S! u+ p5 [* S+ w& e

  }0 K( \' `" w6 i8 A1 [if (document.all||document.layers){; Z# l' v7 S; Y, B/ b8 ~
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')5 |$ T- {  ]7 ]6 V' ?) p. D: E; T, S
window.onload = initializeBall;2 E$ ]" L" `9 S, W; A
window.onresize = new Function("window.location.reload()");4 n. P% z. `- W+ l
}& q1 l4 X. _; U. @/ b7 U2 I
( {0 h9 K: L" m1 P$ `
</script>

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