返回列表 发帖

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

<style type="text/css">
. _6 V( u$ ^; x2 p" \#supertext {6 e! B2 X$ x: O' ]0 J! v
position:absolute;# y( c7 Q; J& |5 E/ m3 t* ~$ H  ]
left:0;
& ]5 V( @: r) [0 P" e' D& |7 H: wtop:0;
  E! g0 o9 u3 D# Y* Gvisibility:hide;
' R! E- ?6 ^3 g$ w# y) y1 Lvisibility:hidden;
+ n3 t5 j# M* M; `7 S5 ^& w& [4 t" c}9 l9 m+ k3 d( L7 O/ |
</style>2 ]) L1 Q3 ?* x, v
<script language="JavaScript1.2">
8 J1 D2 Z  O: a) u0 [7 _<!-- 改变下的字体的大小。颜色-->0 ~; J7 A( m+ C1 d& C( _
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 F7 C  m5 D. ~var hidetimer='';
5 i- ^" u; k: y: X& U<!-- 改变下的弹跳速度-->
7 U) D, G( X: E# I1 w$ ^8 o: y7 tvar BallSpeed = 20;+ j3 R' c& a1 c3 }6 ^
var contentWidth;
+ ~  [  t% _; Pvar contentHeight;
0 C; J: H; _4 C$ t* |* ^# X  s$ Kvar maxBallSpeed = 50;
& U# r* R( M# L$ u; V/ C6 C5 }5 J: ~* t

- [# {! F5 N( Fvar xMax;, \9 Y3 a1 m/ U
var yMax;  {; t. v: `' V8 t
var xPos = 0;
% r' g, Z* y' X( evar yPos = 0;
3 i% C7 L0 d7 a5 a# x" vvar xDir = 'right';( H; f- @+ a+ p, j. q4 E% Q9 A
var yDir = 'down';
& U; I6 N5 T8 Yvar superballRunning = true;
) I; M' f& {: i% J. ^% Avar tempBallSpeed;/ P. u+ \  b# [6 |. t0 w: X- H
var currentBallSrc;
, D2 }: o6 B% Q3 ^$ H9 A. Gvar newXDir;
( _: ~3 k; U7 ]' m8 [var newYDir;( B  n- Y* d& U+ l' q3 K  j9 X
- \/ R8 n. U  Q9 Y7 ]& s% K
function initializeBall() {" m( A2 ^# c; n2 F" L' c$ y. [
   if (document.all) {
9 W! h  M: V; ~+ U      xMax = document.body.clientWidth( g* }2 q  Q5 F' h3 J4 p2 G+ W& f
      yMax = document.body.clientHeight7 N9 K8 c/ J  E# m) m8 v# `5 a
      document.all("supertext").style.visibility = "visible";
2 G, ~) q) `. H* ^' U      contentWidth=supertext.offsetWidth
& @% u, H" u  `' C      contentHeight=supertext.offsetHeight
  n' u* d+ |& Q  E9 o/ n; E      }
/ k: s& Q) K) e. d# V   else if (document.layers) {+ J4 V2 a. J7 A
      xMax = window.innerWidth;( L* c( ^# @' o
      yMax = window.innerHeight;& ~% k+ g- Q! X& d" t- A
      contentWidth=document.supertext.document.width7 j' Y% D" O( P% \' w
      contentHeight=document.supertext.document.height7 a1 c3 L* h  P7 O8 C
      document.layers["supertext"].visibility = "show";8 _) l  ^5 \# v9 e
      }
) c" X7 p8 g% ?1 J   setTimeout('moveBall()',400);6 h4 Y, Z& W, _2 [
   if (hidetimer!='')
+ w/ V# w8 {2 k6 g9 w6 E   setTimeout("hidetext()",hidetimer)
, I- b/ t  _% V% f  v   }
1 d  a# e1 w* g8 X; U
- H4 r$ x1 E' |/ f( Afunction moveBall() {7 h0 ]5 E" i* i& P  K) T7 f
   if (superballRunning == true) {; [! C! W7 S& B. }
      calculatePosition();
( `, e$ u3 ~2 Z+ l# P- K. @4 I      if (document.all) {5 f9 b: F; Z$ _' z
         document.all("supertext").style.left = xPos + document.body.scrollLeft;1 |. E: I1 V% ~0 w2 F" H
         document.all("supertext").style.top = yPos + document.body.scrollTop;* u6 W4 ^2 r* {, M$ Y  W) w
         }  R- L  g  w2 k; g  Q7 u
      else if (document.layers) {5 @5 T& S, [" h2 ?$ I1 r% k8 X
         document.layers["supertext"].left = xPos + pageXOffset;8 R% d3 L* |$ x- H
         document.layers["supertext"].top = yPos + pageYOffset;
9 \3 I/ S9 v4 S3 h- N3 m         }
8 H" y$ J& K# P      animatetext=setTimeout('moveBall()',20);7 l2 x! V" m9 @5 G$ B9 C2 [
      }
& L) ~1 ^% z! j" B   }
: j5 v2 W5 t" u3 j  Y4 C5 T1 b% k! n+ b4 M
function calculatePosition() {" E' t2 o) f/ o2 O& r
   if (xDir == "right") {% r' ^8 g/ q8 [; U4 d
      if (xPos > (xMax - contentWidth - BallSpeed)) {* ]& e8 h) H" {
         xDir = "left";
4 M5 U" L# B; E# C% `" s         }
$ m7 S1 K; O: S, H9 ^% Y, d; C      }
/ v6 u7 X+ j6 V' e! b   else if (xDir == "left") {+ d' k3 [* u  i% k5 f) \7 D
      if (xPos < (0 + BallSpeed)) {
$ Z# U8 \+ N7 f$ K9 N$ u) G         xDir = "right";
! p1 A( ?" r$ e% X         }+ U, U5 y; s0 e6 p* m7 o" d" k( Z% `
      }
: b8 c1 F; G( ?& k9 \0 R   if (yDir == "down") {
) H* ]' z0 M3 w  a  {( p      if (yPos > (yMax - contentHeight - BallSpeed)) {
9 k% Z# j. ?4 V+ X; O& a         yDir = "up";8 Q5 |! F5 p5 s1 E# `
         }
5 d! }4 s' q; r' ~7 U4 a      }
/ a; Q! O- p' N( X) F, v! p3 G   else if (yDir == "up") {! p2 M* k: }9 S$ w5 e5 }5 ]
      if (yPos < (0 + BallSpeed)) {
6 Z, G9 o3 t$ v4 ?         yDir = "down";9 g" F0 S5 v, N  M, g
         }+ I0 p: C' ^# U) Q" ?
      }: e+ {7 f8 e( S- X# Q9 C2 `+ K, n9 y
   if (xDir == "right") {
! H& h7 K5 [: v* k3 _1 w      xPos = xPos + BallSpeed;
7 i- `' v3 \) c      }6 m  Z; F6 `' [8 T4 U) m
   else if (xDir == "left") {5 N  o/ k( b2 Z7 |+ e
      xPos = xPos - BallSpeed;
4 q8 B( f7 j7 z: H  s+ g% [( x      }0 M5 I' O/ g' ^, }. Z
   else {
3 [8 A% f, k+ t  E! g      xPos = xPos;7 f- k* B/ C& i
      }* s% o  f; a8 b% C
   if (yDir == "down") {! [8 x' E/ T8 m7 N. G7 i; I1 q& d5 \
      yPos = yPos + BallSpeed;0 o  a0 q2 h: C7 H. Q  T
      }
" i! p# K" z4 m$ i  S' `   else if (yDir == "up") {
) |  K, s% M* E: s6 `      yPos = yPos - BallSpeed;
0 }" H9 I% ], R; V6 V: }      }
4 Q9 J( x" y1 a/ M) q4 j3 i8 T   else {
9 U# h- e1 D% ?- v3 B! Y; f      yPos = yPos;
, y/ t; ]$ Q/ p% p. _      }
8 o6 L- f6 R5 d/ \3 S( b- S   }; G3 _/ Q; ~# i9 j2 G  {' x, Y! D
9 h9 s& s, d5 S
function hidetext(){& v3 P% I4 Y. l
if (document.all)
- ^+ u" B" J, w  _  ?( vsupertext.style.visibility="hidden"
) D0 o; {* Z0 P5 i8 Relse if (document.layers)
+ v) L8 N7 P4 p9 q8 l9 W8 @% rdocument.supertext.visibility="hide"
% c$ g# |- Q( \& bclearTimeout(animatetext)
1 A; m) ?/ ~5 Q5 m8 s5 }}% ~! q/ @( F- J; I9 f. P

. G  r8 {  Q  w, ~if (document.all||document.layers){
% t  Y. O% m5 B" ]( Fdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; U" |- r7 C. _window.onload = initializeBall;7 Y8 Q& M. F6 d
window.onresize = new Function("window.location.reload()");
/ |( ?& j1 M/ i0 p}! k4 [. c' X: `9 U, O2 s
! a. S% L9 M$ z2 Q! q; A
</script>

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