返回列表 发帖

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

<style type="text/css">( A, ]* d& m1 k& d
#supertext {5 f4 ~, |' {1 i% A) D( [; J7 A
position:absolute;- g( y4 i, g% P
left:0;
3 G/ l; ~+ _  z$ Z. g# X6 J4 M4 Xtop:0;
, k- ^3 C$ q2 d1 A2 Pvisibility:hide;9 ?1 _. p/ U3 n( ^0 a
visibility:hidden;1 t; ^7 U* Z: M
}2 T- R8 T( E1 a6 d5 M& Y7 A! ~
</style>& ~2 H& R: S  g6 l: G  _+ i
<script language="JavaScript1.2">: W( n5 b( q1 |( C: p
<!-- 改变下的字体的大小。颜色-->- c+ E6 b( v* y0 S* o
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 I, V; j- A; Z
var hidetimer='';0 j* r& N- M8 A8 D
<!-- 改变下的弹跳速度-->
) R: ?3 |: D9 N2 a$ w* D3 ?var BallSpeed = 20;) l. [; d; P$ z5 v6 N
var contentWidth;
/ g8 z2 U+ f7 l, Tvar contentHeight;* q1 ?! i/ Q3 ]; w
var maxBallSpeed = 50;
6 c9 B% k5 T. {
2 C6 Q: E8 S7 c! L8 r
, e9 R  b: u( h  ~  uvar xMax;
( ?" W. I) F+ g& Qvar yMax;" O: Q. M0 s( k9 _
var xPos = 0;$ U1 A7 M0 S& d& j6 y1 f
var yPos = 0;
. a9 w' l& i% ]% ]( S3 nvar xDir = 'right';4 z+ z6 H2 p% M3 G: Q
var yDir = 'down';/ v% O3 m  V' J4 K
var superballRunning = true;
5 R9 f5 H$ p2 `) Jvar tempBallSpeed;& U1 @6 Q, w3 m1 x3 @- R3 c
var currentBallSrc;
  I- i# P3 N# b7 \. e, @$ Z  pvar newXDir;$ U7 |8 _% j( e1 E: q* }2 ^
var newYDir;
+ R9 [( T) d" b( P% V7 m8 V$ C; X( t( C4 d
function initializeBall() {
6 a7 ]9 S9 x- F   if (document.all) {
# F' J5 U' G: L7 j3 H0 w; h1 b      xMax = document.body.clientWidth
4 B- l" \+ f' N. L      yMax = document.body.clientHeight
' c- H( N; t) V' n5 q) Q      document.all("supertext").style.visibility = "visible";' L* u5 g$ ?& O  `7 L
      contentWidth=supertext.offsetWidth; a: d) J; w9 |
      contentHeight=supertext.offsetHeight
1 w6 e" I, Z! G1 C      }! v- u; C( M# p3 x# N
   else if (document.layers) {
! k7 y$ P% O. n7 t; J" d& Y      xMax = window.innerWidth;  h5 D3 d& v; I# H& g
      yMax = window.innerHeight;8 E8 F! K5 A; Y2 S  B: a
      contentWidth=document.supertext.document.width
( L* w7 ?" \: k      contentHeight=document.supertext.document.height
# m6 R* q4 Y3 g      document.layers["supertext"].visibility = "show";
% l$ V- d& p# U7 K) Q      }
( @1 N9 ?$ W* s4 x7 I   setTimeout('moveBall()',400);5 L8 L9 l( j0 G- X; b6 A3 l
   if (hidetimer!='')2 a7 D6 l: {* J& j" n% p% \
   setTimeout("hidetext()",hidetimer)! H, l. e9 w8 K. P$ D( |
   }8 o% l, P! D% J5 P- r
) {$ S* f3 |, V5 V, |
function moveBall() {% |! {( p6 K) Y$ S8 S
   if (superballRunning == true) {7 V  |, n9 J% S; p: Q/ B' f
      calculatePosition();
( _: Z+ |9 y7 [( L      if (document.all) {) U9 j3 q$ F! R" L
         document.all("supertext").style.left = xPos + document.body.scrollLeft;  i/ N8 i% v- J6 K* B
         document.all("supertext").style.top = yPos + document.body.scrollTop;$ Q' [0 O1 \! |+ p
         }
6 \1 `5 |  D0 ~& h# Z      else if (document.layers) {
) z) y3 r3 g- ]) U& s0 }8 n0 g         document.layers["supertext"].left = xPos + pageXOffset;
4 Y8 p# q1 C7 E/ k2 ~, V* y         document.layers["supertext"].top = yPos + pageYOffset;0 D; @+ p* a$ k
         }# m* L# q) D2 Q1 z4 V# a
      animatetext=setTimeout('moveBall()',20);0 Y( b1 D3 c# e
      }
4 ]7 W5 [; z$ ^8 Y. m9 V) j, S   }
& g/ x, ^, |5 G8 K0 X3 w$ m! `& T, _6 b( h
function calculatePosition() {
! I# o4 |, E( {, p   if (xDir == "right") {2 P% Y/ f5 E$ B$ V/ V  m
      if (xPos > (xMax - contentWidth - BallSpeed)) {- V& {2 \" d( \" F+ B
         xDir = "left";6 V( J. o5 g- E5 H8 y: C- a6 c# N
         }8 T; M1 B0 ?) N$ L
      }
; ]1 G, ^- {7 m   else if (xDir == "left") {# V7 n7 w7 R9 a$ c2 v/ {
      if (xPos < (0 + BallSpeed)) {
  u1 j" V+ V# x         xDir = "right";8 }, X* O, [/ z& P% }  @
         }" }5 k& E6 X  f7 X
      }
+ N3 v2 d- {* E* a   if (yDir == "down") {
$ A: I+ U8 B$ K  y& P      if (yPos > (yMax - contentHeight - BallSpeed)) {
& d" Y% F/ H1 L- W5 n         yDir = "up";
9 X4 ?( n5 s+ F, C' k         }
) u8 b- q6 R' r( i      }1 B+ [) k. v: M1 q! D5 E4 Q3 L! M
   else if (yDir == "up") {8 s5 f7 \' g9 [, V  K
      if (yPos < (0 + BallSpeed)) {% h1 ^$ ]2 H6 T3 a
         yDir = "down";9 P8 T/ \, o* F$ u4 F' Q: K
         }9 f6 v7 s0 i7 X4 ]6 M/ v  [
      }
' m# Q7 k2 `+ L; j. y; \" q   if (xDir == "right") {
# \/ k- T" r$ S# f9 A% I' C( {      xPos = xPos + BallSpeed;  \# K% q# A+ C8 [. M1 k' Q
      }
2 L5 s8 b0 Z3 x5 H" J. k   else if (xDir == "left") {4 m0 @# I8 \2 e
      xPos = xPos - BallSpeed;6 ?1 C5 @" S" ^6 R
      }, [$ N% x9 b) k6 G+ s
   else {6 u. n8 l' J- q* f! o
      xPos = xPos;; h+ D/ W0 `( ?
      }
" F7 z$ j5 r+ t4 T9 g+ f! o   if (yDir == "down") {4 j$ y+ r8 h1 A' D$ o2 x
      yPos = yPos + BallSpeed;
/ {6 w  o! {0 m" a8 ^      }9 A5 g/ W: H3 F; E$ a  {
   else if (yDir == "up") {1 k3 X% ]9 @% J9 Q4 V
      yPos = yPos - BallSpeed;
# N# O( w; h( M) s8 y- L      }4 S; |  b8 i3 W7 r
   else {4 ~% R5 P9 ]- ]7 n! W
      yPos = yPos;
2 p' U3 {: Q9 Q      }! `9 R; Q& M$ R5 A
   }
- `6 x% }2 P: b# O+ H$ k7 l+ \. q! Z6 o" {( v: N
function hidetext(){
9 U* `# _' X- X8 V  _! _if (document.all)
; J- z( A4 [* E: }! Ysupertext.style.visibility="hidden"
5 m2 G/ }# c- @$ U' p+ L9 jelse if (document.layers)# M0 q1 d* I( k6 S
document.supertext.visibility="hide"
2 A, l$ e- P, j5 FclearTimeout(animatetext)9 k  }1 F: O2 Y8 e( c
}7 V5 q: d; L3 B! `2 B5 ?$ @4 x+ ~
( T+ T8 c* x% R) {  E
if (document.all||document.layers){
8 L0 ]( f1 @% i0 C9 Mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')5 k2 F1 o) u2 R" K/ p( P% @
window.onload = initializeBall;* P- m" p& q0 H1 e- V7 Z7 s
window.onresize = new Function("window.location.reload()");, [. }- i+ @# X/ a
}
$ |$ D9 }1 o0 N1 E
; A! r$ I- U* p) `* v% @4 t$ o$ O</script>

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