Board logo

标题: 网页之不断弹射的文字-特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:55     标题: 网页之不断弹射的文字-特效

<style type="text/css">
+ h' ]" U0 b. c9 ~- l% {0 {$ n#supertext {+ Y3 X' g4 ?6 V6 K1 h6 I
position:absolute;" y0 `3 ^: ~4 V. B" F; ^) D
left:0;, z1 A+ l  }9 P' h$ J& v  W! _! u
top:0;6 H% P8 K* p" W1 i3 E" H
visibility:hide;
. R8 o9 V$ {& R; Rvisibility:hidden;
) H" ~+ T& ?8 H% O0 O}# K; }3 @0 o  M) G7 b
</style>; u& D" A0 H3 Q1 t5 p
<script language="JavaScript1.2">
$ x/ u2 D3 s6 |3 o1 Q8 u<!-- 改变下的字体的大小。颜色-->
7 W& e# J7 {8 T7 \9 Z8 Wvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ ~6 A( p4 x) v2 l
var hidetimer='';- J( c" q8 L. ^
<!-- 改变下的弹跳速度-->) S7 {& z: F% E' L& N, u( _: |* ~/ L
var BallSpeed = 20;
$ N% z; n5 y# W5 R  Dvar contentWidth;
% G7 x5 q0 B( O: Zvar contentHeight;
4 L, I  V9 g- dvar maxBallSpeed = 50;
" ^+ I$ T( ?" G9 W7 v. J
% E- d$ Y" i; _; `  L8 ^
3 P' c; l" o& i" L5 J* mvar xMax;
1 B* j5 z2 \; V! Xvar yMax;
( K# T+ Y4 [) \+ s$ J/ Fvar xPos = 0;5 A8 S, U& s% d& h9 y
var yPos = 0;
: i- N: Y2 ^1 r& X, ~var xDir = 'right';
/ B9 p8 z. {8 Zvar yDir = 'down';
3 k% i# ]) s0 E& s; A; H: J* [var superballRunning = true;) H5 b" w; ?2 r9 W1 {7 A9 Q
var tempBallSpeed;
4 M( ?8 P3 p4 j1 ?var currentBallSrc;! M7 y' G% b4 C0 ~  O9 S7 {$ G
var newXDir;* g9 ^' w, V: M
var newYDir;
- ^9 D( i" ]4 J! j/ G7 }  A: }6 q6 O% H. G8 F! g+ X, [
function initializeBall() {
: h$ `# Y- }! \) N* G   if (document.all) {9 [4 ~! E2 U. Z" D; P* r* e+ d3 I
      xMax = document.body.clientWidth, c# s- [6 H+ e8 w( W
      yMax = document.body.clientHeight
  U# J( h" S  a' N0 n  D2 _* l      document.all("supertext").style.visibility = "visible";
  Q" N# a+ p8 x# K% r& `      contentWidth=supertext.offsetWidth0 N( a; V: j+ U2 Z. i* v8 I
      contentHeight=supertext.offsetHeight
+ }. ?  `" z" d" B/ T) T      }
) x, ?5 @0 L+ |5 R   else if (document.layers) {
! r+ N+ k8 |  \      xMax = window.innerWidth;
# A* l9 u4 f+ S' z8 s      yMax = window.innerHeight;2 |* }) b  K) o6 s
      contentWidth=document.supertext.document.width9 J  k3 w  a) v! v8 H8 d4 G
      contentHeight=document.supertext.document.height/ U( \3 b! s$ C/ {2 {0 [& h( ^# |
      document.layers["supertext"].visibility = "show";
2 m1 ?! S9 t% W, E      }
) u! r  T) ?1 r- p/ M8 A/ ?   setTimeout('moveBall()',400);# h8 Z4 d* p4 @" j6 ~
   if (hidetimer!='')8 M' Z( V8 U2 D' @* n
   setTimeout("hidetext()",hidetimer)* l2 o" L! t% J; D
   }. O3 B$ \' j5 F( U4 m% }2 S; B
3 C* o  w+ h; h" ^- |2 O
function moveBall() {  S+ k  E( s( y: A/ D/ d; [9 q
   if (superballRunning == true) {' U& Q4 Y8 T6 V9 x4 u; y8 D" X
      calculatePosition();# \3 g, w5 `8 W  V, n2 \
      if (document.all) {
; E9 j9 |8 ^4 Z2 U9 i. M; T         document.all("supertext").style.left = xPos + document.body.scrollLeft;- A+ v/ m& B1 [
         document.all("supertext").style.top = yPos + document.body.scrollTop;
5 V9 \# i5 h* g* J         }/ `- @! w; R2 Z0 X9 ?" F- s
      else if (document.layers) {
/ E2 n- n; f! I" a$ Z1 X- a; z         document.layers["supertext"].left = xPos + pageXOffset;+ X, ^+ f" n( u8 C$ k) [
         document.layers["supertext"].top = yPos + pageYOffset;
! ?+ A5 Y3 E9 \4 A. l         }
) F  [8 c% K8 B  S+ U, @& M      animatetext=setTimeout('moveBall()',20);) q7 ]8 L% t% d- V, v8 A+ x
      }/ ~* Z, w3 y. X. X
   }# h  w. x- H; P7 @
  m/ W, y! ~: }4 ~% M. C
function calculatePosition() {
6 P' a0 k2 B+ Y# p$ y% L  A0 p   if (xDir == "right") {
  _# s6 ]8 O* o* u- y4 q- ~/ B/ b      if (xPos > (xMax - contentWidth - BallSpeed)) {1 L$ ]- |4 ?6 n2 m/ F7 D' f
         xDir = "left";
% A; p! d8 U. }* C         }
) c( k# j* i0 D/ g, F      }
# w' ^% }0 N. S) {) ^( E   else if (xDir == "left") {
# e( `" M/ f4 `7 t) y1 n" k6 _      if (xPos < (0 + BallSpeed)) {& I; s$ s+ X+ P( E
         xDir = "right";
4 j! h0 Q, _) m( _         }6 t: c2 n- S1 a  Y, M/ g
      }
: x' p4 N, z$ e, s* K   if (yDir == "down") {
* j; S" s0 L5 A8 ~6 O$ A      if (yPos > (yMax - contentHeight - BallSpeed)) {
% ^! v, y8 s* c# O8 v, d1 S1 u4 h         yDir = "up";* X1 h8 q+ q* [. H+ [7 z
         }
* A, n* [& c3 u4 B      }
; @8 ^/ H$ g' b5 z/ e% U   else if (yDir == "up") {
+ a+ n: a, o, n1 p& e      if (yPos < (0 + BallSpeed)) {) S+ R: G" P2 Q- h3 S# `7 |4 U2 ]& v
         yDir = "down";) c& Y, ?' x# K+ b
         }
3 I. p5 V6 ?; c1 Q+ ]* n- ?5 c7 i      }. Y/ p/ A0 a- T: O. M( Z
   if (xDir == "right") {- C- }1 |$ _$ V" I, s: W
      xPos = xPos + BallSpeed;, h# O+ C5 S; }9 \7 `" \* N
      }
4 N* u1 q- d7 P6 u: b5 m) _   else if (xDir == "left") {# e5 A8 @2 y( [+ W1 H8 w
      xPos = xPos - BallSpeed;
8 s8 A; w2 O- p8 ]( K      }
% k5 x6 w/ m$ i) h* \1 V   else {6 f9 n6 r6 L* m* K( Y
      xPos = xPos;
9 w2 P0 ?* y, P8 ~* n" D      }$ }: u# s! W9 S2 v1 x( W9 Q
   if (yDir == "down") {
/ S: s. h1 k# t: y9 S& g% t      yPos = yPos + BallSpeed;, V6 P, ?0 E) f: q6 z- k4 [
      }
3 y/ Q, V' t1 H6 T; z7 F0 b   else if (yDir == "up") {
" y5 v! [$ w  p, f      yPos = yPos - BallSpeed;
+ J9 V0 a+ c/ I9 ^- k4 t      }
$ t0 A) E  t3 m& b: C: L6 A   else {
$ I7 z7 I' u! ?3 O6 e      yPos = yPos;
' R2 t) ^, G4 b7 f9 ]2 ~      }7 R2 i1 u  {4 i4 @# ]( M% @2 J8 L
   }* z7 G8 c/ q3 y$ W
! d$ P1 ]; U4 A: p% h& G7 g* f) z( L
function hidetext(){
$ G7 k: B" L' [- G, @  Tif (document.all)5 I- ?+ s& E  V" f
supertext.style.visibility="hidden"* a& ]& H0 o8 t' S: y' v
else if (document.layers)* z8 V6 v1 Q# x! g* a7 Q4 Y
document.supertext.visibility="hide"
9 _) U+ Z. H5 ZclearTimeout(animatetext)+ |& Q1 j6 J/ H( A
}  s7 E6 K1 `/ w2 }3 i8 \% P: @

; d# v4 ^* f) ?5 R. sif (document.all||document.layers){
' \( ^( F* M. b: Wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 \0 o$ f1 ?2 v7 O
window.onload = initializeBall;
& y1 r, |( B9 O: Z. Iwindow.onresize = new Function("window.location.reload()");! I' j) [( c$ M: N* Q
}+ x! K2 p' S5 S/ N

+ u; z" J  H6 O; Y1 z3 @6 Z</script>




欢迎光临 捌玖网络工作室 (http://www.89w.org/) Powered by Discuz! 7.2