返回列表 发帖

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

<style type="text/css">
. C- q1 }: B% I- v- s8 H1 ?$ Y8 ?#supertext {
% T" ]" e6 T7 N- E) @: kposition:absolute;. x( `7 ^* o9 I
left:0;, v, J% j' a5 [  ^4 f
top:0;5 a1 V; b4 [( S# J. Z# G8 U4 E
visibility:hide;1 ~; q3 E6 y0 z' B, X$ h
visibility:hidden;
9 W% u" e, Q% d1 Z+ n6 p) j, T}" d. f% N8 }4 D. Q+ ~1 \
</style>
6 M7 D) G  H, |5 i, F8 d<script language="JavaScript1.2">
  M" @1 S# X/ Q8 r0 t) J2 P<!-- 改变下的字体的大小。颜色-->/ l0 k; [( n; \2 A6 R3 g2 {
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
  q1 W0 q: T6 V) K/ _' M' [var hidetimer='';
- o7 a" O+ K2 o+ n8 U<!-- 改变下的弹跳速度-->3 W+ a3 X% _$ n/ r$ [. C
var BallSpeed = 20;% O; q3 ?* Q0 C0 d, M1 f! P
var contentWidth;* @# s8 z2 v" P
var contentHeight;- a& w$ \. H4 x8 i+ s
var maxBallSpeed = 50;
- |! U" o9 S$ D" z8 w; d4 L" J& z) y
: m' V  `& f( Q! m3 q, ^& P( z0 t/ L1 q1 P4 D8 o) ~  a
var xMax;2 s  a: E, E" X$ d# }1 }, N- J( i
var yMax;
, C" h# O  v: V% V  z/ p' P6 Bvar xPos = 0;* h# k+ Q6 n7 _5 y6 B
var yPos = 0;
6 x+ @* n4 @0 c  h( Fvar xDir = 'right';+ y. Q5 G" q4 `: V
var yDir = 'down';( r& V6 j7 \. j9 @8 m" ^
var superballRunning = true;
, }; t( V0 N* r2 b6 r' jvar tempBallSpeed;
- V' K, a8 n3 _) B; n8 evar currentBallSrc;
" }5 S( `3 `( G$ {; [var newXDir;
) x( o; S, o) |; Vvar newYDir;
3 B& C. J* x- o& H8 o. L$ s5 ?9 D# ]4 V6 I
function initializeBall() {" Q! Z) l; L# l- \+ t
   if (document.all) {
2 d% L& r" b* J1 F/ f. F8 X      xMax = document.body.clientWidth; d! m% E! x# O+ M& \7 ?1 {- w
      yMax = document.body.clientHeight" K) O3 ]) Q: F. l$ O" S) j( Y  F
      document.all("supertext").style.visibility = "visible";6 Z$ h3 p3 K$ g
      contentWidth=supertext.offsetWidth
  N( m) R- E" F8 X( \      contentHeight=supertext.offsetHeight
, U1 V6 a" ^# ]2 K- r( {2 |7 s      }; L4 W8 x/ s+ l- M, X& N6 W: }) `
   else if (document.layers) {
* }7 h/ Q' A6 }/ {  y$ d      xMax = window.innerWidth;9 Q0 B. l& M$ C; I/ E) A6 Q
      yMax = window.innerHeight;! Q/ y- u' _. ?/ K) O6 h& l3 r
      contentWidth=document.supertext.document.width
1 o% \( }: N  A+ G4 P% J      contentHeight=document.supertext.document.height
) W' I' |7 }. A      document.layers["supertext"].visibility = "show";
; m3 O# f) J# M9 c6 A. T      }
! [1 K' N. k& T( J. u( |   setTimeout('moveBall()',400);
' d1 G& M& J+ ?0 l0 z# P   if (hidetimer!='')
6 D2 K8 e$ |: z# k  Q; A' S   setTimeout("hidetext()",hidetimer)
# h) w- q, ]3 t& i/ s+ f& M+ X   }9 W6 a8 V! p) |0 K& F# y
6 ?7 z; D3 ^1 [0 L. z+ g
function moveBall() {
; t  u+ k: b& {, M   if (superballRunning == true) {
  I1 Z: ?$ S7 P$ }$ o; p6 J* \      calculatePosition();
  E, }5 Z, C/ o+ ^# p      if (document.all) {3 ]( C1 I; X1 v! U. U- S% D' x9 y
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
' S: ]1 z6 \& W3 Q5 O         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 w( ^& ?: X7 |9 h+ W( f( D+ k         }. j3 m; P( }- g  j, [$ ]
      else if (document.layers) {
1 H& u$ q/ O; ^  K' K0 p* Q" t         document.layers["supertext"].left = xPos + pageXOffset;
; b; W, `2 x. O9 R- e& z& h5 y4 E         document.layers["supertext"].top = yPos + pageYOffset;0 Z; @& J7 w/ o* `7 s
         }+ N5 H- E) ^9 j* M1 J; N6 E
      animatetext=setTimeout('moveBall()',20);0 r6 T+ M! M0 D5 K  B8 Q7 {! t
      }. G0 e0 A& x8 i+ ?/ u
   }
3 S: p! X1 I4 T  r( o" w* T* v
8 W# V3 G6 y8 K$ j# B5 n0 Rfunction calculatePosition() {5 l. @; @, c& c' _# g' I8 ?' c
   if (xDir == "right") {& Z" e& m6 _9 ]* v7 u6 q
      if (xPos > (xMax - contentWidth - BallSpeed)) {
: i: ?  ^% c4 L4 Q         xDir = "left";! ?$ r/ H3 W6 c! h" v8 Z( b
         }
' v8 v3 H. P( y3 [6 r4 z$ _      }
5 ?+ W3 [5 _, T2 ^4 Q   else if (xDir == "left") {
  w' b: K6 z2 h0 P8 m. |      if (xPos < (0 + BallSpeed)) {3 J" w2 K4 y8 v6 @
         xDir = "right";3 s: `% h2 c  Q, G9 o
         }
3 `( a- {) [6 ^  n! I      }7 M! |! o; X0 x) A0 O
   if (yDir == "down") {
! i0 D. l# {; N) u5 A      if (yPos > (yMax - contentHeight - BallSpeed)) {5 Z! m, p4 i, s. A
         yDir = "up";8 I1 w) K0 d3 T$ H1 Z% @
         }
  h& a2 {; m+ H# E. {      }# k( I' n1 W. u* p; r0 ~
   else if (yDir == "up") {' G* l7 \# r" v( A
      if (yPos < (0 + BallSpeed)) {
. f& s6 i5 N* W' H% n* K         yDir = "down";  W0 [* k. y5 U( b. ]& H
         }6 {+ D* v9 q7 _; {1 F
      }
( _8 l& t2 A3 A! [" \+ _   if (xDir == "right") {9 s  n3 F4 N* h6 _
      xPos = xPos + BallSpeed;; T* z% r7 ]' t$ z
      }
/ n4 ]" h! `. |4 q   else if (xDir == "left") {: D, J9 i$ d, |6 A! u: y5 {
      xPos = xPos - BallSpeed;: u8 H. O$ t- d$ h$ F7 h
      }
* q7 N; R$ Y' U/ W; R/ J   else {* g" y* e5 ]6 D0 G( Z7 a0 j. }
      xPos = xPos;! y) i1 n8 U+ T$ H
      }
4 N  L+ `7 k6 {   if (yDir == "down") {$ A7 h5 N$ T0 ?" j3 I, I' R7 y
      yPos = yPos + BallSpeed;
& L5 L8 ^1 C+ s0 R/ a. l      }* H; W  Q7 x" \6 u! E
   else if (yDir == "up") {
6 C0 S% e/ \( Y8 Q      yPos = yPos - BallSpeed;2 [; y, [  D# h  @4 C  G! \
      }
' J3 G7 F6 G4 h  R% C   else {
/ b7 |/ i; K3 t, e/ L      yPos = yPos;
' W' J, z9 Q* ~1 p! n' `0 r      }
* P! f! v6 H. T5 c7 e   }3 ?& f) ]1 b9 }

$ L, C" S7 a% o6 _2 ?, L# Ofunction hidetext(){3 [3 L, u5 `) }* G" Q- m
if (document.all)
/ }4 O. T1 N6 P. Z( Q8 K' c' \supertext.style.visibility="hidden"1 D; d1 A- {8 I4 y  Q8 ~: u
else if (document.layers)2 t& O" G6 k$ j8 P
document.supertext.visibility="hide"# O9 m, k! a) x6 k! }( D9 t7 G2 {
clearTimeout(animatetext)) A8 h) K7 f8 ?3 _2 P% b5 H
}7 ]' |# L, [7 w1 H7 O! U! H
/ d* V$ ^9 h% G
if (document.all||document.layers){
. `/ T7 s3 H) \% q' \1 sdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! P  m) ]/ O! i$ [window.onload = initializeBall;3 H, T0 C0 u( ]' o$ s. [0 K
window.onresize = new Function("window.location.reload()");
0 \9 c3 a' L' u% l% N9 r) {4 R0 W- F# k}
) s; v9 I* ~& P5 a
7 @6 f, J( G3 {</script>

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