返回列表 发帖

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

<style type="text/css">+ U+ C' I' l3 X. u# l6 b
#supertext {
7 w! a2 L& k( O1 |1 Q8 _, L( X& \( jposition:absolute;: A7 U& k: r4 N, h
left:0;9 o; F  J( p1 Q
top:0;& U  N. u& Y; M* _) U
visibility:hide;8 J4 D1 M8 h) `& C! T" E$ ~
visibility:hidden;
3 u: V4 m! z7 ^6 E. [}
+ Q3 P& \- Z5 m3 c, Q+ [</style>/ N1 x9 d$ T! I+ ^! i1 s, s: ~8 }
<script language="JavaScript1.2">  k; m4 S4 p9 d
<!-- 改变下的字体的大小。颜色-->
) S* u; }; B7 zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
+ J/ O2 c' L% q: cvar hidetimer='';
0 ]7 R( V/ M2 v  U3 Q% }$ e<!-- 改变下的弹跳速度-->$ b, y2 }0 E! W% X
var BallSpeed = 20;
0 W) B, V$ ~, F8 A9 y! n# Y/ tvar contentWidth;. N. b2 U. t0 U4 `! B
var contentHeight;
7 I7 Q( n. I4 X" O/ s6 f* ]) Gvar maxBallSpeed = 50;! c( C; r5 B9 `5 M
" w  L, p" z" @$ r% x
% H) |- A- U  v+ b
var xMax;1 o* ~% L4 n. O8 ]5 v0 m- j: W
var yMax;) h4 V% n+ ~: ~( W
var xPos = 0;6 A7 n) _( P% r! Q
var yPos = 0;8 h! k$ P# m, H3 E! @5 P
var xDir = 'right';
* H) n0 g" H1 }, n6 wvar yDir = 'down';: P  d3 e: D( t0 f( I9 p, |$ s
var superballRunning = true;$ c0 Z  V) ?" x2 p* t
var tempBallSpeed;
* }0 i; |# W) m# }3 E5 _# zvar currentBallSrc;
; `* d6 J% V7 e# c! \var newXDir;/ A/ u+ ^) U. r- w* t
var newYDir;: R% ?5 h  x, Y( v5 ]2 G2 p

% L- ^- R0 ]4 `5 o! p6 ~function initializeBall() {
- C# a9 \4 a0 \) A$ a   if (document.all) {
  k% G& u8 w4 T, i$ N: R' e4 \      xMax = document.body.clientWidth% D( N" T9 K/ C/ |7 ?& v# n7 d
      yMax = document.body.clientHeight
- |4 w( H4 \4 {$ u" e      document.all("supertext").style.visibility = "visible";
" F* P% o5 Z) _) _) [/ b      contentWidth=supertext.offsetWidth
1 i" X) e3 t7 T3 i* m      contentHeight=supertext.offsetHeight# S: ?7 `% d* O
      }" y8 y0 L4 _: S" m3 R) H, C# C
   else if (document.layers) {
, n& W2 ^2 X% B7 _1 \      xMax = window.innerWidth;1 @" U! N9 j' Y) D0 L
      yMax = window.innerHeight;
; p4 w) Y( s1 f; g7 h      contentWidth=document.supertext.document.width
! w% w( G) t; F      contentHeight=document.supertext.document.height
5 V. u- E& L9 A) \      document.layers["supertext"].visibility = "show";
6 _/ N8 c7 K( h      }4 i) a/ M0 L4 [, z
   setTimeout('moveBall()',400);
8 z4 T" q( W- ~   if (hidetimer!='')& |8 {" y5 Q1 J" R/ ]
   setTimeout("hidetext()",hidetimer)
# z0 M* B7 u% `   }
- P# b- H! U( J4 f
2 W' V2 F0 e6 L/ G3 ufunction moveBall() {
$ b! G& G, p- _. q! h+ @, [& X/ w   if (superballRunning == true) {! e) j  a6 M; H+ o: }# b9 _/ w; Q4 |; F
      calculatePosition();
# a0 o! I4 i3 \5 o1 ^      if (document.all) {3 X, F# F8 U% z3 F
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ J, I8 u0 {0 I) b         document.all("supertext").style.top = yPos + document.body.scrollTop;9 \1 t! K; A/ U% `, m- F# D; i8 V
         }4 ^5 o' R& p5 x
      else if (document.layers) {8 t5 m- J" p( {/ K8 N- _7 {
         document.layers["supertext"].left = xPos + pageXOffset;
  q* o+ O+ V- ]3 r- m5 [         document.layers["supertext"].top = yPos + pageYOffset;4 L4 |3 @8 J; c
         }
. z4 ?& n- ?; U9 b) a) `      animatetext=setTimeout('moveBall()',20);! e0 n' o0 N8 \/ P
      }* M7 K1 z2 J8 Q7 o8 t' s3 b
   }% G7 W/ H$ O/ o! H

* n* ?% m# |9 D, gfunction calculatePosition() {: d$ `4 @+ P- n# J0 h! E1 b* ~
   if (xDir == "right") {
7 V) ~" I3 U0 u/ s# d* r+ d2 Q      if (xPos > (xMax - contentWidth - BallSpeed)) {
2 `2 X; n# g0 P9 E; n         xDir = "left";7 |. c3 _; ?) `
         }
& p$ {- e* A  [' p6 j& ^/ J      }
" P/ ?' ^/ ?& k1 t$ A2 j& M   else if (xDir == "left") {0 x* _# @+ {3 w0 ?+ w
      if (xPos < (0 + BallSpeed)) {- A* Q: O* a% l% Z" B6 t  a7 k
         xDir = "right";7 b! S. j( ?% ^% Z- l
         }1 `! ?! {, [/ j' t
      }
) T$ p8 _; W' c   if (yDir == "down") {# R3 U9 g$ @3 q
      if (yPos > (yMax - contentHeight - BallSpeed)) {
' c! H6 _: t4 i* D- X         yDir = "up";
* s1 Z/ t8 m; u1 ~, v$ S2 k7 b# V         }$ t9 d2 v1 o7 D. q
      }# f7 K3 t4 Q. J+ [/ K
   else if (yDir == "up") {
' }$ @  K4 C. W9 \6 d      if (yPos < (0 + BallSpeed)) {
4 ]# H$ H* J9 T         yDir = "down";/ i7 y  u3 n/ c- f6 O# e
         }/ G/ o, J4 l, P8 V
      }& j* Z$ G4 N0 W6 a; e8 l
   if (xDir == "right") {
+ S" L" ~. Q* d4 {% {0 l      xPos = xPos + BallSpeed;: S3 ^- d* `+ O2 n. Q5 W
      }
$ N, l6 ^6 ~6 [0 c& r2 H' q, Q- r, y   else if (xDir == "left") {. L9 {7 `# M( b/ F5 r
      xPos = xPos - BallSpeed;( C& m  r$ b/ X/ n- p7 v6 s$ W1 ^9 {
      }% `* q/ j$ H( H# d6 [
   else {& w7 W9 w: [. [% }) }6 f
      xPos = xPos;
8 @5 U" a1 u( y. `      }
  t1 ^- x5 b6 U& P: r   if (yDir == "down") {. I& _5 ~; C: B0 ~5 c, H
      yPos = yPos + BallSpeed;
! Y* P$ q$ j3 a7 ]8 ?      }
2 |# `# B4 q# V4 Y  U# ~: ~: V   else if (yDir == "up") {
4 n( E& X( M# f7 r" A+ h$ w0 r      yPos = yPos - BallSpeed;; X" o" m% X5 K: a  b! n
      }
5 [% R. b. n2 D1 Q  s8 e   else {" L# i, J) {* t( G1 K
      yPos = yPos;
3 M/ y, ]2 z" c      }
# `+ O! I& n- T   }
2 k& z) L% I4 p! \
% F& C' X$ x( [6 {/ i, cfunction hidetext(){
2 r. Y+ U" k3 G: o* C9 A* I+ hif (document.all)! i, `% v2 D9 N" d5 V, t' n
supertext.style.visibility="hidden"
& i* i8 _, G2 I$ ?  o# Telse if (document.layers)% A: T+ J- I1 h7 f+ ^
document.supertext.visibility="hide"# \3 u9 C& a( Z8 V" C
clearTimeout(animatetext)
* ?  H3 [* |/ m% n}
" K1 L6 M) u$ L& z6 z, r
# k0 \. I- t$ `6 F+ {if (document.all||document.layers){9 }) T& w! h! H( g# h
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 }4 `; V7 N/ a# Gwindow.onload = initializeBall;3 o- Q6 k) _% i8 [9 @
window.onresize = new Function("window.location.reload()");
3 {& A  {/ X& Q}& Y, a& V7 _1 B; a, f% V2 c

" ?1 V6 r0 A# S2 q: f4 ?* `1 N7 f( J</script>

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