返回列表 发帖

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

<style type="text/css">9 ^# ?% @* ?4 P* D
#supertext {4 `" M7 g: m4 {' ]3 R
position:absolute;# _$ k4 |6 Y- a8 ]! t1 L
left:0;
+ l3 `' Q3 k/ ]8 Gtop:0;
, \: g$ z  J+ a( avisibility:hide;
, B$ p4 C, u" i0 w" U& k6 |& V6 K0 k  |visibility:hidden;9 G, |' v( ^) U) ^8 s! o
}( H# ?  x; u8 O. d9 y7 t! }
</style>
' Y. u" ]! q6 z<script language="JavaScript1.2">, o4 y) S& {( x# t1 l  r" I
<!-- 改变下的字体的大小。颜色-->
- g( P) S. q1 k' `+ U, M. r& e8 Pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 q6 Q9 f8 P! \! |; R. gvar hidetimer='';
: d2 r1 O7 d, G<!-- 改变下的弹跳速度-->
! e( c- B) b1 m2 ?( Nvar BallSpeed = 20;
/ R9 B- }0 ]( \3 qvar contentWidth;7 [3 z/ l# l0 |5 m: {4 C
var contentHeight;. L# |0 A5 b3 F& F
var maxBallSpeed = 50;
( ]1 J  m6 k0 u" ~9 }: @' g1 K" z/ y7 l" X+ e; k
4 p: d+ T+ t' y5 I6 m# @' t6 d* I+ @
var xMax;
# p3 k5 \) n+ f/ e* E# Gvar yMax;, w8 p. b! x# u" u1 Y$ Q
var xPos = 0;
3 N8 Q* q0 N3 \, wvar yPos = 0;
0 U/ H) I! Z2 J. ?' A( H4 `- Mvar xDir = 'right';
. @# e/ R1 X/ M7 f& D7 A" Evar yDir = 'down';. D% e2 Y) F3 H& |6 m
var superballRunning = true;
8 @9 a) S* L% G4 f5 ]- j8 a6 l2 pvar tempBallSpeed;- P* D0 k1 o2 `$ R
var currentBallSrc;. p( X8 j9 P$ }' V$ _
var newXDir;) |' ^) k1 I% q( D1 e4 U1 j7 k
var newYDir;
9 j4 x) v5 k- q5 l( G1 J" f$ z1 Q& `) m5 x" [4 c9 w( a& ?2 b
function initializeBall() {3 c, C6 V1 f6 o3 W9 W
   if (document.all) {' C9 Q7 W5 e2 X8 K
      xMax = document.body.clientWidth: ]/ @& n+ H3 u9 }3 `' j
      yMax = document.body.clientHeight" o2 q  d% `8 ]& p7 W
      document.all("supertext").style.visibility = "visible";$ S# G' P$ k$ c' l* R; X3 e
      contentWidth=supertext.offsetWidth7 g% u) Z. v% ]; S8 W) F
      contentHeight=supertext.offsetHeight% y# X& w- E- P, Y/ x. K
      }" T4 |- V2 W* }  {$ q# U4 y4 v
   else if (document.layers) {
* H* H6 Q; W0 U0 N' v' t      xMax = window.innerWidth;7 n) w8 L3 t: w2 a- {" j' A: p
      yMax = window.innerHeight;# K6 ]$ _* w$ x5 E! d
      contentWidth=document.supertext.document.width1 B  W9 p+ H$ n% t) T4 c
      contentHeight=document.supertext.document.height
: N0 v8 x( V' v" R& I; H4 b  d& Y      document.layers["supertext"].visibility = "show";
4 f; {. z2 o  e7 c* @      }% ^4 Z* l$ P! `/ u
   setTimeout('moveBall()',400);: n2 D1 G0 Q6 g
   if (hidetimer!=''): |5 a1 m# l8 p9 l: p
   setTimeout("hidetext()",hidetimer)
6 g' G$ L  a/ S   }
, X7 `- n: S& [5 M  B5 C& b: l% Z% m, S
function moveBall() {6 ]; P, K* r8 l. C9 v" W. }2 ~
   if (superballRunning == true) {  c! C& q+ q5 w% w9 M/ W# _
      calculatePosition();- {7 j, `7 s3 h/ P9 o% V, ^
      if (document.all) {: H$ S+ n- w, D& E
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
- p/ I! K7 P2 g$ t' @         document.all("supertext").style.top = yPos + document.body.scrollTop;
2 K: h7 f9 G3 g& d# o" j' s         }& b" c0 Y4 E8 j, N0 f
      else if (document.layers) {: l! L  K) F7 x" S) v4 X: O
         document.layers["supertext"].left = xPos + pageXOffset;
5 {/ _3 E- U% `         document.layers["supertext"].top = yPos + pageYOffset;
' r4 n8 s1 c4 C1 d8 j         }
, g1 j; u1 T- x2 i4 o1 X- h      animatetext=setTimeout('moveBall()',20);8 ~  d3 f' b1 o1 z9 j0 H
      }# P4 J0 ]  V2 m; p
   }7 v" o9 ]- Q3 h6 ~2 V
. r4 ~$ P# G- i1 O2 k
function calculatePosition() {
7 V% b$ D, r6 R   if (xDir == "right") {
3 _" A" x% s5 ~* M4 m4 f      if (xPos > (xMax - contentWidth - BallSpeed)) {
, g  a0 x) b" }" l" J         xDir = "left";
# O/ `) w' K0 j1 x. ~  J0 n+ o         }' F- q% F; j! g" C4 o
      }
  |6 @1 Y& A2 g   else if (xDir == "left") {
" ~, A7 B, Z$ Q& {6 ~0 y      if (xPos < (0 + BallSpeed)) {
) n0 x% C! X  O* G4 Z0 P         xDir = "right";$ `( N! d$ K# c/ n. v
         }0 E/ W' Z9 b0 J. J  K# o
      }- C/ p& m" O+ Y- C  r9 ]4 G
   if (yDir == "down") {) [1 t- ?0 c: E) f( w" f7 d
      if (yPos > (yMax - contentHeight - BallSpeed)) {
4 I! \  {! f( g& q8 b         yDir = "up";
6 R1 V' o* r( D: J, r         }5 ]* J, [7 d0 t
      }# k$ U7 E( B5 z. f# m; ^
   else if (yDir == "up") {: ]! {4 u# h/ y6 |' o/ Y
      if (yPos < (0 + BallSpeed)) {5 q& p8 z9 B- j5 J& E0 p
         yDir = "down";
& T4 e) N4 j; L& R6 t8 h! C, i6 f6 L         }
) L4 ], J% M3 l. G1 S: T      }
- @6 P, h7 ~: H9 D   if (xDir == "right") {! |2 E/ ~( ^, g% s: C5 d! l& v3 J
      xPos = xPos + BallSpeed;
" y( ^* q! a% d- J0 G      }2 r: k( \7 v) @7 j& V4 k
   else if (xDir == "left") {. O2 z6 I4 r9 z6 K5 `0 k6 s8 G- L
      xPos = xPos - BallSpeed;0 i0 J# l, r4 G4 N# E/ W. E
      }" r5 o2 F, ]9 N
   else {
& p8 ]9 Q0 W) {! |/ F      xPos = xPos;
1 b" U" U: f% C. X9 ~. ]      }
1 u+ y; F# W5 A2 P   if (yDir == "down") {
' _( b3 u8 ?4 t: s+ [" g, ]      yPos = yPos + BallSpeed;
9 V. _. d6 P4 a& v/ U3 C* s0 M      }. m" v, ^7 H' }7 D0 a" L
   else if (yDir == "up") {; G/ ]; R5 C9 c. z
      yPos = yPos - BallSpeed;
/ g+ Q# Q1 `' L      }2 Z- s) _8 E/ w" U
   else {& X) k$ w6 a" N. _8 u% ?
      yPos = yPos;
0 z( f$ Y4 C+ T' b* e7 o; L4 I6 t      }1 D( p! U1 h1 {- U# k! H7 z( E* C" O" P
   }
" F# V( a6 r4 m# l* W, X. D
& n# p' M/ q' U" N3 V. U+ Efunction hidetext(){' r: a3 c; A( {0 b1 ]) S- N
if (document.all)& d! w. }# u; g! ~
supertext.style.visibility="hidden"' a) Q3 A; T! F  X
else if (document.layers)
  Y7 ~: S' O& r+ ?. r' `document.supertext.visibility="hide"
3 C( e' ]7 m3 T& d$ T" X' TclearTimeout(animatetext)
( c( p& J' ?: W" r2 G, J}
7 M9 T- T/ s7 ~5 \1 c% C, V
# B; N. r) @; }" ~9 |9 ]0 Q5 Fif (document.all||document.layers){5 S" q; }8 U, t& Q* {
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
, w3 `0 k# V, G! |: Owindow.onload = initializeBall;
& L) n% j/ e( l; h1 ]* gwindow.onresize = new Function("window.location.reload()");8 H7 H) o5 u0 J# h" q
}
' E6 {" U; _- y/ S2 u% [1 K5 A. ^9 c/ P6 ]' ~# J9 A
</script>

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