返回列表 发帖

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

<style type="text/css">) j) V' ?# H: A! c2 B
#supertext {
; S' D9 N2 g9 ~# a' g' K- p+ }position:absolute;
% e& ~' y$ V5 r2 fleft:0;
8 J6 m8 s1 h1 D# Ztop:0;
% }. l  x* Y7 W1 m! F' Cvisibility:hide;
6 }. j& R, l+ ~6 P' S, ~visibility:hidden;
6 Y: i  c( d" s& N}( L4 v! r  e5 i" |1 S. X6 A
</style>
% ~/ v! t! N: A( f8 U) H<script language="JavaScript1.2">4 I/ ?1 F$ G& I% C& F% N6 i; V
<!-- 改变下的字体的大小。颜色-->
  k$ L6 X& ]$ J7 T' {9 Avar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' {* T4 e! ^. A0 Ivar hidetimer='';
! S4 L1 G0 V9 q) `<!-- 改变下的弹跳速度-->
0 Q/ g+ @2 ^2 v% y7 C0 ?5 {! a! Rvar BallSpeed = 20;
; z% w% ?; ]7 Nvar contentWidth;8 g2 p  b) \- T0 A! L
var contentHeight;. Q2 }$ x0 {( L0 [0 S' z
var maxBallSpeed = 50;
  R& H4 \2 h. k) t
& [) y- Q, b1 n4 f: d( u
  t6 E; @- \8 @+ Q1 hvar xMax;
8 m) S# i# i! mvar yMax;
- V6 G7 r0 i7 {: N$ S! Evar xPos = 0;* t* ]9 Z& g5 L* l. ^- q
var yPos = 0;$ H. ^) a; H( V, r* F3 L
var xDir = 'right';7 g, k% e% }: R- P
var yDir = 'down';
! v; L# Z; B0 D* cvar superballRunning = true;; R0 d) m: m7 u7 H! v( {2 l0 J
var tempBallSpeed;. _9 A. y, v, n1 H; y% n! f( Z
var currentBallSrc;; m0 m' ]& b2 T: v7 U3 D1 U, F" [
var newXDir;
& z' y  Y! R2 q) d5 J) _+ ^1 \var newYDir;
' C3 ~* _4 n) p8 x7 k% R$ _& }: e, G9 l0 p4 c
function initializeBall() {
! i9 c3 H! e1 z3 r   if (document.all) {
( q- L9 T1 m3 ?- T      xMax = document.body.clientWidth6 y* t. l) ]! ]: ]3 L
      yMax = document.body.clientHeight
: R/ u  E! p9 h# Q8 N, v      document.all("supertext").style.visibility = "visible";/ K3 K* \8 W( c3 O. T
      contentWidth=supertext.offsetWidth+ w4 N- k7 W, k4 Q9 q1 K0 B5 @) `( {
      contentHeight=supertext.offsetHeight
$ r/ z  A. a/ h% T# Q: ]. U      }2 z5 N+ X) r7 F7 S1 V! G$ `
   else if (document.layers) {  k1 d( O; z; S- h$ V% M3 x3 D# j: \
      xMax = window.innerWidth;
) Z" S7 [9 F! g$ I      yMax = window.innerHeight;# D: F+ Q6 a) \- @# a1 N
      contentWidth=document.supertext.document.width
; C; G+ W7 T) L5 a      contentHeight=document.supertext.document.height
) @! E" z) q2 C5 \8 r      document.layers["supertext"].visibility = "show";" d" S: D5 |! ?
      }
  g+ I  N/ u$ g2 F1 O) Q* Y% ]   setTimeout('moveBall()',400);0 W1 L- h. \; ~
   if (hidetimer!='')& S. T) G- m1 \  U: z# V
   setTimeout("hidetext()",hidetimer)! O# e# o6 z, M7 K. a! b
   }
  V4 ~* j1 g1 j( n) J5 G8 H1 d0 ~- u1 p, V
function moveBall() {
5 u! \3 @2 N  G, a5 k. ^; }, _   if (superballRunning == true) {- |, P, G1 f5 D+ S6 z, x1 [
      calculatePosition();
. h" S; {2 g$ \# q      if (document.all) {
) j# k, ~& y" G8 I         document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 w5 B) ^; E0 \, B+ `* A6 Q" l7 u3 F         document.all("supertext").style.top = yPos + document.body.scrollTop;
( W  F/ x0 u0 l; [' \         }
& J! B8 u8 z( V0 D: X: A      else if (document.layers) {. d% m6 I  N/ s5 W9 @! }3 {
         document.layers["supertext"].left = xPos + pageXOffset;
2 g3 h' W" z5 m) P% }( m         document.layers["supertext"].top = yPos + pageYOffset;1 F9 n0 @& i3 `1 [# @: I
         }
; i5 E& P$ O  R! U# K% Q      animatetext=setTimeout('moveBall()',20);
" @% h, ]# _3 p3 @  x+ \5 v      }. [* B8 O# X0 F5 G/ j
   }
5 E8 J5 i9 V! V& R4 O3 X$ `' O
0 x6 r  D+ m( |- jfunction calculatePosition() {: E; U. m7 B* a' X& k2 z2 B  g+ a
   if (xDir == "right") {
/ J$ q9 {% U0 u$ N- F+ z; B( L      if (xPos > (xMax - contentWidth - BallSpeed)) {8 g3 g  N% w" K2 x. L+ D
         xDir = "left";4 ^, L  L) u1 z  b1 i
         }
# L$ v. |, l# l  f' i7 N      }
; c* M* K2 G5 q. C, w$ C   else if (xDir == "left") {
9 x5 L" O6 L' E- u9 [) v8 O      if (xPos < (0 + BallSpeed)) {
& l% s: A  I1 l7 ~- t5 C! a% C         xDir = "right";9 u7 w* e! c/ a# T1 k
         }3 c# p' ^. f4 a$ b" G, ]
      }/ S, l9 [* g" X! f7 P% N- M
   if (yDir == "down") {9 J! k6 w* k8 E' s% b7 I3 k. c
      if (yPos > (yMax - contentHeight - BallSpeed)) {6 A8 P* i" a; f; I+ t
         yDir = "up";
! i% c$ ]7 E/ z7 Y! O9 u/ z. Z' z7 I         }7 ~6 n  Q, W3 n# |- |$ c
      }% F2 l, x/ \& X! O) q. Y# N0 R% \
   else if (yDir == "up") {$ v! o: D' x- b; ~9 O' ^8 r. {
      if (yPos < (0 + BallSpeed)) {0 R9 C, W( ]) s
         yDir = "down";
3 p5 ~0 S4 _, v( N4 a- Q         }* r7 a5 m$ M* c& J4 H# N
      }
9 r3 W5 x' k1 Y6 M6 |& H/ X" V% L# J   if (xDir == "right") {
' G5 R. j% O" D+ S8 e      xPos = xPos + BallSpeed;
1 ]4 V# _8 v0 X      }9 f& a: z" Y5 k6 A7 x5 ?
   else if (xDir == "left") {$ P8 v' i+ c! _' L
      xPos = xPos - BallSpeed;  `( S2 g' m+ z% N: M
      }
6 U# L+ C- B! x4 j/ B+ T   else {, w) i6 q5 f4 u' k* H2 p
      xPos = xPos;. b8 H" O1 g8 G1 ?& Q8 \" f( K
      }& a) @& V$ H, k/ R* P
   if (yDir == "down") {" Y3 K' y9 d% c' U& u7 @/ ?0 B
      yPos = yPos + BallSpeed;
" a, O5 u" ?, r2 T  ?. e- e$ ?      }. h0 V2 w* p  t! C
   else if (yDir == "up") {
- V6 o* _- M! z& b4 D$ D2 e) v- i      yPos = yPos - BallSpeed;
5 O1 h# P* `* b  Z      }) h. [/ E; W6 _  @3 P
   else {& ]6 w% z5 \1 x3 x, }. |6 ~
      yPos = yPos;; _+ m0 k' ?+ c* S
      }
% z3 l" f8 i; ^- E& B   }7 A7 e6 f" o( {& @' v

( v1 H" \6 I  V1 _function hidetext(){
- S9 O5 K; o3 U" aif (document.all)
# ?2 i* |( L3 A4 r; l! ysupertext.style.visibility="hidden"7 y. W0 l  w0 i& i- V0 g
else if (document.layers)/ X2 B$ C* a" s6 G$ L$ E( p
document.supertext.visibility="hide"# y, h% z/ t; f, g% {9 @$ N. R. C
clearTimeout(animatetext)7 V* i, J5 N, |8 m2 i  ^/ Y
}6 x6 k4 a+ [2 e# o9 Q

) a; ~/ \) z, Hif (document.all||document.layers){% X* ]+ {! q5 q. h: J/ N" H
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 G3 v; x$ X1 h/ @, W! \window.onload = initializeBall;9 @/ f  P" L, [8 M3 q$ G. n( Q
window.onresize = new Function("window.location.reload()");# t& ^# B! U5 G7 s( _/ g
}
" k9 s  _0 h0 V9 F8 G
, Q9 ^6 N' n* Y0 w</script>

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