返回列表 发帖

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

<style type="text/css">
& u3 D8 ~4 s, U3 g& o#supertext {  y6 t1 Q, o# K' M( y0 I$ p
position:absolute;
, t. y( ~0 z7 y) Y  b8 `left:0;) K; r2 Z$ u  y: W$ j5 \
top:0;
3 c* \) h* p  Cvisibility:hide;& m. o3 e) k- q2 u  y/ x9 a
visibility:hidden;
6 G, l( u) j+ `}
3 t2 ^8 n/ c9 `  S' c</style>% q5 e) Q0 v" o/ V) I# S) q
<script language="JavaScript1.2">
8 S- m4 s" R" u% ]<!-- 改变下的字体的大小。颜色-->
; T) a# A5 |4 w, Q1 l2 u/ I4 p1 dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'6 P) |* j0 S1 ^. a  U9 u
var hidetimer='';7 s* q; p6 Z2 k
<!-- 改变下的弹跳速度--># P' @5 t3 R& o
var BallSpeed = 20;( {9 b. w* W1 V/ o9 q- `( a
var contentWidth;9 y# ?% r; b. C) m4 h8 @# q
var contentHeight;
7 f3 `/ L4 k# ^. ~% p) P8 I* J# Xvar maxBallSpeed = 50;3 T" X& Z' \- Y* U" R: P

  k/ Z5 |2 C# Q8 s' \2 f& f' U  ~- R: h/ R& `, m0 U, b6 L
var xMax;
0 P7 m$ M. w7 _/ o2 c; N( |6 |. _var yMax;. h9 a0 i& F- N9 ~9 R: k7 `
var xPos = 0;
6 D2 p1 l8 t9 d9 Mvar yPos = 0;
" v5 E1 l; H" u# z4 Z" rvar xDir = 'right';
* m5 V! G8 D, }/ T- ]1 y+ bvar yDir = 'down';* I( y+ K* P( F7 X* y& A1 A; _2 m
var superballRunning = true;
' ^. D$ T' s- g6 ]* O3 o* ^var tempBallSpeed;/ \- k  v4 H) x% X
var currentBallSrc;. [; z, U+ ^# t9 m6 f5 b0 N' m
var newXDir;
$ y/ t7 w2 A) h$ ?' b. O% T" h9 u4 P) @var newYDir;
' ?  |* ?, w: g; C6 Q6 e% {7 |
# ^4 T* J( w8 F% L5 }; jfunction initializeBall() {
9 N7 K* B0 o6 b: I   if (document.all) {) _3 C' c+ U- X. I3 g( }$ E. p7 [
      xMax = document.body.clientWidth
' J+ M5 J! ^! X      yMax = document.body.clientHeight6 Z& D4 P: g( U# Q, D( j
      document.all("supertext").style.visibility = "visible";$ ]- Y$ O5 N4 ~1 a7 ^/ P1 Z8 D$ b
      contentWidth=supertext.offsetWidth
3 a; X4 L2 _4 f$ r2 q0 X      contentHeight=supertext.offsetHeight/ Z* x/ X# U+ l1 ]" J' V8 A
      }; i5 X9 s4 d9 a# V& E" z
   else if (document.layers) {
0 [' |" Z9 d% Q5 r# s% n      xMax = window.innerWidth;
, \; u2 L; N0 w7 p7 p/ S5 h/ O1 W      yMax = window.innerHeight;
/ R% @: _2 F" h8 k      contentWidth=document.supertext.document.width
# e7 p9 T1 e' Z$ b- g2 `: \/ |      contentHeight=document.supertext.document.height
9 Y' p. J) u3 {* r      document.layers["supertext"].visibility = "show";
) e$ _7 C" D# {      }+ a! H7 e  M0 I3 n
   setTimeout('moveBall()',400);: g, s8 `4 B* x$ I7 m1 n7 `
   if (hidetimer!=''). n8 _) P8 F) b
   setTimeout("hidetext()",hidetimer)* R& U/ S) R+ M# C
   }2 r: C, g6 N8 p) i
4 C9 s3 j) I$ e& b
function moveBall() {( g' F0 m+ c: S9 V6 J0 g. E+ X2 I
   if (superballRunning == true) {
, X* f( v' N" \; R3 z" C0 |) u      calculatePosition();
7 V' A0 K3 V" Z+ y& w  g      if (document.all) {
/ k! E# h) O+ N9 h1 c5 g! H         document.all("supertext").style.left = xPos + document.body.scrollLeft;" \3 w, P  {$ v4 H9 ?) x* J9 i% S
         document.all("supertext").style.top = yPos + document.body.scrollTop;4 @( {8 q: x% }
         }
6 b" J# m2 {. J' D      else if (document.layers) {, K4 Q0 A5 ]& `1 D& ]: V+ w  N
         document.layers["supertext"].left = xPos + pageXOffset;% L  t$ V! B  |7 \
         document.layers["supertext"].top = yPos + pageYOffset;
3 t- ?! j4 ]3 _3 B         }
0 o$ r+ b, p. ]  V: S) M% x      animatetext=setTimeout('moveBall()',20);
0 W: t! v! w. k, k8 X/ k      }
' {& z" ?( e1 C   }
! ?! e( ]$ R# S" c* Z, |* |! H) A& {
function calculatePosition() {) i9 {) `7 y' ~" f8 q3 E- ^5 W: g' z
   if (xDir == "right") {
  P9 B% ~4 J- ~4 W8 E9 X      if (xPos > (xMax - contentWidth - BallSpeed)) {- H/ }. E# i3 _$ _' X: q+ m0 ]" A
         xDir = "left";
/ {( i) {1 [, s& A& b7 O         }
# B* J6 t9 E9 b) t7 R- e: f2 D      }4 ?7 Y7 J6 g4 I% q' h) f! i
   else if (xDir == "left") {
8 z/ N, M  V8 C- m" w  e6 `      if (xPos < (0 + BallSpeed)) {
) V7 A( S" P3 h5 H& }- K         xDir = "right";
" d1 z) n5 ?3 t+ M         }
6 X+ S9 |2 H7 b- H" `' H3 c      }
; }0 F$ ]9 q' e   if (yDir == "down") {5 w* t" `# m* p! y3 C, {
      if (yPos > (yMax - contentHeight - BallSpeed)) {& C2 \1 ]. e' [) P. g
         yDir = "up";8 j; v( _+ p  h- e- l: q
         }! B, [1 w7 K& L+ k5 \& @
      }6 A& J( |2 y+ F5 e7 m; D' n
   else if (yDir == "up") {
: x$ o: O8 |, ^- Y. w( x" _      if (yPos < (0 + BallSpeed)) {- |# X+ R, j- p1 W  ^* q3 r
         yDir = "down";) `0 T6 l" ^/ h9 M0 ]3 R7 q
         }
( q% L5 ^% N$ b1 P: u7 J1 n      }
5 C3 F: v; \; T1 F3 t* `   if (xDir == "right") {; H1 A# J& D8 V" `
      xPos = xPos + BallSpeed;5 n& {6 n& b0 Q' n
      }+ e! x% ^- \8 ~% I# k' o/ g: [, K
   else if (xDir == "left") {! j! Q1 h) A. ]! j& G6 l8 k
      xPos = xPos - BallSpeed;
- V( g5 H6 ^% R( m' S, D. w  X      }
0 i, f( g% P. ]7 f& g  W& \   else {5 B0 u) y* ?# J: i2 Q. `  J" J2 O
      xPos = xPos;4 A6 d; ^# f! k7 r; N
      }
5 e: ~+ T; F: H* y/ j4 x% y   if (yDir == "down") {
( q6 j3 c  D% T7 f- x( @      yPos = yPos + BallSpeed;
* t, S: p  |6 J9 H, }      }8 W! e, y1 l3 U1 @9 G, A' f
   else if (yDir == "up") {
/ b: ^2 ~& W6 b3 I* X5 o      yPos = yPos - BallSpeed;
' i" I/ }) M4 C- S# c      }
7 x2 ]7 I- ^5 }/ a   else {9 l% V, r$ ~- o
      yPos = yPos;
2 c9 l4 z6 c2 }& ~      }% t5 g% l! ?! T' q- e* M0 d* o0 \/ j
   }
( Q/ V# w: P: u+ d
- Y+ ~2 s) ~: P8 n4 D  }: M, Rfunction hidetext(){
$ A6 Q$ A/ t5 b( Z; f2 ?+ B9 dif (document.all)
- T" W5 o( [! |% Csupertext.style.visibility="hidden"
" N2 x1 l$ c& o  I' zelse if (document.layers)2 Y0 z, E% }' W+ I# O! E
document.supertext.visibility="hide"$ X: _. ~$ j" q6 [- X
clearTimeout(animatetext)2 h3 A) V9 O5 u  `, c. j4 ?- f
}
# I+ v, ?: B! B: Y/ [5 Y
' M' q" U4 o  J2 L* ~7 K3 i* Z4 hif (document.all||document.layers){3 p& e9 w2 S0 {" j
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 ~% e( x" e3 D: cwindow.onload = initializeBall;
, d% m, }6 z: b0 g$ Q, j1 @window.onresize = new Function("window.location.reload()");
+ O* f" b* g6 y" b$ p1 W}
8 V8 @6 n2 L' E+ D
+ P. B7 o; c$ K; g  j</script>

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