返回列表 发帖

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

<style type="text/css">
' V( o$ u( E$ h# ]1 ]1 u#supertext {
! F7 _. n  B2 W6 ~' Fposition:absolute;2 ~" t3 K% J4 [* ]1 u# Y# X
left:0;, S- m3 M$ Q+ i8 u2 @
top:0;- ?* R* E! [" g9 R
visibility:hide;4 S9 O1 r. r$ M. k, i  V3 _6 N3 B
visibility:hidden;' [. i. M+ z' y' p, v
}
) {' m% l5 l) c6 G5 K  \( X# P</style>
2 t, n1 k3 z2 }( T! ^<script language="JavaScript1.2">- P* A& |- U2 T- o" E
<!-- 改变下的字体的大小。颜色-->
( n+ Z1 @6 O. Lvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% b& r1 X* G# ~7 {( ?var hidetimer='';( R% |6 f: ?3 w) C
<!-- 改变下的弹跳速度-->
  G' s% S% o( u5 R) s: M* }var BallSpeed = 20;. B* d( O* ?1 L) \& I
var contentWidth;* Y: r$ r! O, L; Q! t
var contentHeight;  r9 M- K, z  v" o  P  H
var maxBallSpeed = 50;' I% v$ Y- w$ C' G3 Y5 _
2 l: G6 \5 W# N# |1 }' s! @) r

  ?* O; a" d# j9 \/ I! G- W7 bvar xMax;
9 {9 H% M: _& `/ {2 N3 _var yMax;; |6 B9 p2 |  p, {
var xPos = 0;. K- ^, y# c, a; |7 c# U  Q
var yPos = 0;
# h! B8 f! C! Y/ A0 }var xDir = 'right';
- P/ F" S& D& Nvar yDir = 'down';
) Q1 V# v( e: J! N1 ivar superballRunning = true;
3 _5 Y3 o/ l% p$ r7 y8 Rvar tempBallSpeed;3 ]) e7 h- M; k% T  u1 A1 m+ K8 s
var currentBallSrc;4 \, U0 b/ O7 Z7 Y9 G7 I
var newXDir;8 y& i8 x8 T, n6 ?7 P
var newYDir;
8 Z7 ^: P$ x6 o6 t, B' J( g  e2 G( c1 t
function initializeBall() {
  \1 ?# f+ H2 x% P1 F# i   if (document.all) {
3 f3 U1 H7 R/ Z2 a      xMax = document.body.clientWidth  s( g# \/ m# Z' N% O
      yMax = document.body.clientHeight/ t0 O+ w7 @. L% q! q
      document.all("supertext").style.visibility = "visible";+ D3 v( c' z+ u2 u- z& g. s7 s
      contentWidth=supertext.offsetWidth8 |8 Z. y* e( Q2 V
      contentHeight=supertext.offsetHeight6 {% ]  X2 @- L8 I  g+ i1 [
      }3 ~3 V5 B8 e) d/ k& f+ D
   else if (document.layers) {
3 Z8 `  |+ ?1 Y3 T/ ?! O0 m      xMax = window.innerWidth;
. p3 W& H. }: x* ^/ [, o      yMax = window.innerHeight;0 c& @" V. B- [& o% f. u
      contentWidth=document.supertext.document.width5 H) x  K/ G" a( I
      contentHeight=document.supertext.document.height* `8 y1 p$ Q% m+ _. ^" P5 {
      document.layers["supertext"].visibility = "show";
& ]# }! c4 K* |7 V* G      }
; h* ^- t' x8 p. M   setTimeout('moveBall()',400);
! e5 |* E2 n; ?* Y7 I! i! v   if (hidetimer!='')# L) Y3 e4 N1 W8 e
   setTimeout("hidetext()",hidetimer)+ |, j9 q2 m7 D7 u: p9 {% d: o- |) T
   }
" u4 b3 A% J3 H, r; d/ }( t& b3 F) F( s: {8 }* @6 M/ q+ q; Q3 e
function moveBall() {6 t+ d% }6 d. G; e
   if (superballRunning == true) {
2 V; Y- \1 {% \. z$ @      calculatePosition();# T- l  n( x% R3 D* @/ m$ P
      if (document.all) {$ d* k% [0 e. ?# R; ^
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
, ~# f5 r& ]$ a' C, q' b3 A         document.all("supertext").style.top = yPos + document.body.scrollTop;. [( P& _" l5 ~% h8 O* l* E7 l* p7 J7 {
         }
1 b0 M# f8 h$ V  a$ Q+ i      else if (document.layers) {! H% F3 y. S% R1 `
         document.layers["supertext"].left = xPos + pageXOffset;
0 r3 N  b3 Y4 a. V  F- X) U7 T% N         document.layers["supertext"].top = yPos + pageYOffset;/ |' ]. f9 y; \/ r, [5 ]1 C
         }2 f) ^. v1 I  |$ L2 e
      animatetext=setTimeout('moveBall()',20);
% R/ Z. N# K; a5 X      }
' s2 K7 b, V1 k' g' x+ X$ m2 n3 p   }2 O& T; E# {# L) f) s! D, e
' m4 x) z, O0 W0 [
function calculatePosition() {
6 j! N- V. t. A* v' V   if (xDir == "right") {- O' G9 Q  ^/ V9 b3 k$ z) t
      if (xPos > (xMax - contentWidth - BallSpeed)) {
) i" W2 Q' c% q: j5 v) C         xDir = "left";! v: T: b) D! A( h: p5 ]5 V
         }/ b3 O+ p0 C$ V) w" G1 r/ U/ L0 J
      }
" K# o" {) @+ |" z  ]3 o9 ~   else if (xDir == "left") {
9 S9 r5 A' U+ A& d, ?# F      if (xPos < (0 + BallSpeed)) {
: u3 x& J+ ~: h& f+ c! y1 Y         xDir = "right";8 n: ^: h2 `, w. p5 W; J3 |1 x
         }
0 c/ ?% \8 K! e1 z      }
9 s7 B0 p, x% ^; X) |0 P7 L5 [   if (yDir == "down") {
+ Q1 J- Z9 y$ S& P* {" X      if (yPos > (yMax - contentHeight - BallSpeed)) {
) P( f9 R5 V1 {7 H         yDir = "up";1 b; [+ H! v# m7 U
         }
; a) y+ L% K8 m; i: y      }
3 \$ w% o4 O$ J$ [+ ~/ B   else if (yDir == "up") {
# U! i( G$ K+ y7 e5 z  s      if (yPos < (0 + BallSpeed)) {6 U# ?8 A" O1 H. j3 F8 }
         yDir = "down";
- o4 C/ v7 ?# m: o  _! N* P0 o         }
' l6 e2 a& R% o6 S$ b% k' y      }
+ T0 @. O. z0 n1 u   if (xDir == "right") {0 ^6 n( S) z5 S' ~5 A
      xPos = xPos + BallSpeed;
6 j6 |! j& N6 ]. |8 s8 g# c      }$ @  o' X! Y4 i/ j4 _* r
   else if (xDir == "left") {
+ }" U9 i- a+ @$ ?( l; j      xPos = xPos - BallSpeed;
, T. N$ E0 U' K) ?* M      }
- }9 B* i4 U! g" u/ q   else {
/ O# w& }- v/ V% A      xPos = xPos;* j' w: x& }4 Z  G4 l
      }2 t* p& n. V9 {6 w
   if (yDir == "down") {3 f) R0 }6 G1 A4 H3 q
      yPos = yPos + BallSpeed;6 T( ~4 `0 |( x1 ^. J
      }( P% E/ j, F+ }' s
   else if (yDir == "up") {3 a2 @: k5 R( W  i0 Z5 Z8 M, T9 p
      yPos = yPos - BallSpeed;% l9 u  Y' J; c* P! [
      }
* y! Q- \3 y5 o/ I8 p   else {
8 G2 m  X+ u  }/ _  W      yPos = yPos;9 y. O7 M+ O% m7 Y0 f% F
      }
% c8 p& j# G6 V$ T+ |# g) w   }
* G" h% J" B" `% }: g
; @( R0 w4 A" S) h0 O  i3 ~function hidetext(){
' k; r2 N3 M* m. I) ~' g$ r& l9 a5 Gif (document.all)
; S2 g) q1 u% \supertext.style.visibility="hidden"
% x3 G- [# {; B& W: y" W4 n* Gelse if (document.layers)
& q7 ?  o% k3 vdocument.supertext.visibility="hide"# R$ d) i. N/ i& g) E9 ~& J$ V7 H
clearTimeout(animatetext)9 G. h1 m# Z; a
}
- W: f$ z) x& u8 {! s+ s1 S8 ~7 p5 v2 K9 V" G
if (document.all||document.layers){
5 D3 @, F5 C0 e3 pdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
8 `+ X. H2 K" x9 i1 p  ^: M+ M+ U/ Bwindow.onload = initializeBall;
; k& h& k* C* \( F" p8 h# ]window.onresize = new Function("window.location.reload()");9 I! X9 I0 t0 C2 z
}. I8 @! M; U4 @$ i0 P4 \7 @

! e6 [& A( {: O: Q' _</script>

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