返回列表 发帖

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

<style type="text/css">9 K0 N+ M% Y& l  d0 n
#supertext {3 j% L3 w0 d8 d5 H; e6 B/ ?
position:absolute;
5 g/ {/ k" p6 c# mleft:0;
+ ]) \( w# U" q. ~top:0;
4 Z0 z3 s8 X, r5 {* D& d# j# ovisibility:hide;
% C5 ^# h. B% M; J6 u$ [visibility:hidden;
# Z/ r0 b* f5 j}/ }* P0 N0 q7 ~: ^9 |
</style>7 P8 q& y; ?& e
<script language="JavaScript1.2"># s+ P9 z9 A+ T# ]) p8 C8 m
<!-- 改变下的字体的大小。颜色-->
$ w8 d8 l/ O; U% i1 qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
& E; w2 _! K2 vvar hidetimer='';1 O2 I+ d1 h6 b5 ?' U+ g
<!-- 改变下的弹跳速度-->
3 D) q/ V, g. v8 O: Fvar BallSpeed = 20;, D  l4 N8 T) b9 N, d% U/ b
var contentWidth;
  V" s1 e- _: n6 B" s0 V4 Pvar contentHeight;
- `6 {0 o* u& ?var maxBallSpeed = 50;
/ s0 j% L8 G/ f: H7 @1 G/ V( W* ~3 r8 ~/ J; }% u; A3 j
3 c* }* y3 r; S
var xMax;
' h- Y# E# O/ L0 }# a, hvar yMax;
. v' @% X  A& cvar xPos = 0;
' y8 M# T" F; O& ^var yPos = 0;, Y) v$ M7 l3 R7 J3 }
var xDir = 'right';
- Z. x# l- u, v" y3 L# {, E* ~var yDir = 'down';
% T; o) ?) J7 G) e3 k, I. L+ xvar superballRunning = true;/ Y8 p" j5 ~, m0 Z
var tempBallSpeed;/ O( v' A1 T5 D/ O6 Y- h
var currentBallSrc;/ I2 f/ }# I9 s
var newXDir;
& H: i/ V8 k. t& c8 K, U: v- Xvar newYDir;$ [7 e6 K9 r3 W: h. }* Y& U6 g2 t

  @( Q9 t# W# q, d, M9 Tfunction initializeBall() {5 P4 r6 V3 `( h. A0 b
   if (document.all) {; c% P7 T- K1 h& W& @/ Y
      xMax = document.body.clientWidth
; v9 Z. e2 ^2 T$ x2 B      yMax = document.body.clientHeight
$ H' L1 K- K& O      document.all("supertext").style.visibility = "visible";
- r1 o% y. B" X4 s! s5 W      contentWidth=supertext.offsetWidth
  C0 n" ^+ g5 f& I% U# D9 f      contentHeight=supertext.offsetHeight# K& O( z" e/ Z& n% _' W$ X3 M
      }8 M8 ]( e$ O. o
   else if (document.layers) {
4 c& R- ]# T- W! u0 m: {      xMax = window.innerWidth;
) M4 q& D7 B& Y* |% |      yMax = window.innerHeight;3 K$ P, d/ w+ N  B  e+ @* M' z6 r
      contentWidth=document.supertext.document.width& y7 ^9 {1 \, A& z! k! |: F
      contentHeight=document.supertext.document.height' [: J7 Q  e( g# O4 c$ ~
      document.layers["supertext"].visibility = "show";! v' G# [+ n5 B* E
      }
$ S* ?0 O% q) G   setTimeout('moveBall()',400);
2 ^) U) d' x/ J, L$ k   if (hidetimer!='')6 l, h% w; _- j1 A
   setTimeout("hidetext()",hidetimer)& d7 D) ]( ^3 P: F: F7 W
   }0 U: R/ U+ |: e$ |4 h- Q
4 N/ r! L2 e. w: a- m) X( w; x
function moveBall() {6 c; i1 Y1 n, X* H$ T
   if (superballRunning == true) {
6 S" M6 T0 L8 @+ t- t+ y4 ~      calculatePosition();
- M. t4 v# L& U  u& k$ d      if (document.all) {, a! M) u3 i& w/ F8 ~$ y- G) A
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. e: c$ b( R0 b# w8 [! z4 O% r$ a9 v         document.all("supertext").style.top = yPos + document.body.scrollTop;
6 V) S9 T5 w7 |8 s& d         }" A2 `( V; }6 i* C7 F3 M3 c
      else if (document.layers) {
# U" h7 k3 R4 N2 }: r3 X         document.layers["supertext"].left = xPos + pageXOffset;
" W7 \, p  s+ [         document.layers["supertext"].top = yPos + pageYOffset;
9 {2 ]  X  ]) N9 S" i         }
+ Z& d( u6 U- T. `5 r. _* x      animatetext=setTimeout('moveBall()',20);1 S2 X; i8 l+ V1 M& X9 d8 {' r
      }
7 \) J* a/ h- [2 l: l) W   }
: M* @' Q7 L3 S# P
6 ~( ?2 l/ X7 O  S9 Hfunction calculatePosition() {4 ~, Q4 N1 `5 b0 D0 x
   if (xDir == "right") {4 E3 b1 R) h6 i& a# Y- [3 ]
      if (xPos > (xMax - contentWidth - BallSpeed)) {8 j: [0 |% ~& }5 x2 ^! |
         xDir = "left";
0 R4 W' T+ c% Y- p8 G1 V         }' p! m/ ^6 }5 r1 C) m- y4 v, ]
      }
" A0 p9 s% q6 P( G+ N" F- _   else if (xDir == "left") {
8 M; \9 }. |0 C, ]$ X% X      if (xPos < (0 + BallSpeed)) {  O2 m& @9 t9 A8 {+ {7 J( G. C" {
         xDir = "right";
: p6 V6 r: z- E2 E         }
1 O5 |8 Q: d- i1 a& ~) O      }
, u" c1 U# O, K$ e   if (yDir == "down") {
6 ?7 D0 D: w0 \3 w2 L* q      if (yPos > (yMax - contentHeight - BallSpeed)) {4 r2 e$ q" T" f  q
         yDir = "up";4 S2 P3 a, }( t
         }: e4 U8 }+ x4 ^1 \. T
      }( V- F0 E5 ^5 N' f& K
   else if (yDir == "up") {
8 Y; j: V4 B( T* H" o2 I& z      if (yPos < (0 + BallSpeed)) {" K5 [! F. q. T7 {. P  n
         yDir = "down";
% s' y! G0 ^4 J5 o) `         }6 J4 s- g7 W8 _. |
      }
4 \. a7 I5 \, s  |" u" {6 C   if (xDir == "right") {- ?6 l; y3 G: `5 K1 z; E0 i
      xPos = xPos + BallSpeed;
! D% Z$ @. ]7 t  K      }, V5 `: o: i! z: l1 t! A- q
   else if (xDir == "left") {" j% b2 I& [, [9 a& B% c' D) d" F6 d
      xPos = xPos - BallSpeed;
  a2 [8 w8 O# q      }
: Q5 p! _' e/ a8 a, g5 K3 s   else {
3 \5 Y, d6 w' w" m# N% V      xPos = xPos;; z/ c  L1 Y. H  a% N
      }
$ O- f2 Y6 w- ]- h$ V+ Q   if (yDir == "down") {$ @. Q1 [' [' A0 d- v
      yPos = yPos + BallSpeed;
, p0 }5 q" h1 ]: C8 T3 ]      }# i( X* ]0 X  L2 O2 J5 ?1 O
   else if (yDir == "up") {
6 o4 R& r& P. J5 U* B  N: O      yPos = yPos - BallSpeed;4 d* `8 _5 f% a1 B" Y) }: C2 k
      }/ i0 @# H2 F/ h: B  C5 _& F0 h% s1 ~
   else {
& h2 ^: c- m5 U& w      yPos = yPos;
* Y% E+ T, c' U. b$ ]      }
) a5 h$ W' T: m   }7 S/ d; @$ J" d, z

- ?" ~% Q. S: ^6 E8 y5 Ifunction hidetext(){" s! }9 s: u+ o- Y; w' q
if (document.all)! p1 e1 B$ C# u8 D
supertext.style.visibility="hidden"
  G' u. f4 f8 c. [% ]else if (document.layers)8 Q( p3 D0 t# X
document.supertext.visibility="hide"
3 }$ i4 k7 P) @clearTimeout(animatetext)
: R) w3 ~. l8 [0 q}
6 b2 |; [$ R, H% N( L& G$ i4 m9 k* Q5 Y  x7 v6 e7 U. I
if (document.all||document.layers){
3 j3 x/ A  ~0 Z" _% f+ e" f- wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 ^4 o0 @' i4 f( c4 L% N
window.onload = initializeBall;
+ t$ O1 @# g" K/ ywindow.onresize = new Function("window.location.reload()");
4 }6 B4 y# w; |$ a6 J* w}
" R! a3 d6 Z# R8 o: E2 ~0 f
) x  n/ I: ], i& W</script>

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