返回列表 发帖

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

<style type="text/css">
; u( _7 c/ f8 L3 s8 W#supertext {. a; t% ]$ {9 p$ u( E% x
position:absolute;$ L! N# |; ~* b) `( c' _& l; f& h
left:0;
4 R. G' P! R' H0 xtop:0;6 |" f: F+ ]6 N3 }. `4 g
visibility:hide;
, c3 E0 f7 o0 k, T% @' tvisibility:hidden;5 H, d$ F. N" S7 k% J1 L
}
! h8 L0 y) D/ F8 u; P7 L</style>' `" R2 s+ W+ x2 O6 o( u$ o. s
<script language="JavaScript1.2">
% |; g( z0 F* Y0 L2 Y0 R<!-- 改变下的字体的大小。颜色-->; C! B7 ^8 G! `+ q2 T
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ |2 F0 [- B# j, `1 d" l0 ?- j
var hidetimer='';
3 d+ `( N; d: x% X<!-- 改变下的弹跳速度-->
1 W+ E# e  ]9 q! u. Z+ Bvar BallSpeed = 20;+ n- h$ ~, }! @; D% C0 G% b
var contentWidth;5 e: m) I0 x! H: i2 N
var contentHeight;8 S1 R# B( I' P) m5 D2 V1 R$ W7 L
var maxBallSpeed = 50;
8 T6 Y5 x; M" L) h, [1 T$ T/ s6 e9 [! [7 r

/ e$ I( }8 N( w# O7 |var xMax;
- @# x  g$ _" Dvar yMax;( C4 [/ q4 \5 Z9 Y
var xPos = 0;
2 g% N! i9 R6 Z4 n5 K$ P2 n1 Lvar yPos = 0;
$ U$ {5 Q- i1 Ivar xDir = 'right';
6 N7 T# j4 G0 H- bvar yDir = 'down';
& D6 {9 i6 I5 B* t& d$ V) R+ z9 Zvar superballRunning = true;
! g' J8 N; {) Wvar tempBallSpeed;
8 r5 N% o3 D' m2 B# g: rvar currentBallSrc;
% S. a- }6 e2 M, u6 I  \var newXDir;+ m- H6 y* G1 A; A: Y8 A: D
var newYDir;8 L/ L4 Y4 A- A
& ?* M  r( q6 a0 p+ i+ G
function initializeBall() {
! d1 l% q6 z+ I3 n   if (document.all) {
+ A! l' H" j) g( M* o7 D      xMax = document.body.clientWidth
; p; q/ |' i, j6 M) [5 q      yMax = document.body.clientHeight
" I( ?3 L( g- h/ e+ |      document.all("supertext").style.visibility = "visible";
+ k: J, J* x* H( [! m      contentWidth=supertext.offsetWidth- |4 N: `# ?4 ^1 C- M8 `& K
      contentHeight=supertext.offsetHeight% L" t9 [& c7 i
      }3 l5 D6 w" Q  ?2 P6 L9 t4 a
   else if (document.layers) {# R. f( ]5 l! }0 @1 H  E+ X/ |- U
      xMax = window.innerWidth;
4 e  \. v- D% K" E4 b# n7 v      yMax = window.innerHeight;  q' |2 v: ~( M7 M. P  I& S: l4 e
      contentWidth=document.supertext.document.width. m0 S- G7 a! E  w# Y
      contentHeight=document.supertext.document.height
* H! j: B5 Y: h& F      document.layers["supertext"].visibility = "show";
, p+ ^& g5 P' j0 V- ?6 O* u      }: h" @! z- j- M4 t7 a
   setTimeout('moveBall()',400);
" E' B' V  G+ E# f- R   if (hidetimer!='')
% g* A  B8 }9 l- Q8 t5 R   setTimeout("hidetext()",hidetimer)& Z- j  D1 `( V) N, C
   }2 H9 T6 x" Q5 O2 O# L) j

' v+ X  W3 ?8 @9 `& @6 jfunction moveBall() {
2 s/ x1 z: s( }. R+ D9 u' z5 i   if (superballRunning == true) {
% P8 G# m2 @. Q' K4 V8 o; A      calculatePosition();6 {+ L) N6 {, V! W" j6 X" I6 a5 I
      if (document.all) {
- D2 N6 \7 _9 C  u( d         document.all("supertext").style.left = xPos + document.body.scrollLeft;' p9 |* `* b4 Q' Z) G* {1 _5 i
         document.all("supertext").style.top = yPos + document.body.scrollTop;8 v4 s) ~0 Z& l7 c8 O; S: b; f1 J" i3 Z
         }
! t$ u; d! O. a% ^5 p; T      else if (document.layers) {7 Y: n8 [* q% n0 x) |
         document.layers["supertext"].left = xPos + pageXOffset;% j' G5 F5 j; W0 e. c6 B2 e7 g
         document.layers["supertext"].top = yPos + pageYOffset;6 f* h& b3 h* U2 u1 V7 H$ S
         }
. ]* [$ F2 N8 |0 `' s      animatetext=setTimeout('moveBall()',20);1 j/ R  _6 f" w
      }1 a% ?! G  q9 }+ T
   }+ {! q) q3 D4 @0 E* u; t# s) j

+ _/ V9 N) D0 m5 {function calculatePosition() {( Q: k) d/ ~, ]! @
   if (xDir == "right") {/ z6 Z) I/ H" E9 q" ~" y
      if (xPos > (xMax - contentWidth - BallSpeed)) {7 q9 w) f+ u$ D2 v' y- a% m( ]
         xDir = "left";
8 Z5 N( ]: G+ c( q$ i         }
" Q6 E% ]4 R1 M2 ?      }1 r4 p8 g% ]+ e6 e8 Q7 q' o: P5 Q
   else if (xDir == "left") {& a& e1 |- X. `, A# f  R4 g$ n% M
      if (xPos < (0 + BallSpeed)) {
, C! C* m( V" @! u( ^* s4 h         xDir = "right";
0 c! t# a6 J0 Y  \* M         }
2 l9 P6 p2 ?+ ~  e* b2 e- D      }( ?. ^9 Q3 p# d' J
   if (yDir == "down") {
9 a$ G- _% {8 C" G6 g6 M! {      if (yPos > (yMax - contentHeight - BallSpeed)) {
, f  K+ `1 H. R7 u3 j         yDir = "up";3 B0 A9 I/ g! m2 _& {; S/ q
         }
/ O) E5 b2 N8 w  G      }# c, e2 q2 {& ]" [6 k
   else if (yDir == "up") {+ ~. ]6 F) K/ g! H
      if (yPos < (0 + BallSpeed)) {
; ^5 [2 x6 K2 h% ^         yDir = "down";
+ b5 m2 h, a0 r& F         }+ {  o; D' O) r3 r% j2 ]: T" O
      }
# y5 I  h" ^9 x5 Y   if (xDir == "right") {
# M( i* @- Y" E- V; j6 A( |3 v, G7 X      xPos = xPos + BallSpeed;
2 O: c* A! n) `& z* u4 E* f- p1 s# V      }
. }; e# S$ r/ L   else if (xDir == "left") {" [1 k! ], g" H( M9 c/ F5 ^# V; z. t
      xPos = xPos - BallSpeed;
' E4 {# O1 I6 i9 F+ p8 G7 P5 ~" p      }3 V% G# O3 M- b
   else {8 A. Z* q4 _' U+ w
      xPos = xPos;
3 d1 ^; i- B" F& U      }6 m, |9 k) y- j( E
   if (yDir == "down") {
! j; v. K% C! w& e. H7 ]      yPos = yPos + BallSpeed;
8 l/ W! w4 q  L1 o1 s      }
) o/ w0 G9 P9 z! B9 C2 Z6 v   else if (yDir == "up") {; l  l* d* V6 m
      yPos = yPos - BallSpeed;; U" }6 f0 M+ s' t! y5 C* |2 X
      }
2 ?. ]& k5 ~9 k7 Z' e$ k   else {! |0 A( W; \, I  H: M4 U8 Q9 c2 W
      yPos = yPos;& L* ?) j, P! B
      }
* x) C- I0 l- K: p   }9 d; m' [2 i' p$ ~6 q0 |' z+ U6 Z
9 O& N0 {1 g5 Q. c) s
function hidetext(){# |. h: W: Z& @) e1 m& `
if (document.all)& R( L: Y; E" R7 h
supertext.style.visibility="hidden"2 V0 S1 l- X" m/ I! b4 f
else if (document.layers)& Z8 |6 c1 g( Z. O' [* ]' ]( C
document.supertext.visibility="hide"
9 t0 @8 I' H: kclearTimeout(animatetext)
9 P3 @7 N2 E& ]9 H* h8 X}
# x  r5 k1 i5 R' h+ i0 q: y. w' N2 z8 c3 K
if (document.all||document.layers){
0 B5 S! Q; W7 b& f0 Q) Idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
' c, _! n( q0 {; t5 {. {window.onload = initializeBall;
$ F7 S/ H+ L' zwindow.onresize = new Function("window.location.reload()");
3 y  X  U; V  Y3 r}
3 f/ p$ |) l+ n% _2 D' g) l1 v% @* |' x( k
</script>

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