返回列表 发帖

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

<style type="text/css">
9 n& U9 |, ^! h/ _3 ?#supertext {
! F" ^% n/ o& W( `/ q# R6 X$ zposition:absolute;) `4 U& P6 \1 I5 B% D* R; _0 w
left:0;0 A+ Q) q. y  s1 p
top:0;
, t5 t: q, X/ N# }5 m% p* Jvisibility:hide;
1 N+ l, d) M9 _0 a5 Fvisibility:hidden;( U  d: Q6 r* t+ B. _
}" H' d' d- T6 T. _# G# L1 O( H
</style>  P7 v2 x" q" _& g1 x9 t
<script language="JavaScript1.2">* U* P8 y  ^# y5 e3 [* q5 T+ `
<!-- 改变下的字体的大小。颜色-->5 t' x% h" h( R: \" t
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'4 y6 O) d4 Y5 C1 [$ j: X  z
var hidetimer='';$ e/ j! Q& a, W/ z
<!-- 改变下的弹跳速度-->
; |: b+ b0 n  v( G* e+ Bvar BallSpeed = 20;
9 L% j1 r2 V1 l  ?# Evar contentWidth;
& D  \' i) B" d5 {5 p) k* j0 xvar contentHeight;/ u$ l5 Z2 N7 b7 Y$ D" C0 p/ r# K) J
var maxBallSpeed = 50;
4 A  l! o5 ~0 G. a; V6 ^6 s
/ w8 G& J& Z/ q+ l
9 c) z& ]/ ^( v0 Tvar xMax;) H  T8 \; [( S. Z* @
var yMax;/ }4 k" j) G! S* {7 _
var xPos = 0;$ r, B. i( ?+ k8 j  a/ Y7 y
var yPos = 0;  W+ g; D0 K9 p+ _
var xDir = 'right';
7 H, j2 J% }! U7 P- `" a9 zvar yDir = 'down';7 I' u  y9 R/ |* f
var superballRunning = true;
* h9 y$ J5 O8 dvar tempBallSpeed;
* W# b- h# Y  K: Y! B+ A7 Jvar currentBallSrc;) W& v- E1 Z2 d
var newXDir;
* Y% C% d1 X& ^. V) U! dvar newYDir;
- g0 \6 b3 I: T! O
% G* B8 f! P% d) Bfunction initializeBall() {! M* G" X$ }- O7 K5 A& y3 u/ V$ ^+ I
   if (document.all) {
' Z3 N4 r5 E% p. {      xMax = document.body.clientWidth- x5 `: z& W" Z* @, q& R
      yMax = document.body.clientHeight, C9 e2 m. S/ U. F
      document.all("supertext").style.visibility = "visible";
# M( o) X1 n- q, T      contentWidth=supertext.offsetWidth
, S. B$ _7 O" u% ]4 f. X+ w$ u      contentHeight=supertext.offsetHeight
# T8 p" d" w0 P6 z      }
: c) k4 b+ O" x6 B   else if (document.layers) {
$ r& ]* k: e/ k6 `2 {, k& P      xMax = window.innerWidth;
  T: |# W" H; y* I3 w6 K      yMax = window.innerHeight;
  [  r, [9 ~& s$ ?      contentWidth=document.supertext.document.width1 ]- L  d8 ^$ l! Q+ l
      contentHeight=document.supertext.document.height
: g8 f( W0 q+ v- ]5 f      document.layers["supertext"].visibility = "show";
- d% j4 T" E0 T  ^2 n5 O' Y      }+ u) r; e: c" t
   setTimeout('moveBall()',400);
* }: A$ j" t; s! ~6 d   if (hidetimer!='')
" \! l5 j; t" |! c8 z   setTimeout("hidetext()",hidetimer)
" b4 C1 ~5 p& ~+ m   }
9 D& c  X+ x& S& s6 R% G$ x" o! P% b: i1 `
function moveBall() {
0 M# F) U0 ^: N1 F   if (superballRunning == true) {( n1 F: y0 f5 s! U& \" K- Q
      calculatePosition();. ]* b( |3 u' J! d' Z
      if (document.all) {7 v2 w% R3 g9 @# g; a+ Z4 b. O
         document.all("supertext").style.left = xPos + document.body.scrollLeft;; y5 ^: I, {3 W' C
         document.all("supertext").style.top = yPos + document.body.scrollTop;
8 w9 }1 l4 Y3 `$ B5 I. @2 v2 |) S         }
4 G. c( [9 m) U. p      else if (document.layers) {1 |7 l6 ?$ l3 P% Z! P
         document.layers["supertext"].left = xPos + pageXOffset;
; N7 e& w+ {% U* D' ^0 ?5 g         document.layers["supertext"].top = yPos + pageYOffset;* q0 ~6 {  g5 t! ]' n* r& `
         }5 V" A3 U; _$ z: p! X6 E- }. k
      animatetext=setTimeout('moveBall()',20);
! `. Y) f$ ~# D8 d      }8 S: w( m% u6 x6 c* }% w  t
   }+ o$ I7 i6 j5 F0 X. J7 N% g9 `  ?

7 Y) m0 a% [" p9 Z( t& j+ o1 G6 yfunction calculatePosition() {
; I, v5 K& c/ _   if (xDir == "right") {
1 I5 @$ e0 `4 |      if (xPos > (xMax - contentWidth - BallSpeed)) {( e9 `6 K- U. d$ t
         xDir = "left";5 U% u# {! [2 b$ }
         }
) N: ]2 {1 A4 D! C; t# [; k      }1 {! i0 N7 z* h9 K& q% L
   else if (xDir == "left") {+ X' \( X3 `1 Y! D* i8 e9 {8 k: l7 T" v
      if (xPos < (0 + BallSpeed)) {4 C( D9 W) Y* k% m
         xDir = "right";, r; F! y; r7 w; T! Y7 Y' ?5 v
         }2 z$ C; u- W% x* H7 M- n1 ?
      }" W6 E2 h9 k8 o
   if (yDir == "down") {8 V  Q' L! L) A3 X$ _- U
      if (yPos > (yMax - contentHeight - BallSpeed)) {: L) M) V* `5 a9 O3 d$ E  y
         yDir = "up";
5 P' Z! m! S4 h# n& h$ x) }         }! J0 b8 C0 g2 L  y( L4 q6 Z" T" f
      }' z) y7 u7 m: A% l& E+ v
   else if (yDir == "up") {
( p3 k. i0 i$ f      if (yPos < (0 + BallSpeed)) {& M& F! Q) \% Z0 Q6 L
         yDir = "down";; Z) l* r0 X* _* O6 J, k1 K
         }
* Q- k) x7 s3 n( {5 P  x      }
; y+ e6 G) G) E6 ~1 ]- ]   if (xDir == "right") {
9 i7 \+ Q/ t+ n      xPos = xPos + BallSpeed;
* }3 C9 w* r; J' Q* U5 s- [8 E$ O+ e      }
" y; [" \' _- W2 C8 _   else if (xDir == "left") {" B/ W7 _8 T  O, \/ e  {
      xPos = xPos - BallSpeed;+ S# ^) d# M3 L5 b
      }
+ m9 t. K& U  Y   else {" E1 _& l' D0 S0 K
      xPos = xPos;7 S9 C1 C/ P) b. _* U& {4 l
      }' Z0 \: }5 I; q" w
   if (yDir == "down") {9 ]6 r& M8 p1 r8 i1 O- w
      yPos = yPos + BallSpeed;5 M* @* ?9 P# e. C1 y
      }
% n$ {. d. H1 T1 Z. g, u   else if (yDir == "up") {
7 d0 R6 \# C( Y$ Z# I+ w      yPos = yPos - BallSpeed;0 J$ T$ M2 F' w0 r1 u
      }" G' z' A3 ?+ H- T
   else {3 n" i# K) {6 j6 w
      yPos = yPos;- V: h+ W- a- H/ n: i% M# v3 ?! `0 ]
      }
" I* U. w4 h0 K' L: H   }* b/ K. Z7 G" K& Q* I5 v

2 j6 x7 T& A. a! B3 u4 Tfunction hidetext(){
+ X6 ~* H% ]! x/ ^* Q$ Pif (document.all): Q" q' g$ L+ L3 V6 C
supertext.style.visibility="hidden"8 l/ V8 G; |3 a( V: N" @2 T
else if (document.layers), B7 N1 g. Q* R3 m9 Z
document.supertext.visibility="hide"
6 @8 {4 P7 m6 E2 R3 Q; H( A7 W$ rclearTimeout(animatetext)& j+ p# Z0 F0 U& k2 d* t
}
; D7 N# `* U+ k0 a' N* S
' L) Z7 F8 P; H+ L( m/ t- oif (document.all||document.layers){  {" t3 l" L) |+ P( e; Z% _
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" i0 t9 b5 |2 e% d. Y! I8 Awindow.onload = initializeBall;. c! c  Z9 G' I. K& n' c8 b
window.onresize = new Function("window.location.reload()");
8 t1 a8 F- i; Z, n8 ]7 F}0 r  O" x: f+ x, E# Z/ `1 l  W* V
9 w. k) g0 n# O; H  K+ o, D
</script>

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