返回列表 发帖

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

<style type="text/css">9 ~. O9 k8 Y/ b' w( e7 j& X8 \& s( G% r
#supertext {
' h& m, T- i, h8 a3 V; ]position:absolute;: ?" R% t, k( J3 `
left:0;
9 |+ O. r( F0 {5 E; I: {; y4 Ltop:0;; d! s# ^  \3 L4 s
visibility:hide;6 z1 W5 y8 a, H
visibility:hidden;
: i6 ]4 r$ k4 T% y}
' l* ]" a: p  W$ M' j</style>$ N1 f/ m+ ~! S; e  U
<script language="JavaScript1.2">
7 U  X4 [% ?1 m2 y  t<!-- 改变下的字体的大小。颜色-->; Q2 F4 E& f, U3 {  S8 `/ Y0 E* k
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 T1 N) p& y) J# h+ b  ivar hidetimer='';# V& l' ~. }" w
<!-- 改变下的弹跳速度-->9 J& {7 q3 E# Z3 z; L1 r3 k
var BallSpeed = 20;
5 w6 V9 h' \( q  D, J* Uvar contentWidth;9 X6 U0 T( I! I8 r9 s3 f
var contentHeight;5 h7 X  t! x- x4 q$ o
var maxBallSpeed = 50;
3 `: M( N* d8 Z% k$ Z# I/ ~6 o6 A( m) }( u

5 s0 `/ y! F! h" V& Vvar xMax;. e+ j8 |, w: ?3 K3 w
var yMax;
$ a, K- f& s2 P: T) O; qvar xPos = 0;4 |- |3 m* i  P
var yPos = 0;
. Z, i) T; R- o0 y) Pvar xDir = 'right';
# a4 }5 o  N2 n" ]6 i, Fvar yDir = 'down';
# l: M/ c( \; Z2 R6 u" M1 gvar superballRunning = true;$ y! f1 L& H3 p
var tempBallSpeed;( B2 J4 t- k3 X
var currentBallSrc;- I0 M0 f' d& X2 K8 t( w8 `6 R
var newXDir;
# c6 b- S' z" q3 Nvar newYDir;
, _+ {+ U& F+ Z5 f0 n( h' [: }, E7 F3 }$ c; I3 z
function initializeBall() {
' j. L+ F4 }+ W: l1 W   if (document.all) {9 R( |( g$ G: r6 S
      xMax = document.body.clientWidth
! r7 A: m! h/ w% ]5 H1 J; G- e1 ~* g      yMax = document.body.clientHeight. G$ K4 L$ ?2 S
      document.all("supertext").style.visibility = "visible";, H( X' p0 U' n% Z. ~8 N' I) t
      contentWidth=supertext.offsetWidth
6 G! a$ g8 U( B' D8 B  U& g      contentHeight=supertext.offsetHeight# X" o8 U( ?, h4 z9 W5 {9 T0 g6 T( X
      }
% I' Z( M/ g. Q' H# M) ^   else if (document.layers) {4 d) f9 I6 s  R
      xMax = window.innerWidth;1 }5 Z' w4 N) J3 r8 y$ B
      yMax = window.innerHeight;
0 A7 P( A" c. {) I: T      contentWidth=document.supertext.document.width# T8 f9 C8 @) M1 N, g# h
      contentHeight=document.supertext.document.height
/ u5 L: o7 c: A/ O$ A6 c      document.layers["supertext"].visibility = "show";, |, C) R2 B8 M; U( W  Z/ y
      }, U! X: U5 R1 A2 J- k$ W
   setTimeout('moveBall()',400);8 ~3 k% ]! l* T# o( H& h
   if (hidetimer!=''), L7 s' c5 r3 G% u2 V  \* ~
   setTimeout("hidetext()",hidetimer)" A8 X5 ]- L. @0 U; s, Q8 d# U8 m
   }
2 H. \0 n* o; K7 y2 g8 f$ }5 v
& |* Q2 z7 u9 C7 I% @function moveBall() {
5 L) f2 A7 ?# C9 F* Z  \   if (superballRunning == true) {
9 z; K' g5 ^$ n, `, {: S      calculatePosition();: s7 i- T2 O6 ]$ u9 L4 V- f
      if (document.all) {( t1 A* F4 {9 ~  b8 ^- }
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" ^/ b. \5 j. o4 G6 s/ G         document.all("supertext").style.top = yPos + document.body.scrollTop;# v9 {# O) J& k5 t, C
         }
' z6 c, @1 h. f+ K$ }, j/ _0 o      else if (document.layers) {
; o0 G  d5 ?* f. o         document.layers["supertext"].left = xPos + pageXOffset;
: a- n- i$ Y$ I; [* o+ K! v7 f         document.layers["supertext"].top = yPos + pageYOffset;# o9 a9 d/ q/ o2 Q* H$ D+ b  Q
         }
" ]5 D$ O/ e# Y4 K* i4 a( @$ K6 z      animatetext=setTimeout('moveBall()',20);
3 B5 i6 d0 d& |      }- u3 ^% S  Q" l& T; O: f7 I8 v
   }8 b- l8 K# j6 k$ E
2 F+ F" L' }# N
function calculatePosition() {8 ~8 n9 ]7 p5 U+ v* J
   if (xDir == "right") {+ `! G1 `8 h9 x
      if (xPos > (xMax - contentWidth - BallSpeed)) {% V1 O- j, U' d2 |" R- V
         xDir = "left";
* G7 G6 Q8 F$ X' S* M. j) j2 H         }! U0 ]7 R$ q4 R" u- R/ y
      }) \& q$ C& e) \' W. e
   else if (xDir == "left") {
* `* s0 ~) c4 y* k, l5 l3 H      if (xPos < (0 + BallSpeed)) {8 r; l% I& ^9 y0 w# g
         xDir = "right";
5 ~7 G0 @. p- r2 `/ Q" i7 {         }
( U$ V+ M6 J* R1 Q4 N      }
% h" |! ~$ o7 r2 K8 y  W; T/ f   if (yDir == "down") {
. @' l, M( L4 h6 \- M( Q" s0 |      if (yPos > (yMax - contentHeight - BallSpeed)) {
% _. a6 H1 o% Y         yDir = "up";* p& [) u: K* W0 r: p% n
         }% D. X5 N$ q1 V& v+ O' ~0 X# H& \
      }
/ M8 f" j+ Y; z( p2 c4 \   else if (yDir == "up") {  Q5 w. D, {  ]3 k1 C
      if (yPos < (0 + BallSpeed)) {1 j; `0 v1 Q) n5 Q4 K" I& i; x$ x5 T
         yDir = "down";
. o, g; O# ?3 m( |6 r! k( K: Y) m' z, J         }" N9 G: ~) @+ ], s
      }* Q3 `. n1 h- ?& K" \: B  F
   if (xDir == "right") {+ m4 ]( i* Q( G; \) ~
      xPos = xPos + BallSpeed;
8 @$ \* x" |4 j4 Z* `8 N      }
5 ?, i8 q- w7 J7 R5 |6 {   else if (xDir == "left") {
2 i8 b2 K$ l8 ?) v      xPos = xPos - BallSpeed;( K% w2 G* m2 N6 s6 w6 Z- U: n
      }
# v- Y- v! m% j# a   else {
; k6 U1 c& [8 X0 ~% Q) H. Y      xPos = xPos;& l* @. r  `- w' T2 P0 h8 n
      }
. o6 k8 y1 T7 z: ~8 y0 j/ Q, a0 x; Y   if (yDir == "down") {
+ ?" l2 W7 `# J0 y/ q- g7 ~0 ~      yPos = yPos + BallSpeed;
8 I$ w: P* P& G# r8 B4 Y      }
5 s" I7 \( F" V0 g# g   else if (yDir == "up") {
9 G: [& [8 Q& u) E; @      yPos = yPos - BallSpeed;7 h, A! }4 n* U3 P% d  e' }
      }
% T9 O' N1 r% n! C   else {5 n: q# L  Y( @+ d1 E( H
      yPos = yPos;
# I( n, I' Y6 N. |      }# g6 H! N9 z+ @$ A! ?- t* M' S
   }& J0 ~8 _' n' J6 H6 @
( V- d+ L& `2 h4 @8 K
function hidetext(){5 w/ K& M& M! E. d; b
if (document.all)
+ }, P( _" d8 O7 A% W0 @supertext.style.visibility="hidden"5 w# w9 D7 p/ k: ]$ i
else if (document.layers)
& D- Z8 a, y- V" s7 E8 E/ w* pdocument.supertext.visibility="hide"7 j6 w& o' ^, o+ e
clearTimeout(animatetext)
( j  d6 o9 c2 V; }! V# D# V}/ a( {8 [8 Q) j. }$ B0 O% A
5 x3 V( j$ T& u- ^7 ], h
if (document.all||document.layers){3 A8 J+ N$ `3 a* Q4 d: L* m
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 x' e4 N6 X! v  ]# awindow.onload = initializeBall;3 o5 ^) w2 h4 A& F7 m. }
window.onresize = new Function("window.location.reload()");9 }( d) h2 M% I  M" Q
}
& D3 F: {6 G5 G3 Z% Y9 T
2 o, i3 i/ x$ w1 x( W</script>

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