返回列表 发帖

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

<style type="text/css"># m9 \5 Q' `, t8 O  ]) _
#supertext {; h9 a* `1 ^6 A; h, E
position:absolute;
! S) L& ?' q5 l5 |6 u; Z8 Aleft:0;
. k( S* T2 i/ s: ^0 R+ otop:0;
* [3 k2 q* o  Dvisibility:hide;8 ~: x2 a+ @4 E# e& B% `( F" o
visibility:hidden;8 C! k% T) ~9 C6 K/ \0 s- E
}$ K* ]; L3 H2 a& }
</style>0 m5 ?) ]  U! _4 a
<script language="JavaScript1.2">  a$ v* `1 i' P+ g' I+ b1 q2 ?
<!-- 改变下的字体的大小。颜色-->9 C7 z# s, b: c2 b. y2 M* @" w
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 N, d, }3 ^% q& B* n( uvar hidetimer='';
% L+ ?  p" |2 Q9 E% Q( S3 K<!-- 改变下的弹跳速度-->4 ~* `& ~# y8 G9 z) g+ K
var BallSpeed = 20;- R3 e. ^3 F3 G4 g! w: A' F
var contentWidth;. o3 J' [. W' l
var contentHeight;1 [, {/ e' h- c/ h, @9 w  D! T& R
var maxBallSpeed = 50;4 g; j% N$ `; B2 e0 B* T- a# r& d$ h
4 K# H7 h1 b' |2 k8 j

/ w* N6 S% f* z8 F9 K7 xvar xMax;5 c9 ^1 t7 Z4 _; ^: D: R2 F
var yMax;
- n- ?" E, r3 x# Y' n0 g- A! y2 I; \var xPos = 0;& K/ b7 X( _  e4 A# o
var yPos = 0;5 l( |( o( W9 T4 z0 V* U1 r
var xDir = 'right';
" i& X) q* m; o) M! n0 xvar yDir = 'down';! ?' M/ _: ~  X; L$ W- b6 e/ H
var superballRunning = true;
( {5 [0 ]  v* z; c8 a; }var tempBallSpeed;
2 s2 T) I( `0 ~9 L' M" H# Fvar currentBallSrc;/ ~  p, n% [; i+ l0 h
var newXDir;6 W; r+ ^0 u) z# F  U
var newYDir;1 l/ G/ Z3 z5 Q

6 {) Y1 N: ]- t! u9 pfunction initializeBall() {
# }, r0 q# N+ C* P8 S* G9 A1 w. S   if (document.all) {* X& Q7 A+ n  `# Z  I8 V
      xMax = document.body.clientWidth! P; }+ j5 a: P# N
      yMax = document.body.clientHeight
5 v% U- x5 l7 B! E0 A/ D      document.all("supertext").style.visibility = "visible";0 _4 }4 ]5 F: v( I7 v8 |5 P
      contentWidth=supertext.offsetWidth
( x, S1 w, z, @0 r7 i6 _2 I      contentHeight=supertext.offsetHeight
5 Y$ g8 Z+ P+ m& h) \  Y      }
& D  q( }& d( `4 Q* e   else if (document.layers) {
/ d9 \  {* L, R+ i      xMax = window.innerWidth;
2 L( F8 j$ L  x( u+ U% D; {% n      yMax = window.innerHeight;
& X  i4 G2 o+ H5 t# h      contentWidth=document.supertext.document.width
* _2 f6 G( ]( ~      contentHeight=document.supertext.document.height& k4 a  h4 C# F9 |' i3 L+ M. C0 z3 {
      document.layers["supertext"].visibility = "show";
) e0 S) `. K7 W; H- C/ h      }
) ]7 e  E/ y7 X% @! m1 Z/ x/ j7 H   setTimeout('moveBall()',400);5 }, G% ^; N1 z9 A6 V
   if (hidetimer!='')
7 ^2 v! k0 W: @  z8 p   setTimeout("hidetext()",hidetimer)
; I/ n- q  ~' r: M# t! r   }+ k$ c9 d) @6 H0 L, i

$ C& m3 q3 n. i* x4 c% p: yfunction moveBall() {  g% h& \# `: @, F% i
   if (superballRunning == true) {
- B+ Y& V. U; \: V      calculatePosition();* ^& N7 G% c; B6 K+ U' k
      if (document.all) {
- x' B7 X  F9 g         document.all("supertext").style.left = xPos + document.body.scrollLeft;
  _8 l; H' R5 e9 X& a' o         document.all("supertext").style.top = yPos + document.body.scrollTop;
" o+ R( r; g% M7 r+ C) ?! ^8 I- m         }2 p7 f  c8 ?+ X7 a* w
      else if (document.layers) {
/ `2 ?3 n2 {1 k) a" u4 t/ [         document.layers["supertext"].left = xPos + pageXOffset;
& B* I! j, Y4 Z% q7 Y& i- c! y4 I( }1 c         document.layers["supertext"].top = yPos + pageYOffset;0 Z: ]8 @# L8 p- |' I
         }
$ d" k* H' `, y1 ?      animatetext=setTimeout('moveBall()',20);
9 y8 C5 x6 k; o  @      }/ J3 q4 F2 d) H+ \& r  \9 w% e
   }% I/ g  Z/ B, i; M8 M
/ s3 ~4 {( \9 \/ m( \8 _
function calculatePosition() {
$ L% P" \6 T. i% O: b  `   if (xDir == "right") {, F  i' @9 {7 A
      if (xPos > (xMax - contentWidth - BallSpeed)) {' r7 N8 w8 P0 T- b. d6 H* l
         xDir = "left";/ _9 H2 l  I$ V$ j  k5 c" C
         }
& m- k+ ?* s5 |/ d      }1 i& Z7 E0 {- e4 s  o
   else if (xDir == "left") {
6 Q6 Y+ ^8 R% U5 E. q, g* J' q      if (xPos < (0 + BallSpeed)) {
& B. r% o: y' E* h         xDir = "right";/ o: M- m( \+ f& c! H) b4 v4 Z
         }
6 i( l5 V, h! L* {) L' c      }
7 v, I: B" v3 E2 a" s! A6 K   if (yDir == "down") {
, b' T2 q0 F& I9 Y# ^- b9 x      if (yPos > (yMax - contentHeight - BallSpeed)) {
2 ^1 p5 g/ S: B         yDir = "up";+ Q" i0 Q) }6 A& F) X& h
         }4 O  z/ G" l% U; Q( Z9 `
      }
' q- \, d/ W5 ~% p" M* V- v   else if (yDir == "up") {
1 d1 |6 w" |5 L6 z: I0 g. L      if (yPos < (0 + BallSpeed)) {, W2 _$ [) ^5 S" [- p
         yDir = "down";
- S& \/ k" ]' V/ _7 f# U1 c: ~         }/ c# M" Z/ s4 j. v. Y1 \! _: U3 R' r
      }
6 Z  Q- P, m: I   if (xDir == "right") {
# C4 _" a2 h; H/ e" ]4 s      xPos = xPos + BallSpeed;+ ?8 f& H3 _- H  u3 R& |
      }
. w4 d$ T: G6 U8 g% I, W   else if (xDir == "left") {) {+ Z! X) `) m/ p6 [
      xPos = xPos - BallSpeed;
* m1 R! v5 Z6 W6 \( Y+ c3 _" |      }( J' Y. L0 M  x* z
   else {. c) j( e# d) H# F, l
      xPos = xPos;
" ^& d- f/ r( b/ l      }
# t* w3 `7 u0 r& r& y* f   if (yDir == "down") {4 V7 n: ^- N8 s0 T* h+ d
      yPos = yPos + BallSpeed;
" x" @1 G4 X1 \# P  o      }+ C# r& j# e5 n" J1 n- N+ E$ V( k
   else if (yDir == "up") {
) A4 [, C/ k6 ~% U3 g5 U; q      yPos = yPos - BallSpeed;5 m+ \/ p3 P7 u
      }
/ J5 L# I8 w: _   else {
% }2 W8 [% v" p, a" G; M6 V: n      yPos = yPos;
; m$ A* q0 ?- H2 B& ?; G: V      }
% \1 E* k' W% m" l* i* X2 C: y   }
7 W" Z- N( W8 b1 z' P8 ]# G% P* C$ E8 q$ M2 m. d* C
function hidetext(){
5 I! \8 p7 y) x% ]/ \' xif (document.all)9 G. E' B- ^% V+ _$ Y. u$ f
supertext.style.visibility="hidden"! L& D: `, T5 v; n* `+ b
else if (document.layers)
, \. L, V" C: ?" f5 F. C$ k2 U1 y5 n7 Pdocument.supertext.visibility="hide"& x- S8 k) c6 q, w- C0 g! d
clearTimeout(animatetext)1 n: n3 O, ~. \+ U2 M( t
}
8 I: Q' i. v5 ~% ^' |8 J1 n$ s5 h( ]1 d
if (document.all||document.layers){% d0 g/ s2 R( ?% T; X! o6 a4 ~6 u1 I
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ |) K+ R3 m+ r7 e# Y+ T" T. K1 u* b
window.onload = initializeBall;, A/ d. m$ g- d& D7 M! h' q
window.onresize = new Function("window.location.reload()");" z! v) A9 ~3 l, {$ e% s" R% @' v) J! g
}
( U' P! W& n" S6 u' L
" g# i  |5 G" H3 |$ D: ~" n</script>

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