返回列表 发帖

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

<style type="text/css">
: l6 V, @8 x2 u6 }( v( h#supertext {
( Q: }" h; R3 g: @" Z6 K7 j. L2 F! }position:absolute;
+ W  x2 P' `' a, `4 J& Wleft:0;8 g6 _; f( p2 d% I- J! @1 @  l4 _
top:0;+ l+ d* x  ?+ W/ `& i+ p$ ^/ r7 T! P- Y
visibility:hide;
/ U6 O0 Y# p4 i$ Q% T' f/ Hvisibility:hidden;$ K% `4 E& T8 l8 o0 `
}2 a" |" m- D" O1 U1 L4 {/ V& U
</style>) c* R4 o( x1 Y, a
<script language="JavaScript1.2">. X& r; ]3 `% \- @3 k+ x( T6 a3 ^
<!-- 改变下的字体的大小。颜色-->! M0 w" b7 q" y) Y7 G2 v1 Q( b
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') C: G' j& H& v$ m1 a& j& a
var hidetimer='';0 i0 E+ B2 ^3 D$ N
<!-- 改变下的弹跳速度-->2 n6 S* @' ~! p+ Y. q. }, Q
var BallSpeed = 20;
# S5 F$ ?! Z- t1 b, t3 y6 J; E8 Vvar contentWidth;4 p) V# N8 {0 \0 t. z
var contentHeight;
0 S( \* _" i& A% g) F: x3 ^var maxBallSpeed = 50;0 O0 A6 }( e* W/ I$ ~6 |; U; x# w
% F8 P; f7 r; o' s7 G: k

2 ~" i/ T2 g2 v& zvar xMax;
8 `  ~4 x( ]. [& [* W7 avar yMax;! j7 z% y. x; R+ s
var xPos = 0;$ L; O4 f4 i0 G
var yPos = 0;( {2 w/ Y7 g5 c
var xDir = 'right';" v* f0 H0 x7 H1 T% C7 S: @
var yDir = 'down';  b9 |- n: J! s% F: N; u) d
var superballRunning = true;  D, Z* |$ V" N
var tempBallSpeed;
" Z/ l7 u/ v; M4 p& K3 tvar currentBallSrc;; L* K9 u6 N' i. ^0 ]8 U7 x" i$ h* R
var newXDir;, T, K, |3 V) T  `- q4 b
var newYDir;: |3 r& q* x' o! W5 [/ o

7 L5 L3 d3 f5 A; nfunction initializeBall() {. u5 D$ \5 P. g$ I. I! h& c
   if (document.all) {# W* v2 [! G2 _
      xMax = document.body.clientWidth
, A5 M! R2 P+ n8 s+ d      yMax = document.body.clientHeight
1 t4 F" E$ p  U$ h$ J+ v  v      document.all("supertext").style.visibility = "visible";1 Z- q2 i5 a* v3 q+ P
      contentWidth=supertext.offsetWidth
3 g' X1 X6 o' }* o      contentHeight=supertext.offsetHeight
4 P; \% Z6 ^( P* X, N      }
# {2 p" o7 g9 x4 @% S; q   else if (document.layers) {% p: E) ~2 {. y& y: w6 _. R
      xMax = window.innerWidth;
& d4 a5 @& o8 I3 d' W. T; q      yMax = window.innerHeight;
  h' N+ ]9 P5 h- l# H      contentWidth=document.supertext.document.width
9 l( u& e$ }. v/ X0 ]1 ~      contentHeight=document.supertext.document.height5 c4 G7 X5 q1 `$ A3 f/ h
      document.layers["supertext"].visibility = "show";# C3 i3 N* k( L6 S5 B
      }1 y* P5 \; ^. j$ i* P) ?
   setTimeout('moveBall()',400);$ s5 n) F7 j1 ?; R" n" J
   if (hidetimer!='')
# ^0 ~6 l9 B8 M- k6 t7 ]* x   setTimeout("hidetext()",hidetimer)
+ E8 v- N" Y2 d. E. I6 @+ c/ t   }+ b) \3 h+ |& [. M! k

# L" j# _& n& Dfunction moveBall() {
/ q" R  a" D- d7 d( H3 U% \   if (superballRunning == true) {5 A- j: C7 P' {. ^- q% `1 ]8 u9 m
      calculatePosition();
; b; z8 R9 \0 D& d) v/ f! C( E      if (document.all) {
+ D1 d% U3 R  f2 s0 @         document.all("supertext").style.left = xPos + document.body.scrollLeft;# O3 J1 r3 z  q
         document.all("supertext").style.top = yPos + document.body.scrollTop;
8 A( v4 h4 u. F- ?         }
0 x* O, W  p4 Y1 o7 b      else if (document.layers) {
7 \; j2 J( A! Y# k) j# M( O         document.layers["supertext"].left = xPos + pageXOffset;- V; x8 E9 L9 d: |- z
         document.layers["supertext"].top = yPos + pageYOffset;
- ~( G2 L, t$ ]) Z$ a* @) Y8 h1 K  U         }
: T' a7 W+ a! ^9 _6 k      animatetext=setTimeout('moveBall()',20);8 \/ X$ ?2 d% t- B2 Q5 Q8 m
      }
3 k2 S/ u) t* k0 ?   }8 k4 b! X" A# m/ S+ G4 B3 \
0 V5 r2 ~: ]$ \( k
function calculatePosition() {' V% \* J/ U! o9 p
   if (xDir == "right") {
8 r* X- S6 \, L      if (xPos > (xMax - contentWidth - BallSpeed)) {' o( H" ~% W! v, P
         xDir = "left";0 A4 S) A) t- ^6 K. j# z; @
         }) I! E. M& \+ K% F
      }
4 V+ z4 }5 K6 F   else if (xDir == "left") {
, Y3 i6 R; T- t- [5 K' i      if (xPos < (0 + BallSpeed)) {! m5 r" u7 m1 `/ p1 E' Z
         xDir = "right";3 X+ B, h# C  c
         }
" L  G% n' X" @4 t1 T      }
7 O6 C, P+ Q( `; m# M1 v! G5 _; V# b   if (yDir == "down") {9 R. u0 n9 w: o8 R  L) |
      if (yPos > (yMax - contentHeight - BallSpeed)) {/ m5 \, b0 s* |, B
         yDir = "up";
! u) h, y  b. v         }9 B+ G2 _0 ^; D; l6 m4 j4 ~
      }7 ?9 m' B) k# q+ k
   else if (yDir == "up") {! D  M2 s* u9 U: u0 S- {4 p+ G
      if (yPos < (0 + BallSpeed)) {9 A1 ]$ x- j' J1 ^" s& i' L
         yDir = "down";, s0 F! b4 j6 l3 l
         }& l* G' S1 x: Z% b5 A1 \0 w
      }
  u3 G- C- P( W& o4 ?9 F: j5 m   if (xDir == "right") {; t! \) C  e' {2 d' z, W
      xPos = xPos + BallSpeed;1 D) f4 B4 a) U
      }
% S! L# a0 v4 Y/ k   else if (xDir == "left") {5 t4 B! v+ W, ]0 B
      xPos = xPos - BallSpeed;
! p: S- p0 l. R& T% R, ~      }
- d& `! N  |, `8 x, A) K, ?   else {/ z; S# ^8 ]/ f* R6 k) g
      xPos = xPos;& `7 F" I9 X2 G7 c$ ]
      }
6 `3 d* U4 b6 e- z; W" c   if (yDir == "down") {: d1 f' v$ d& j. _1 X6 \) I2 n
      yPos = yPos + BallSpeed;
! @$ `5 X- \4 Y      }
: Y9 ^2 J8 `( s   else if (yDir == "up") {& X1 l- \' ]5 g; X6 Z9 b7 O* _
      yPos = yPos - BallSpeed;. O$ E! h, }# E
      }$ R  x7 W: G" R& Y8 [& o
   else {. e/ ]8 E4 D1 E! X
      yPos = yPos;, V; u3 L) z# Y2 f/ |4 J. Y1 h
      }
: @+ K# k1 Y, @. S   }. ~6 e0 C) B' `$ z! J4 u
! P: l& W" F" K2 E9 ~
function hidetext(){+ {& l5 v  u1 @$ n2 A
if (document.all)
0 o7 `* K; _1 p& c- \1 ?. [/ ?3 [supertext.style.visibility="hidden"
' D$ k6 e' }! H# aelse if (document.layers); {7 c0 h6 J% Y9 |( P; L2 q
document.supertext.visibility="hide"0 V7 c- Y1 ?9 Y; e4 K& t0 g
clearTimeout(animatetext)
( l1 x, F4 U! D# s5 }% V/ [0 ^! g}+ X4 ?7 S" }% j: L& c; }- G

  I( r3 i1 j5 @7 u9 n1 ~  a' v: uif (document.all||document.layers){
7 s2 B" A1 b" B2 x" T$ Cdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 S$ r2 M3 |* o" Q' G% [window.onload = initializeBall;4 G/ z/ _4 w" y' F1 o1 f7 U/ Y
window.onresize = new Function("window.location.reload()");
. C5 R. t, E+ l0 E$ ]/ W$ z$ e}
; a" B- Z4 o- [4 T6 A- M: g+ {3 y4 V' C9 G5 C5 f
</script>

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