返回列表 发帖

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

<style type="text/css">5 K) |1 b( C( K, [/ C
#supertext {* v+ ~5 B" i' k  `" t2 A" I, l
position:absolute;
$ I4 a: X  w" L% r  \left:0;" F5 L3 L! L$ ~5 s
top:0;1 R5 ~" d% I8 c8 [5 @8 s
visibility:hide;
& e" ^' f5 ^, i; z3 Hvisibility:hidden;
& O( p" m) L7 q# e/ w}
6 B6 l* R" Y1 F; a. K</style>3 ~, O& y4 r" s
<script language="JavaScript1.2">4 l+ v- E, }1 ~  k6 M6 j, D
<!-- 改变下的字体的大小。颜色-->1 M7 G2 e4 l) k) E$ B
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# j2 Z8 j( w) _8 |
var hidetimer='';( Y$ [, ]1 D8 w" ~$ Y7 Q
<!-- 改变下的弹跳速度-->/ d. F# j) j6 Y( A  q' Y
var BallSpeed = 20;
; ?8 X) E0 E2 c! Svar contentWidth;0 n6 \# i1 }6 E5 n) w$ o4 H& ]' r
var contentHeight;
' |8 k7 \% _0 D, G$ m/ `var maxBallSpeed = 50;
0 \! D) x$ E% K
% R+ ?8 n6 A5 H% O6 a$ }
9 o/ M; d/ N5 u( ~: ovar xMax;1 O+ n% P$ t; P# h: W. d' M
var yMax;
9 I& G4 R8 J8 K& n: u  ~' J) ~var xPos = 0;# Y  ]7 W  ~0 R
var yPos = 0;
* ^. |4 ?& _( V  a+ u( |var xDir = 'right';
5 G  H; `, ~6 z6 wvar yDir = 'down';
% q+ O; f  j4 d% l6 Hvar superballRunning = true;( F) `9 [6 p2 H9 D- Q* w) ?
var tempBallSpeed;5 }# S( u+ [# M3 Z, B7 ]
var currentBallSrc;! v" X; w: K# f& c
var newXDir;+ f2 {- k' Q- j
var newYDir;
$ Z" c$ P' s6 m4 G5 h/ Q0 t1 T: D
function initializeBall() {1 \, h) {& S0 A0 K; y2 U% M, R9 Y
   if (document.all) {; g8 \& U, A9 K$ h; _' {
      xMax = document.body.clientWidth  E9 K) j8 s! a6 l, ?% T0 F
      yMax = document.body.clientHeight
  T6 l: i& [- w5 n2 w7 {      document.all("supertext").style.visibility = "visible";2 N- D2 ]8 g4 y: e8 {+ g$ ?: q
      contentWidth=supertext.offsetWidth3 v- D7 [2 V  y0 y: u( o, w1 Z
      contentHeight=supertext.offsetHeight
7 D6 M* V7 G6 w$ @      }
! Q5 y  A4 [0 x3 P1 e   else if (document.layers) {
! @7 x; W+ v/ U, J; C      xMax = window.innerWidth;/ s* J& m; i* Q' o
      yMax = window.innerHeight;
7 {; R' F/ m& H5 e9 h      contentWidth=document.supertext.document.width( _& |2 J% k" |$ c) }
      contentHeight=document.supertext.document.height9 m* F3 m& G+ m0 C
      document.layers["supertext"].visibility = "show";
5 M9 j/ \# o$ b$ v7 o+ @% Q      }8 c; r! c8 r( u  @
   setTimeout('moveBall()',400);/ a/ o6 J7 [# H5 x
   if (hidetimer!='')
# @8 r1 n, w) z- ^% p   setTimeout("hidetext()",hidetimer)
/ n1 B: u% E2 r4 {   }; G2 [" I* R9 Q& v

8 Y9 l: X( M0 x$ qfunction moveBall() {
2 h! o& q- u: G% \4 y   if (superballRunning == true) {
+ L- T( ?2 T8 n      calculatePosition();
  x/ ?% s2 `1 `  C# D  Q* `      if (document.all) {
+ W+ J5 |7 j& z         document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ p) J9 |6 a# c: U; O         document.all("supertext").style.top = yPos + document.body.scrollTop;7 z% W1 F% W0 p8 F! }
         }6 o. O6 }* S* f9 V0 ]( q
      else if (document.layers) {, v2 o2 z3 R2 ]
         document.layers["supertext"].left = xPos + pageXOffset;" t9 e; m5 O2 X: X4 o
         document.layers["supertext"].top = yPos + pageYOffset;
" x6 K$ C. }3 ?6 N0 k) r         }
- b5 L* Q. p. m. ?$ c2 `      animatetext=setTimeout('moveBall()',20);( h9 ]0 V) n& R* h) y
      }
, y5 t1 r* Q1 |2 f) i. K   }
# ^& e7 p7 }1 o; ]! a+ F
3 B# M% q1 `6 k" W2 xfunction calculatePosition() {
; v9 t7 a, ~9 ?( l. [3 }" J1 d$ a   if (xDir == "right") {* _3 K! |- w2 \) R* a% n
      if (xPos > (xMax - contentWidth - BallSpeed)) {
! h8 A  s1 I5 g3 H. I         xDir = "left";
" L1 K# G# p" b2 x. N         }
# \% S$ A9 o) H2 b' Q! Z+ B      }
$ o( |1 r% s5 L" r! |( b, u   else if (xDir == "left") {1 Q1 {& f9 {5 {, [# {* {
      if (xPos < (0 + BallSpeed)) {
/ y+ N3 U) @- H: O6 P+ O         xDir = "right";4 _' B, Z0 c0 f, k( Q
         }
% m! {% P) ^. F0 h      }5 r0 t0 s! c9 U9 g# o
   if (yDir == "down") {: k' v4 K% U0 {4 V3 ^3 o4 A
      if (yPos > (yMax - contentHeight - BallSpeed)) {# ]* r) H5 `" C1 [
         yDir = "up";
9 J; a/ h3 _4 g6 w5 V& w         }
+ q5 C' Y! }! D5 u! m      }
% N0 q  y8 w1 r% T6 F   else if (yDir == "up") {
" J; _9 G" q2 `& S6 {2 x4 [' H5 t      if (yPos < (0 + BallSpeed)) {
4 U1 \$ E$ i) k         yDir = "down";7 z' R" z, B' e0 ]3 {/ f: y4 z
         }
9 V/ j( N7 k5 D; h+ D! ]: T( [      }% h. f9 k; ]( v
   if (xDir == "right") {4 k) i& O" P, F. J
      xPos = xPos + BallSpeed;  N5 ~; C: W4 Z3 s5 c
      }  q" n4 U1 _* T* Y/ r* z
   else if (xDir == "left") {
- S' z' F$ [3 u- V2 I" u      xPos = xPos - BallSpeed;4 G# ?' ^4 ?3 h1 {: C
      }
$ W' Q5 }8 {9 V7 ]3 N. b/ i9 c  F7 \   else {  T5 u! G$ U" X0 y$ [
      xPos = xPos;
! ^1 c% L8 `' ?" n, d1 B      }
6 e: E5 V  ^0 @4 U: `9 H0 t   if (yDir == "down") {9 R3 Y4 B" P; ^, }, r5 e  p2 @+ e+ v
      yPos = yPos + BallSpeed;
+ W1 O3 U; {6 j* t* ^      }
2 X" I; b0 A; {' l   else if (yDir == "up") {: Q  C" ?& a" [2 `6 O2 l# i. n& c4 R
      yPos = yPos - BallSpeed;
+ S. x( U+ {: F" i1 [8 _      }
5 y$ d( U2 Z7 D4 f# P( M   else {: n9 J& t" n% v$ N! H/ k0 x
      yPos = yPos;
1 d- e% v9 `( \' j7 Z      }; k# X- h$ ^9 W# _3 A6 n! L% L/ k
   }! ]$ T( v8 C$ e
$ U, f9 I  D7 V4 H  g" j4 g" g
function hidetext(){
" W; o0 W" Q8 \8 Aif (document.all); R# ]8 A3 ~2 M7 V
supertext.style.visibility="hidden"1 K$ ^1 L# h# e8 c
else if (document.layers)- T1 b- F: j6 f! R" i( {1 M* ~  E
document.supertext.visibility="hide"
% j. f( a9 |5 [5 y" s# \& h2 YclearTimeout(animatetext)
0 M3 s" u- Y$ `5 f8 H}8 ?+ e+ x7 S8 }! E# o5 E
3 N# _, q- q1 L8 K; z' B
if (document.all||document.layers){4 J2 ?% o. {' n5 N% l+ f
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 @. K) B1 C" K4 h+ ^, O- i. Q5 zwindow.onload = initializeBall;, p, b8 L' @4 m- Y* p: q* ?6 N1 @( W4 z
window.onresize = new Function("window.location.reload()");/ c: u) k/ j- \
}) N( \. ?! M  ~
) D' @) N# K* q" o
</script>

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