返回列表 发帖

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

<style type="text/css">5 s# V' D& a/ _# M8 }) O
#supertext {
4 y9 P: s4 x* ]  n: qposition:absolute;
( J7 i! D' x2 g# t- Gleft:0;! k  A7 b, `7 r% _5 a; o$ k! C# |
top:0;) ~$ j+ h1 Z, A" b0 W4 @5 G
visibility:hide;
; k6 V/ O+ T. \visibility:hidden;
" H. W9 @( I" A6 i% k9 n. R% E}( b1 w- O8 l( q2 W
</style>
# J; k1 e! V/ q- }, t' E  |<script language="JavaScript1.2">
0 g% u" R. S% U; h. E* o# G5 a/ Q<!-- 改变下的字体的大小。颜色-->
3 W' p/ D: C4 X! V+ j1 C, m, Z) Y  Kvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
/ H5 t+ H8 H3 wvar hidetimer='';% j7 V6 k0 O- t+ b7 z" u1 T' ~4 i% z
<!-- 改变下的弹跳速度-->
4 h+ I0 M& Z) b1 V+ W3 ivar BallSpeed = 20;  d, V2 x: {+ B, d' J2 R
var contentWidth;$ f% L' ~# B6 }  E
var contentHeight;1 F. C$ }# r: @' z
var maxBallSpeed = 50;
& ?* r8 L# K; n* q2 B' S/ e
; I# `/ k) |: P  _
) B" q* C6 G- z$ e+ g0 dvar xMax;
8 l5 U* ^) v& x4 F* |var yMax;* W( o5 G* r% a, Q/ G' @, C9 Q
var xPos = 0;
1 ~: J$ C! @# s% I/ _var yPos = 0;
+ G4 a. d7 }0 Yvar xDir = 'right';
( \2 B8 V. M  l9 P) G# L6 |var yDir = 'down';7 X1 l2 h1 E$ k2 ~* ]2 A- f
var superballRunning = true;  b; H; G' a, p
var tempBallSpeed;; X- j2 G( j1 F$ @& K2 `
var currentBallSrc;
/ |/ `5 S" Q- B% B& ?9 fvar newXDir;
3 H& Y% H) }" n# qvar newYDir;: Z+ Y! s; ]9 r) @1 o0 R3 t$ [5 @' M
1 p& _' N3 x$ a; Y7 L
function initializeBall() {
& {+ Z  d' ]# {5 A$ l3 j' v   if (document.all) {* {( o( l5 {% K2 o/ @6 z. J6 x. _
      xMax = document.body.clientWidth; \, S+ Z; |( O+ D% r* g3 B
      yMax = document.body.clientHeight
/ t! J0 I- I3 @4 `3 N; G      document.all("supertext").style.visibility = "visible";
7 b+ Q* E, M+ E& _2 b2 M8 j      contentWidth=supertext.offsetWidth
& K" f( B# N) z      contentHeight=supertext.offsetHeight
; g! x! U2 m, ?3 i& d      }; v  y! U+ l3 D: R5 d& Y" q5 s  b
   else if (document.layers) {! V6 H6 c, k: |5 B$ k7 w
      xMax = window.innerWidth;9 z  b& `) i0 ~! v
      yMax = window.innerHeight;$ Q" R) ?4 G& q8 U, u7 x
      contentWidth=document.supertext.document.width4 m/ b/ `) W: M  `
      contentHeight=document.supertext.document.height, v0 P0 G/ F/ J# L
      document.layers["supertext"].visibility = "show";
& f* Q6 d( n6 G1 D9 f# D      }$ i7 f4 d; Q; b3 Q' x
   setTimeout('moveBall()',400);
7 ]7 r/ j, K3 |) Z2 L2 }# }6 O4 C   if (hidetimer!='')4 Y8 `/ e' W9 m3 q( o6 ^/ Q4 ^$ O
   setTimeout("hidetext()",hidetimer)' S1 C8 Z  x, W* @, @. w
   }; a7 v9 g0 M) L- |/ z0 h
& r. J% }% q5 V+ E
function moveBall() {
2 ~# J6 f2 {8 r# ?3 S' G) j  c   if (superballRunning == true) {  j2 x3 V: o# K* J1 z- J
      calculatePosition();. _7 o. l* J- W; Q7 Y; _& n
      if (document.all) {; t: i' v% m$ v" F
         document.all("supertext").style.left = xPos + document.body.scrollLeft;. j, l9 \7 f) k3 a4 }* x* W3 R
         document.all("supertext").style.top = yPos + document.body.scrollTop;
3 ~; }' Q- g4 L0 L1 g         }1 g  u4 o9 m7 a
      else if (document.layers) {; P, G0 N9 |4 X; X( r. W
         document.layers["supertext"].left = xPos + pageXOffset;
+ @' T& |: P2 M" ]0 P         document.layers["supertext"].top = yPos + pageYOffset;
6 d# B3 [- }, K         }
& n. [( T0 i# N      animatetext=setTimeout('moveBall()',20);
- [6 _0 t: T. W( e4 i. V+ w/ L! Z      }( l' c' i5 _/ W
   }& a1 L1 q+ Z1 E7 o
3 \( ~7 ^( D; A1 p0 K  T- @
function calculatePosition() {
! e, E" K/ Y5 x1 j$ B) {; u   if (xDir == "right") {5 m# C# P% C9 t7 i/ P, r
      if (xPos > (xMax - contentWidth - BallSpeed)) {, c  F8 ?' P' r" ]+ K) s
         xDir = "left";1 k8 b1 J  T2 s1 K$ p4 f3 R' `
         }
+ S: A: `  G+ u5 t) U( E      }
* v% e- H9 e5 W; P   else if (xDir == "left") {
% r1 g3 s# ^' P0 S; f      if (xPos < (0 + BallSpeed)) {6 y8 k+ j" I# L; `! o$ R9 k
         xDir = "right";2 X" q7 v, V* c" g5 y5 r1 e, D
         }
1 Y: \- Z1 p  }      }
7 g5 D, w5 g, U  x! |   if (yDir == "down") {
; F! B' E- ]/ a7 z. |3 @0 C8 D8 N; P: Y      if (yPos > (yMax - contentHeight - BallSpeed)) {
% k8 P% Y- X$ c         yDir = "up";
. _* Q& v/ f, G5 d         }
5 \  d  F7 b2 C7 @/ `- L      }8 ?4 j% K# z, p& `0 m! b* i
   else if (yDir == "up") {$ q, ^8 O6 ~0 E
      if (yPos < (0 + BallSpeed)) {% K+ g2 w* h7 W3 w5 }3 k; p
         yDir = "down";
9 y! R. U( x' h! w# r3 H         }" c! u9 H( l) b1 `- v  S- T2 Z
      }0 F" s$ E4 t% R1 L' y
   if (xDir == "right") {9 s8 L" a' Q" }" C6 R7 ^, Y2 _+ x, r
      xPos = xPos + BallSpeed;
* H$ P4 d% J# Z/ Q, w6 A      }" Y" Y/ I" O4 d- c
   else if (xDir == "left") {
. Z- \- Z# }2 I# U      xPos = xPos - BallSpeed;
8 d! I8 d/ }5 O8 u' H) Z7 g9 k5 g      }
0 U1 O7 K( w+ G+ |# J6 r4 ~   else {
$ P/ m# T/ p3 P, Q" N6 D1 X9 P      xPos = xPos;7 d1 c" A* d  L
      }
- o/ j; `: A& [& B4 Y" a  E   if (yDir == "down") {/ B) T6 ]& N2 b4 {7 d
      yPos = yPos + BallSpeed;; H" Z; W: \/ Y: ?" C* w
      }1 U- v# p6 Q# g% v. R* p2 |
   else if (yDir == "up") {
! M3 l8 c$ u' R# D) h7 F/ `" T      yPos = yPos - BallSpeed;3 R, w$ C9 ~5 R) b3 B6 ]/ w
      }
4 X9 A6 |) O" M! |   else {% @& R' V4 k5 u" j. ~! c3 f/ Z
      yPos = yPos;" \; n7 Z! D4 e: C, s2 F' e7 u8 X8 R
      }  a: l/ R" Q" N; ?$ C; l6 D4 y( C4 A
   }" {' g# q5 K4 \9 N3 t" k7 J

9 y8 L. W) h4 gfunction hidetext(){
2 k  y1 r0 \: I/ I- a# oif (document.all)3 W) [! W4 x" @; D+ v( {" W! g+ q% G% D
supertext.style.visibility="hidden"' w+ [: {2 ]8 g8 x# H0 ^& s
else if (document.layers)3 V& l2 V6 E0 k- C& n( x0 v
document.supertext.visibility="hide"
4 ?+ ~7 w+ H# c8 q) l* D3 VclearTimeout(animatetext)9 K$ z2 P) N% I+ n% t- V/ s
}9 P/ J) `# d7 k
- J9 s; ^3 Z. G6 f  s
if (document.all||document.layers){/ L1 p6 a! T1 O. ^+ r& Q% @
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')7 R( ^4 I4 ]6 a3 S4 F5 z
window.onload = initializeBall;
6 P# }6 x7 Y5 |# P/ ?window.onresize = new Function("window.location.reload()");6 {& V- C) ^+ C7 _* J1 S
}' W8 z: g$ i$ O2 B
8 S5 g9 ~* G- v3 i7 `' R7 ~/ w
</script>

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