返回列表 发帖

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

<style type="text/css">. }, `" Q) U9 e8 J
#supertext {
3 b, Q/ ~0 S# N* t8 K4 X& cposition:absolute;( {2 \$ ^" n. y, f' ~
left:0;9 D5 j& P7 `, ]( E
top:0;
  t) I* ^5 c" [' ^( q+ C2 ~  k* \visibility:hide;% r7 Y2 U. ~4 }( z2 n% w7 a' O4 \
visibility:hidden;% \! T5 J, a/ f
}( C' q7 H; W3 c: Z+ }
</style>
" l! J2 k2 f% p0 v0 i<script language="JavaScript1.2">, @) R8 Q! K3 C
<!-- 改变下的字体的大小。颜色-->
% v* _/ m7 o/ Z, Z- u7 G/ L) wvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ j9 J/ g7 \8 M( ]  a
var hidetimer='';: m" I$ X4 X) G; ^  |
<!-- 改变下的弹跳速度-->% U! h( B3 Q; u
var BallSpeed = 20;; D8 Z3 \4 P4 e9 W4 J3 i
var contentWidth;; u+ g+ s) @" G/ q
var contentHeight;
; ^, q% M  z/ d, f: k& @  Kvar maxBallSpeed = 50;- A( {2 E0 B+ B9 j3 m

# F4 n7 }; o/ u0 R' Q9 ^
6 c$ p  Y3 J/ [var xMax;
; P) q1 `' g# m! x, {( Jvar yMax;# r  I5 Y* Z0 ^( u) b
var xPos = 0;
. s  o6 t' n  X# X/ Y* H' t0 ?" f' }var yPos = 0;. q' x' U' ]+ s6 `; X/ y, ]9 S7 K
var xDir = 'right';
: o/ P" V3 B0 G; p1 lvar yDir = 'down';
: C; x! C! t+ \, o* b8 c2 jvar superballRunning = true;7 m& V5 ^$ T, c6 j
var tempBallSpeed;
9 [- z1 o9 M7 n8 f: a/ H. i2 p7 I. o8 Pvar currentBallSrc;
- W6 V7 d7 Z  w( Yvar newXDir;
- v* U3 Z0 ]2 e# a( R7 n5 pvar newYDir;
4 r" H7 k! }, w4 J! ~
0 W$ x4 X. E% d9 @function initializeBall() {. s4 V2 ]2 c6 a
   if (document.all) {
& {! q; {6 T7 s! c# B7 {3 s      xMax = document.body.clientWidth; s( O: [& v% J: ~" [5 b
      yMax = document.body.clientHeight. K8 |6 |  I, s$ |4 Z7 W0 q; I  O
      document.all("supertext").style.visibility = "visible";
( s9 B1 C5 i8 l3 n      contentWidth=supertext.offsetWidth
" X2 V5 I2 J$ s; A6 q- N' U8 n7 Q      contentHeight=supertext.offsetHeight4 H1 b( h; x/ f, H
      }
2 ^4 X- O: f+ e- S/ o: W' ^8 l( D   else if (document.layers) {
) k" A5 _( [, ?6 u  \$ L4 B, s      xMax = window.innerWidth;
/ j; q0 q9 N8 o& {9 x  c2 x- X      yMax = window.innerHeight;
7 e" }% ~0 K# t; e# n; N, f; s      contentWidth=document.supertext.document.width
! e: [& s/ F! [# N0 @+ P      contentHeight=document.supertext.document.height
" K4 p4 T3 Y! x. T) y9 ~      document.layers["supertext"].visibility = "show";- n% P7 G, u$ m
      }
. j9 Y0 h1 D. b! L; v( ^   setTimeout('moveBall()',400);7 ~0 \/ \7 @9 y" I
   if (hidetimer!='')
9 H4 O5 d$ E- s0 _   setTimeout("hidetext()",hidetimer)7 o1 w4 [" c4 u! d
   }, f, t  U) R2 H, K! Z/ J# ?! h0 h

, A% a# ?& u8 L9 Y/ i' q, k9 D0 Qfunction moveBall() {$ K$ s/ @. y! i0 x5 K
   if (superballRunning == true) {1 f. H9 j. ^5 I; D9 s1 w( t
      calculatePosition();, w2 O" w" v; j( F
      if (document.all) {
6 m) u5 E: E( a         document.all("supertext").style.left = xPos + document.body.scrollLeft;
  j  d( t  I& b/ T' {( R         document.all("supertext").style.top = yPos + document.body.scrollTop;
. ]9 k. L6 O( {6 C         }
5 c, s7 v( [0 T' A( v, Z/ |1 z      else if (document.layers) {
( y% {# \5 a9 g/ i' D         document.layers["supertext"].left = xPos + pageXOffset;
# x8 t1 h& h( `; X( ?: G         document.layers["supertext"].top = yPos + pageYOffset;
% x/ [8 `5 D- r6 @6 ?         }
' o0 x8 p. e! {, e5 l) n      animatetext=setTimeout('moveBall()',20);
5 k) K3 k! E; b+ O, n      }3 f- T* W4 c* `3 M3 W: y
   }
2 T9 a0 e# K: m  P5 w1 V# @1 A( i" V- i* s
function calculatePosition() {( f7 j. ^) N; w: h! S! u
   if (xDir == "right") {
: M- n, v1 W; M3 v6 _! e6 O4 w      if (xPos > (xMax - contentWidth - BallSpeed)) {& n8 W  a1 |) y5 y
         xDir = "left";
. P" X, y$ W- K+ n) a         }
8 ?5 J, g' a6 ?/ S  C% [      }0 p/ ]* l! }' n' B
   else if (xDir == "left") {) G3 r, Z4 K9 f$ z8 `
      if (xPos < (0 + BallSpeed)) {
8 e6 Z$ G7 _6 l  U1 E+ z: e         xDir = "right";+ H% I& h: {# d0 f0 X" m
         }( ~1 @! W: p6 K8 H) I' y0 i
      }
9 U1 Q1 D% R- f   if (yDir == "down") {" p# }: h& ?4 j- G4 b
      if (yPos > (yMax - contentHeight - BallSpeed)) {
7 L  {$ a  g# m) N0 m' |1 q; G3 s+ F         yDir = "up";
" R7 y; `  b. k7 k0 p         }
7 N, C/ C5 L+ b/ H) r$ U      }
% C, ?9 l: U9 ?   else if (yDir == "up") {4 @- i2 T0 W; ~4 s# y' [
      if (yPos < (0 + BallSpeed)) {! G; H% J' i9 Y/ [1 d4 G, o
         yDir = "down";. z) b. ]5 c# ^; I
         }
! P- @7 U: E- |4 k) `      }
) Y1 u  w! v9 B' P   if (xDir == "right") {0 F8 r- P8 Q/ I0 t3 I2 l$ ^
      xPos = xPos + BallSpeed;
9 C& `5 s5 q) Q9 Q+ H( w7 D* L      }
0 ], o$ b' e) N9 y- i7 w2 l   else if (xDir == "left") {
% g9 E2 G9 I! u( j( h& q% |# J      xPos = xPos - BallSpeed;, X3 D: M4 B! B& m
      }" M& _1 n& z# }6 |0 X% t
   else {
) L; v, v: Y( N' l1 ]0 V1 a: h. p      xPos = xPos;
! \( z, O9 W  k8 k) e5 D3 K1 M      }
% \1 Y, G( p; m! B   if (yDir == "down") {5 v/ V" x; g' `- @' e& [: H
      yPos = yPos + BallSpeed;
6 B$ T# N  X2 X7 h5 @' p      }. i5 G. P4 @' A
   else if (yDir == "up") {
3 }3 s0 w) G- \% r      yPos = yPos - BallSpeed;9 Z$ S% E4 j( t8 o" v) i
      }( X' w; `, K& E1 K) M8 q
   else {
$ q8 g" m# U4 T3 S: j% d# x      yPos = yPos;" e3 X& R8 {0 Q! q( _% `2 {
      }
: z  D& F3 _* \4 t# ?4 }2 l7 l   }5 n4 l2 q/ e1 }/ \( K, g2 G

- i5 j7 o; K2 U  W; y$ Jfunction hidetext(){
: g+ n' I1 C9 F+ ?2 I7 v) a- f) t" dif (document.all)5 F: \% [* l* t" f" u8 H8 ]
supertext.style.visibility="hidden"
+ e$ E$ b3 T& yelse if (document.layers)9 ~  w/ Z6 @# H& E! o
document.supertext.visibility="hide"& q+ \( u9 v  \. e2 M8 j
clearTimeout(animatetext)
& w! ^" j4 z" w; e/ F+ Q4 {}
3 O' i' k8 J$ x, B5 @+ a: M3 a& l) B; W
if (document.all||document.layers){
% u* M1 O9 H2 R  M1 n% {  fdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 X8 Z, _% r) p# Wwindow.onload = initializeBall;
) w- s9 t' L, z& ^window.onresize = new Function("window.location.reload()");, O3 ^9 F/ j" }7 N( T
}% a* O, S7 ]% G

& U6 B' N' M; Z. x4 p6 l( j  ?1 F</script>

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