获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">
, r  }2 R$ A) U" C4 b8 R( G#supertext {, v6 `1 A( r7 k( s/ ?3 C/ k. ?
position:absolute;& A- ]6 z( E. ]
left:0;! F3 U+ e8 m% K! S3 x
top:0;% U& {9 ]$ ]/ y' B$ u: I
visibility:hide;
6 a7 |, s9 @' E0 Avisibility:hidden;6 q; @$ O0 C1 u. y2 n" u
}, o3 l. k+ }( B
</style>  k# G- ]# f5 A: a
<script language="JavaScript1.2">* _8 Y# }1 I: y7 e: d
<!-- 改变下的字体的大小。颜色-->
; }# _4 J1 z/ O5 s( Z# X1 xvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'6 b  [: f: i( c0 m
var hidetimer='';( p$ C! p* ~5 Y9 |9 L# D' `
<!-- 改变下的弹跳速度-->
' a7 n/ [( g9 Y( C/ `  ]( g! Pvar BallSpeed = 20;
0 I- W5 x- X3 n# l2 Ivar contentWidth;
2 H) g0 v+ u5 L; S" x' |1 [var contentHeight;
" K; b: F  X5 r; G  O" Vvar maxBallSpeed = 50;
# v. w! |6 C6 o, u, T
6 Z" M4 |( P$ c5 A4 ~5 F$ j' x2 @* G4 W+ X; R1 t8 B) `
var xMax;+ O- D# L! ^, ]
var yMax;. T* ]9 C! _/ v3 U+ T/ Q/ ^
var xPos = 0;# G7 H) R" Y! M& w1 @8 R
var yPos = 0;
3 a" u4 a3 C* T4 G6 j4 ]var xDir = 'right';
. R9 Y5 [1 q! `/ Yvar yDir = 'down';$ z5 x6 U- F: L+ D
var superballRunning = true;! i$ E1 X" K) k. x6 D
var tempBallSpeed;# Y! U  T3 }. w5 D' L
var currentBallSrc;
0 T" L4 u9 ?" s4 F) d% t0 v' Yvar newXDir;' ~7 ~: s- q  E$ C- d
var newYDir;( Q1 \9 w. P: X" m1 ?  E* [# d
$ G# [4 i( E- V
function initializeBall() {% R% _& o+ i, Y9 u/ q+ S  R- V0 B
   if (document.all) {
" _- f' d& D+ Z+ U      xMax = document.body.clientWidth: O$ O/ `- O- D: b5 j3 C+ @. \
      yMax = document.body.clientHeight
' k; Q7 Y! R" g$ r; ~      document.all("supertext").style.visibility = "visible";
2 G$ t5 Y* g+ K. J. P      contentWidth=supertext.offsetWidth
. t! H# z  Q$ S9 }% g2 m      contentHeight=supertext.offsetHeight
' ]! c, }' }- k  [4 L/ H0 u      }0 m0 J& Z* H2 \+ D
   else if (document.layers) {( ^/ v: d3 y4 i# l8 C
      xMax = window.innerWidth;! n) [0 r( \  R
      yMax = window.innerHeight;3 M" o1 S7 o) y5 }
      contentWidth=document.supertext.document.width
+ a0 {) H/ n  b3 y$ r      contentHeight=document.supertext.document.height. K& x7 \# J, u6 P1 j7 e
      document.layers["supertext"].visibility = "show";
" j$ V- T( N" r% M  {0 l/ P      }
) S! H( g& W! P7 n- {; X   setTimeout('moveBall()',400);3 |$ u! J* z0 `' `
   if (hidetimer!='')
& E; o  y5 ?2 W( f# `! J3 J   setTimeout("hidetext()",hidetimer)5 e6 u3 b- C* H9 p
   }7 G/ X' q7 o) w9 `% V
" h( }  }6 ^, u& d$ A" Y
function moveBall() {
; N8 e9 |) i9 A; f9 B( f6 F) d   if (superballRunning == true) {: M, ?# F  C9 ^/ \" y, `' k
      calculatePosition();
$ x. }- |7 ]2 O  y$ [* Z. c) L6 u      if (document.all) {( J* A, }5 `% e/ c
         document.all("supertext").style.left = xPos + document.body.scrollLeft;+ i0 A6 Q; K! h& Q/ j# q
         document.all("supertext").style.top = yPos + document.body.scrollTop;
* I9 L9 t) C0 n( r' I         }8 }& i; L! B% s; J- [7 U
      else if (document.layers) {( `2 a2 k& q3 d$ g9 L6 G
         document.layers["supertext"].left = xPos + pageXOffset;
+ U: @2 _/ U- a# M) p         document.layers["supertext"].top = yPos + pageYOffset;& I+ t7 F3 {7 O- _! n0 h2 X
         }
0 o* `4 p4 t+ d6 J& g      animatetext=setTimeout('moveBall()',20);
+ ]4 U# u, c- w" C6 R* s$ V* g  N      }
* T% F( |% C+ P+ E" R0 t   }
3 ^# Q% I& {5 F1 t0 M: r0 k
7 h. ]9 f* A& n3 p7 d9 X- }/ a1 i% Mfunction calculatePosition() {
# c" m- ^) C- M+ D   if (xDir == "right") {& w% X8 @# C' v/ I
      if (xPos > (xMax - contentWidth - BallSpeed)) {
6 R& b2 n$ L* V0 |' {9 L         xDir = "left";) I" F) |! g3 \4 a: W
         }
! |$ j# n- U2 K; [" T* `8 B: X      }
, i* j5 t9 t3 P$ i+ g5 M6 l   else if (xDir == "left") {2 p  t# M. W  V4 q
      if (xPos < (0 + BallSpeed)) {
% ?6 I8 x* t+ M" U+ Z         xDir = "right";+ y  X# Y2 ^$ F% U/ c" X
         }( O! s$ V! g& u& F0 T
      }
5 D4 B1 o9 N3 l) \" }   if (yDir == "down") {1 F4 Z7 e  m! ]# ^/ y
      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ ~4 g: V. H/ ^8 p* ?         yDir = "up";
+ L' j  L2 k) L         }
1 _; z. F/ E8 K, z" M! I, a( d      }% |% ^1 }. B2 a* U5 j, S7 a
   else if (yDir == "up") {
. ~* l' z! i  @( e  {  Z. R      if (yPos < (0 + BallSpeed)) {- m5 R5 A* d" `/ c3 \- W
         yDir = "down";
5 p0 a6 O" R7 n! F& \         }! J  _  U- W/ w9 K+ \" r1 U
      }
# B9 ^& ^0 l; J. j9 R8 D( L5 K/ {5 X; F8 r   if (xDir == "right") {; `1 \$ {4 e$ w, q) G  Z
      xPos = xPos + BallSpeed;
% W0 W0 D& p, b) L: O+ D      }
7 [6 p. C  W5 O7 y- q5 Y   else if (xDir == "left") {
. w+ e0 p4 @. k. O) h( L      xPos = xPos - BallSpeed;
9 P/ ?/ v' T& B' q" I' d- c      }9 c: G5 r$ @5 J' g" E& ]9 G
   else {4 f0 k$ [$ e( A1 O+ i: d8 [
      xPos = xPos;
( n. |+ I+ W2 n3 U6 m3 K! ?/ V      }0 ~2 Y- i2 b' Y& U
   if (yDir == "down") {
7 E. i0 P, ^& S5 M5 i% c1 ?/ g3 X      yPos = yPos + BallSpeed;
3 B5 a! N1 c1 N% f- i6 @      }
' f+ `  y5 }5 L/ p# \/ |& d   else if (yDir == "up") {2 ^! E. \$ x& N) s0 G
      yPos = yPos - BallSpeed;+ L. p' r+ M% b2 a7 A
      }  t, F0 s& {- E  \$ p" _& ~1 k
   else {
6 f+ Z- S; M! \- f, P      yPos = yPos;: Y3 k6 _* F& Y, |6 S
      }
. V6 t( ]9 x7 K   }* k8 k* q, z' K
1 n3 G; i0 X  L: C7 H/ _- P2 I
function hidetext(){+ L/ e: O) E2 m
if (document.all)" w- M; z- `& V% j
supertext.style.visibility="hidden"5 u0 M0 b( I1 c' O, m) e/ g; K
else if (document.layers); ^- d8 B5 f  ~% U
document.supertext.visibility="hide"
9 Q8 }; u$ g, B7 Z1 J% vclearTimeout(animatetext)7 I- P; h2 F- G+ q% r; B, {: B# s4 u
}
& Z# F, K$ `' a6 J" o5 E
2 C+ w- r; y2 J  a: j$ v* ~if (document.all||document.layers){) k) H2 q! ~3 L: j; |
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 c, N, z8 ^1 |. \2 cwindow.onload = initializeBall;0 q9 K, k2 }! p6 H
window.onresize = new Function("window.location.reload()");
4 T6 C9 C7 j6 l* s" _/ _}/ Q; d$ @. R' F# V
7 s! k9 S  h9 g  B+ E
</script>

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