返回列表 发帖

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

<style type="text/css">. s: a. h) }& W
#supertext {2 ^. C; W7 E+ Y# w
position:absolute;) c- O+ P+ B' W# I
left:0;$ c. Y/ A( [* H  z- r& y
top:0;
' ~1 S1 Q' Y0 M* m  }: m) j4 O2 D$ pvisibility:hide;7 R2 ]- T  w+ R1 k7 R& Q
visibility:hidden;
( v2 f* d/ \) k6 T" V}, R2 j! M! E4 q. d( h9 ^! y0 }
</style>
6 i- r- t0 v: ]/ n<script language="JavaScript1.2">  _% @* `: a0 Q( b( i
<!-- 改变下的字体的大小。颜色-->8 S* g& n, S% g- Q
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'6 J! ]; L" {, ?& `
var hidetimer='';
+ Q0 P7 E8 a/ o2 Z+ t* Z6 O<!-- 改变下的弹跳速度-->
8 V+ k( {; G* @  [$ z$ A4 t0 I. dvar BallSpeed = 20;- a. i2 Q+ p8 B6 J) V' \' E
var contentWidth;
6 [" y6 e% L) }) s2 Yvar contentHeight;
- C+ x4 y& v3 B) n3 c$ ?2 O7 dvar maxBallSpeed = 50;" c% d$ m2 a8 c" _# U/ i6 r2 c
# b8 n6 n( y! o! u6 l+ M$ b
' b# s* V- _+ J* m; \
var xMax;; O1 z( q7 z1 S$ q: L6 p& t' Q
var yMax;
; h( G. [5 @2 M, ]var xPos = 0;5 R3 A* _* r! B: g5 {. D
var yPos = 0;: Y( U; E* e! I) s
var xDir = 'right';
. q% f2 d2 A& A+ Nvar yDir = 'down';6 D' [" Z; s. S. @0 y+ l
var superballRunning = true;' l- |- R/ W1 u& ~* v  _
var tempBallSpeed;
: i* {: W; E  C8 ~) p3 {* v, H1 bvar currentBallSrc;: c, E4 _. J2 E2 S( p
var newXDir;: \. M9 @5 R) p* P9 M& ^( y! h
var newYDir;7 H- T' X$ O, G# d+ s  C

2 @: d9 F+ R5 b5 }3 mfunction initializeBall() {5 Z0 E0 G! d, P+ m: c# q
   if (document.all) {% `7 N$ m- C; U+ C% u: n2 z# w
      xMax = document.body.clientWidth! R1 z9 \7 e4 W0 o; }& @8 v
      yMax = document.body.clientHeight
& q0 M9 ?6 X; k$ H- B  ?; E" f      document.all("supertext").style.visibility = "visible";. Z( Y$ E/ `- C
      contentWidth=supertext.offsetWidth% @$ g" Z9 e+ u4 a. R+ W. L4 E
      contentHeight=supertext.offsetHeight
  s" W  t! o% c3 J      }
# ~8 b5 Q; @* @: `   else if (document.layers) {# N9 y4 y( U. P. F+ S3 V; X& o. I
      xMax = window.innerWidth;
3 Q; d! L% e! H      yMax = window.innerHeight;9 H; b: H- e% Y5 n
      contentWidth=document.supertext.document.width" D# i/ `% Z$ l: o. ^; K
      contentHeight=document.supertext.document.height  r# T2 z8 w: D) ]- R! r* t
      document.layers["supertext"].visibility = "show";
' U% u& [2 W  X6 S. P, E      }
% N( y' ?0 P5 O' n% R0 j   setTimeout('moveBall()',400);7 l. t! u2 P* Z7 m% e; e
   if (hidetimer!='')
! a9 [+ X; H5 Y   setTimeout("hidetext()",hidetimer)
, v0 V/ j2 A) n   }
( Q2 P. f( s$ V0 g3 ?+ \- ?( S& n6 p: G
function moveBall() {
, C( v. ?4 H* ^1 Z, Y   if (superballRunning == true) {
# @: J8 {8 P$ E8 S2 C# u      calculatePosition();# `9 Y# ]* I5 C/ g8 ?# h
      if (document.all) {$ y) M& l* j) \7 J/ S
         document.all("supertext").style.left = xPos + document.body.scrollLeft;8 L. w, u# t( C; }2 F5 n2 z
         document.all("supertext").style.top = yPos + document.body.scrollTop;3 G( K+ V" Y' u; S) R, i4 g/ ^; @
         }! y- f# L5 N4 i1 ]
      else if (document.layers) {
7 b5 A' `9 {# |- z" ?0 M7 p9 p8 M% Y         document.layers["supertext"].left = xPos + pageXOffset;
$ u' b0 d! O: N$ u5 F) D         document.layers["supertext"].top = yPos + pageYOffset;3 K$ I& Q% o/ s& `! J1 Z+ C
         }; }( O( D6 L4 A5 r% E
      animatetext=setTimeout('moveBall()',20);+ K* O2 U+ C) A( p3 {, A
      }
( j1 p; L& S& O: W. j8 q   }8 d7 L7 c9 W& r0 c/ \, g7 X& {
' I" o0 H5 x4 g* n( A6 [; _
function calculatePosition() {
9 w4 O% Q  D: e/ P5 a6 y3 ?   if (xDir == "right") {
8 G7 Q: U4 _6 [9 u! q7 v1 j& u      if (xPos > (xMax - contentWidth - BallSpeed)) {1 a0 w% I! m% ^8 g1 T
         xDir = "left";
* R# B: E1 w' e1 N# }5 |         }
  I; j( j+ B8 I8 ~' a/ M0 }/ w      }
% ^/ I$ r6 {4 |1 L2 F# i3 U- A   else if (xDir == "left") {
' z1 h$ Y7 }1 ]; [/ j, O      if (xPos < (0 + BallSpeed)) {9 ]( Y+ ?" {/ l# F+ }
         xDir = "right";
# L1 ?+ `) {5 K7 ~  k" d         }+ |( r9 }# M/ Z! A  b2 }+ N+ m7 i) a
      }6 A6 }+ ?7 h, R6 ~
   if (yDir == "down") {
2 r6 C. A" R0 D. _" z- [( @  P      if (yPos > (yMax - contentHeight - BallSpeed)) {! D6 E# V. S9 {3 q2 _) V
         yDir = "up";1 i8 \1 ^) [( h' b: m& N
         }
* Q% y4 ?2 k4 q) C      }
' o; r4 l/ |& _( n. n   else if (yDir == "up") {# c$ ^8 y- T! K! E  h
      if (yPos < (0 + BallSpeed)) {
, |, C  }/ R/ V3 B         yDir = "down";( n4 ]3 a1 ~9 s) Z9 y; T
         }8 D% H4 B) F1 x3 p* a% y; G) b$ ]2 t* l
      }
* _. M5 `2 G' L- _2 x) J0 I   if (xDir == "right") {
! M  K1 G% _1 `" a$ Q      xPos = xPos + BallSpeed;! f0 [$ j0 A/ u. [
      }
1 g  H& ~4 b, `- {   else if (xDir == "left") {
# n2 E' W& p5 @0 z      xPos = xPos - BallSpeed;# b( H1 h$ Z7 @. K* J* |+ k
      }
! M8 V/ a8 a, [" |+ f   else {& r2 k/ }- c" B9 o3 Z" B
      xPos = xPos;
8 x% ~# y' v$ `: _4 \: Q1 A' C1 U- A+ x      }
& [  c' S$ W" z$ |% y; R# Y  L   if (yDir == "down") {
4 M8 C& f8 c9 @, l      yPos = yPos + BallSpeed;# t  R9 @4 e4 c  |+ I
      }+ `7 z: H  J" T4 |
   else if (yDir == "up") {
& g  o. k, c  k: M3 F& f      yPos = yPos - BallSpeed;
. w, _3 _: k3 F0 ]$ i2 V      }
3 t* r& ^$ f% f6 g0 `   else {( z- h$ V' o0 `
      yPos = yPos;
8 r5 Z5 W, t8 b; f, R0 t7 A      }
$ k1 a2 h2 i' D- ]" h! f  d   }
6 C( ?" U, R% d" j( P
7 U& {! W/ E2 J* M- W, s9 Ifunction hidetext(){3 e5 D8 v- `& v/ E" D% I
if (document.all)- q1 W: B1 e7 T8 {9 i
supertext.style.visibility="hidden"6 T$ e7 k% x1 ]0 [- S1 C% W
else if (document.layers)( d  M, d& O0 x+ [/ n
document.supertext.visibility="hide"* `5 G! g' D- Q- \2 W4 W1 L+ D
clearTimeout(animatetext)
  T( g) q$ Q0 I6 m) P3 g}% k9 o: |% v; w0 B6 ^6 q. Q1 k

6 Q- u) n1 Z7 m  Mif (document.all||document.layers){* t) U# p5 ~; Z. \0 k* }% J; {
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 I/ S; o1 w# e% d. x* `
window.onload = initializeBall;. K" m8 e: V1 L" q. L
window.onresize = new Function("window.location.reload()");
5 ?+ Q3 k6 U5 z, @. r8 q2 a7 n}$ ?+ `- Z  e) V6 i( t4 `
0 a6 D( W* ^/ D" I# ^
</script>

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